CXR-L(EN)
cxr-l-sdk · v1.0.1 · snapshot 2026-05-13· ↗ source

Development Flow & State-Machine

Development Flow & State-Machine

End-to-end development flow

CustomViewCustomAppcustomViewOpen_okopenApp_okAudioPhotoAudioPhotoCustomCmdDevEnvAndReposSdkImportAuthGetTokenSessionTypeConnectCustomViewConnectCustomAppSceneBuiltOnGlasses_CustomViewSceneBuiltOnGlasses_CustomAppCapability_CustomViewCapability_CustomAppAudioStreamPhotoCaptureCustomCommand

Description:

  1. DevEnv: phone OS version, Bluetooth permission, Rokid AI App, glasses firmware, and (if needed) glasses-side samples are ready.
  2. SdkImport: Gradle / CocoaPods and manifest configuration are completed.
  3. Auth: obtain a valid token.
  4. Session: choose CUSTOMVIEW or CUSTOMAPP (Android enum), then complete configCXRSession and connect.
  5. SceneBuiltOnGlasses (scene building): the glasses side has opened the Custom View (e.g., customViewOpen succeeds) or launched the target Custom App (e.g., openApp succeeds and the app is interactive).
  6. Capability gating:
    • Audio / Photo: in both CustomView and CustomApp scenarios, call only after the link and the scene are ready.
    • Custom Command: available only when the scenario type is Custom App (CustomApp), and requires the target app to be opened and interactive.
  7. The above gating rules are consistent across Android and iOS (see platform sections below).

Android: authentication result states (logic)

You can refer to MainViewModel.checkAuthorizationResult:

requestAuthorizationAuthSuccessAuthFailAuthCancelclearOrReauthIdlePendingAuthAuthedFailedCancelled
  • Success: AuthResult.AuthSuccess persists the token, _isAuthorized = true.
  • Failure/cancel: clear token, _isAuthorized = false.

Two key booleans are reported via ICXRLinkCbk (overridden in multiple places in the Sample):

  • onCXRLConnected(Boolean): CXR service-side connection.
  • onGlassBtConnected(Boolean): glasses Bluetooth connection.

CustomAppTypeViewModel approximates “operational” as both being true (connectSuccess).

configCXRSessionconnect_tokenonCXRLConnected_trueonCXRLConnected_falseonGlassBtConnected_trueonGlassBtConnected_falseboth_truecapability_blockedscene_built_on_glassesaudio_photo_cmd_okLinkCreatedSessionConfiguredConnectRequestedTransportUpTransportDownBtUpBtDownLinkReadyNotReadySceneReadyReadyForCapability

See “Feature Development/Android/Connection and Session” for detailed explanation and code locations. Link ready (LinkReady) ≠ Scene ready (SceneReady): only the latter allows stable use of photo capture, audio, and custom commands.

Android: capability gating (aligned with the Sample)

CustomCmdentryType_customAppsharedCxrLink_nonnullappOpened_trueAudioAndPhotosharedCxrLink_nonnullscene_opened_on_glasses
  • Audio / Photo: sharedCxrLink is created by the scene creation page and connect is called; and the user must first complete scene building.
  • Custom Command: the scene type must be a Custom App, and the glasses-side app is opened.

Cross-platform consistency: unified gating rules (Android / iOS)

  • Audio / Photo: available in both CustomView and CustomApp scenarios, but require link readiness + scene building first.
  • Custom Command: CustomApp only; not available in CustomView.
  • Platform consistency: docs and implementations on Android and iOS should describe the above rules consistently.
  • Observe authentication state via client.auth.statePublisher / eventPublisher (see “Feature Development/iOS/Authentication”).
  • Observe runtime events via audioEventPublisher, customViewRunningEventPublisher, etc.
authenticatesuccessfailurelink_readyscene_built_customView_or_customAppaudio_photo_cmd_allowedlogout_or_expireUnauthenticatedAuthenticatingAuthenticatedLinkReadySceneReadyReadyForFeatures

Note: ReadyForFeatures indicates that on iOS you should also complete the glasses-side Custom View running or Custom App launch before using capabilities.

The gating rules are the same as Android: audio/photo can be used in CustomView and CustomApp; custom commands are only for CustomApp. The exact event names follow RGCxrClient.

Marcin Miazga