Skip to content

Commit ae446c1

Browse files
committed
refactor(android): make Talk capture policy explicit
1 parent 3b7947a commit ae446c1

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

apps/.i18n/native-source.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,23 @@
7575
},
7676
{
7777
"kind": "conditional-branch",
78-
"line": 1686,
78+
"line": 1695,
7979
"path": "apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt",
8080
"source": "Failed: this host requires wss:// or Tailscale Serve. No TLS endpoint detected.",
8181
"surface": "android",
8282
"id": "native.android.81009c40eed2216d"
8383
},
8484
{
8585
"kind": "conditional-branch",
86-
"line": 1688,
86+
"line": 1697,
8787
"path": "apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt",
8888
"source": "Failed: secure endpoint reached, but TLS fingerprint verification timed out. Check Tailscale Serve or gateway TLS and retry.",
8989
"surface": "android",
9090
"id": "native.android.467899bb510b8e34"
9191
},
9292
{
9393
"kind": "conditional-branch",
94-
"line": 1690,
94+
"line": 1699,
9595
"path": "apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt",
9696
"source": "Failed: couldn't reach the secure gateway endpoint for this host.",
9797
"surface": "android",
@@ -4931,31 +4931,31 @@
49314931
},
49324932
{
49334933
"kind": "conditional-branch",
4934-
"line": 336,
4934+
"line": 342,
49354935
"path": "apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt",
49364936
"source": "Listening",
49374937
"surface": "android",
49384938
"id": "native.android.b4f67e96603515bd"
49394939
},
49404940
{
49414941
"kind": "conditional-branch",
4942-
"line": 336,
4942+
"line": 342,
49434943
"path": "apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt",
49444944
"source": "Ready",
49454945
"surface": "android",
49464946
"id": "native.android.b88e4278ead724ba"
49474947
},
49484948
{
49494949
"kind": "conditional-branch",
4950-
"line": 1623,
4950+
"line": 1629,
49514951
"path": "apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt",
49524952
"source": "Aborted",
49534953
"surface": "android",
49544954
"id": "native.android.13531fe081a45711"
49554955
},
49564956
{
49574957
"kind": "conditional-branch",
4958-
"line": 1623,
4958+
"line": 1629,
49594959
"path": "apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt",
49604960
"source": "Chat error",
49614961
"surface": "android",

apps/android/app/src/main/java/ai/openclaw/app/NodeRuntime.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ class NodeRuntime(
12481248
return@runTalkPttCommand GatewaySession.InvokeResult.ok(payload.toJson())
12491249
}
12501250
runPreparedTalkPttCommand {
1251-
val payload = talkMode.beginPushToTalk()
1251+
val payload = talkMode.beginPushToTalk(allowNewCapture = true)
12521252
GatewaySession.InvokeResult.ok(payload.toJson())
12531253
}
12541254
}

apps/android/app/src/main/java/ai/openclaw/app/voice/TalkModeManager.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,19 @@ class TalkModeManager internal constructor(
243243
}
244244

245245
/** Starts a push-to-talk capture session for gateway node.invoke callers. */
246-
suspend fun beginPushToTalk(allowNewCapture: Boolean = true): TalkPttStartPayload {
247-
if (!allowNewCapture && activePttCaptureId == null) {
248-
throw IllegalStateException("NODE_BACKGROUND_UNAVAILABLE: command requires foreground")
246+
suspend fun beginPushToTalk(allowNewCapture: Boolean): TalkPttStartPayload {
247+
if (!allowNewCapture) {
248+
// A background retry may reconcile an existing capture, but must never create one.
249+
return activePttCaptureId
250+
?.let(::TalkPttStartPayload)
251+
?: throw IllegalStateException("NODE_BACKGROUND_UNAVAILABLE: command requires foreground")
249252
}
250253
if (!isConnected()) {
251254
_statusText.value = "Gateway not connected"
252255
throw IllegalStateException("UNAVAILABLE: Gateway not connected")
253256
}
254257
// PTT begin is idempotent so gateway retries don't start multiple recognizers.
255258
activePttCaptureId?.let { return TalkPttStartPayload(captureId = it) }
256-
if (!allowNewCapture) {
257-
throw IllegalStateException("NODE_BACKGROUND_UNAVAILABLE: command requires foreground")
258-
}
259259

260260
stopSpeaking(resetInterrupt = false)
261261
pttTimeoutJob?.cancel()
@@ -359,7 +359,7 @@ class TalkModeManager internal constructor(
359359
)
360360
}
361361

362-
beginPushToTalk()
362+
beginPushToTalk(allowNewCapture = true)
363363
val completion = CompletableDeferred<TalkPttStopPayload>()
364364
pttCompletion = completion
365365
pttAutoStopEnabled = true

0 commit comments

Comments
 (0)