Preserve stream notifications and synchronize host checks with audio cleanup

This commit is contained in:
evgeny committed 2026-10-29 13:34:23 +01:00
1 parent 0d9dabcd23
commit a90416f50c
3 files changed
+11 -7

No files matched your search

@@ -235,11 +235,11 @@ class RadioCallLifecycleTest {
@Test fun outcomeNotificationPreservesForegroundServiceAndPhoneOutcomeNotifications() {
val manager = requireNotNull(context.notificationManager)
val overlay = Notification(); val phone = Notification()
manager.active[1002] = overlay; manager.active[1003] = phone
val call = Notification(); val phone = Notification(); val stream = Notification()
manager.active[1002] = call; manager.active[1003] = phone; manager.active[1004] = stream
val id = outgoing(); emit(id, 4, 2, false)
assertSame(overlay, manager.active[1002]); assertSame(phone, manager.active[1003])
assertTrue(manager.active.containsKey(1004))
assertSame(call, manager.active[1002]); assertSame(phone, manager.active[1003]); assertSame(stream, manager.active[1004])
assertTrue(manager.active.containsKey(1006))
}
@Test fun outcomePresentationFailuresCannotStrandTheEndedState() {
@@ -86,8 +86,9 @@ class RadioOverlayLifecycleTest {
if (it.foregroundId != 0 && it.stops == 0) { drain(); radio.onSettingsApplied(NativeLib.radioRequest, true); drain() }
}
private fun show(): RadioOverlayService = create().also { it.onStartCommand(null, 0, 1); dispatcher.scheduler.runCurrent() }
private fun diagnostic(fragment: String) = assertTrue("Missing diagnostic: $fragment",
LogManager.entries.any { fragment in it.message && it.level in listOf("ERROR", "WARN") })
private fun diagnostic(fragment: String) = synchronized(LogManager.entries) {
assertTrue("Missing diagnostic: $fragment", LogManager.entries.any { fragment in it.message && it.level in listOf("ERROR", "WARN") })
}
private fun touch(action: Int, time: Long = 100, down: Long = time, x: Float = 0f, target: View = view): Boolean {
val handled = target.touch(MotionEvent(action, rawX = x, eventTime = time, downTime = down))
drain()
@@ -178,7 +178,10 @@ class RadioWorkerLifecycleTest {
NativeLib.radioFailures = setOf(failure)
assertTrue(engine.talkBegin()); drain()
await("capture startup diagnostic $failure") { diagnostic("capture startup failed") }
captureEnded(); assertTrue(AndroidMicrophoneCapture.opened.all { it.closed })
captureEnded()
val mediaIo = MediaAudioSession::class.java.getDeclaredField("io").apply { isAccessible = true }
.get(MediaAudioController) as ExecutorService
assertTrue(mediaIo.submit<Boolean> { AndroidMicrophoneCapture.opened.all { it.closed } }.get(5, TimeUnit.SECONDS))
NativeLib.radioFailures = emptySet(); engine.cancelTalk()
}
}