Skip to content

Phone SDK bootstrap (ASR/TTS)

Purpose

Explain how the phone initializes cloud ASR/TTS during EngineParam bootstrap and where Ak/SK credentials must be supplied.

Entry points

Phone home shell:

  • MainPhoneActivity

Core routine:

  • initSDK()

Platform

  • Phone

Primary source

Where to look in-tree

Important symbols live in the same file:

  • initSDK()
  • UserAuthInfo, EngineParam, NetServiceType

Continue debugging by walking initSDK() success handlers to see downstream wiring for transport + listeners.

Flow

  1. Build the client-id list (SecurityPhone, GlassSample).
  2. Instantiate UserAuthInfo—fill real accessKey / secretKey pairs for hosted ASR/TTS.
  3. Configure EngineParam, including service bans.
  4. PSecuritySDK.getMobileEngineService().initSDK(param) boots the engine.
  5. After success, continue with connection + listener registration.

Sample snippet

kotlin
private fun initSDK() {
    lifecycleScope.launch {
        val clientIds = arrayListOf("SecurityPhone", "GlassSample")

        // Replace with real AK/SK.
        val userAuthInfo = UserAuthInfo("", "")

        // Skip translation cloud; keep ASR/TTS only.
        val banServiceList: List<NetServiceType> =
            arrayListOf(NetServiceType.TranslateService)

        val param = EngineParam(
            clientIds = clientIds,
            userAuthInfo = userAuthInfo,
            banServiceList = banServiceList,
            envType = EnvType.Companion.PUBLIC
        )

        PSecuritySDK.getMobileEngineService().initSDK(param) {
            if (it.isSuccess) {
                GlobalData.setSdkInitState(it.isSuccess)
            }
        }
    }
}

Boot sequence

mermaid
sequenceDiagram
    participant App as Phone UI
    participant SDK as MobileEngineService
    participant Cloud as Hosted speech

    App->>SDK: initSDK(EngineParam)
    SDK->>Cloud: negotiate services with AK/SK
    Cloud-->>SDK: status
    SDK-->>App: isSuccess
    App->>App: continue transport + listeners

Key implementation notes

Client IDs

Phone + glass builds must align on the same business-scoped IDs — sample uses SecurityPhone + GlassSample.

Auth placeholders

kotlin
val userAuthInfo = UserAuthInfo("", "")

Hosted ASR/TTS cannot work production-wide until BD-issued AK/SK land here.

Service scope control

Rather than banning ASR/TTS, demo bans translation:

kotlin
val banServiceList: List<NetServiceType> = arrayListOf(NetServiceType.TranslateService)

So initialization specifically targets:

  • Cloud ASR
  • Cloud TTS
  • Not translation cloud

FAQs

Why only harness code on the phone?

Repository emphasis places interactive ASR/TTS experiments on the glasses; the phone file mostly unlocks engines and credentials.

Empty credentials?

Init may still report success, yet subsequent cloud calls fail or return empty transcripts.

Why touch banServiceList here?

It defines which optional Net services load during init—here we focus the speech stack.

Launch checklist

  • Request hosted speech AK/SK from BD.
  • Mirror client IDs with the glass build.
  • Gate user journeys that need cloud speech until init finishes.
  • Surface explicit error UI so empty keys are not confused with transport failures.

Caveats

  • Never ship UserAuthInfo("", "") in production.
  • Keep client IDs synchronized across artifacts.
  • Add a dedicated phone-side speech lab screen if product needs explicit QA affordances.