Skip to content

Commit 5e6cf5c

Browse files
committed
test(android): cover background talk capture shutdown
1 parent 12bd3c5 commit 5e6cf5c

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ class NodeRuntime(
13781378
refreshExecApprovalsFromGateway()
13791379
}
13801380
} else {
1381-
stopVoiceCaptureForBackground()
1381+
setVoiceCaptureMode(VoiceCaptureMode.Off)
13821382
publishNodePresenceAliveBeacon(NodePresenceAliveBeacon.Trigger.Background, throttleRecentSuccess = true)
13831383
}
13841384
}
@@ -1875,11 +1875,6 @@ class NodeRuntime(
18751875
setVoiceCaptureMode(VoiceCaptureMode.Off)
18761876
}
18771877

1878-
private fun stopVoiceCaptureForBackground() {
1879-
if (_voiceCaptureMode.value == VoiceCaptureMode.Off) return
1880-
setVoiceCaptureMode(VoiceCaptureMode.Off)
1881-
}
1882-
18831878
private fun stopActiveVoiceSession() {
18841879
talkMode.ttsOnAllResponses = false
18851880
talkMode.setEnabled(false)

apps/android/app/src/test/java/ai/openclaw/app/GatewayBootstrapAuthTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,24 @@ class GatewayBootstrapAuthTest {
666666
assertFalse(readField<MutableStateFlow<Boolean>>(runtime, "externalAudioCaptureActive").value)
667667
}
668668

669+
@Test
670+
fun backgroundingStopsActiveTalkModeCapture() {
671+
val app = RuntimeEnvironment.getApplication()
672+
shadowOf(app).grantPermissions(Manifest.permission.RECORD_AUDIO)
673+
val runtime = NodeRuntime(app)
674+
675+
runtime.setTalkModeEnabled(true)
676+
assertEquals(VoiceCaptureMode.TalkMode, runtime.voiceCaptureMode.value)
677+
678+
runtime.setForeground(false)
679+
680+
assertEquals(VoiceCaptureMode.Off, runtime.voiceCaptureMode.value)
681+
assertFalse(readField<MutableStateFlow<Boolean>>(runtime, "externalAudioCaptureActive").value)
682+
val talkMode = readField<Lazy<TalkModeManager>>(runtime, "talkMode\$delegate").value
683+
assertFalse(talkMode.ttsOnAllResponses)
684+
assertFalse(talkMode.isEnabled.value)
685+
}
686+
669687
private fun waitForGatewayTrustPrompt(runtime: NodeRuntime): NodeRuntime.GatewayTrustPrompt {
670688
repeat(50) {
671689
runtime.pendingGatewayTrust.value?.let { return it }

0 commit comments

Comments
 (0)