From 9ea558f09e1e88ec7e9aa441715959c5800cc69e Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 00:19:15 +0000 Subject: [PATCH] Calls: an Answer only while one rings; the call's alerts in the log Phantom incoming calls were reported with nothing in the log to say where they came from. The log now says when the app shows a call ringing in (and from what) and when it's gone, and when the call's notification opens the app. And an Answer (or answer as fax) intent Android hands back later, as when the app comes back from Recents, does nothing with no call ringing: it went off hook for no call. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0172Hejd12i4aYikYW9vgpZs --- .../java/com/neodesktop/dmodem/modem/ModemService.kt | 11 ++++++++++- .../java/com/neodesktop/dmodem/ui/MainActivity.kt | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt b/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt index 353977c..2287324 100644 --- a/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt +++ b/app/src/main/java/com/neodesktop/dmodem/modem/ModemService.kt @@ -358,7 +358,16 @@ class ModemService : Service() { ModemState.incoming.state .map { c -> c?.takeIf { !it.ignored }?.let { it.since to it.from } } .distinctUntilChanged() - .collect { callNotification(ModemState.incoming.state.value?.takeIf { !it.ignored }) } + .collect { + val c = ModemState.incoming.state.value + // (in the log: what the call's popup and notification came from) + if (c != null && !c.ignored) { + log("a call ringing in (the modem's RING): its notification and popup" + (c.from?.let { " ($it)" } ?: "")) + } else if (c == null) { + log("the incoming call's notification and popup gone") + } + callNotification(c?.takeIf { !it.ignored }) + } } } } diff --git a/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt b/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt index 049a22f..4e652bf 100644 --- a/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt +++ b/app/src/main/java/com/neodesktop/dmodem/ui/MainActivity.kt @@ -207,6 +207,17 @@ class MainActivity : ComponentActivity() { } else -> return } + val ringing = com.neodesktop.dmodem.modem.ModemState.incoming.state.value != null + val stale = !ringing || i.flags and android.content.Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY != 0 + com.neodesktop.dmodem.modem.ModemState.log.add( + "app: the call's notification: ${i.action?.substringAfterLast('.')}" + if (stale) " (no call ringing: nothing done)" else "", + ) + // (Android hands the intent that started the app back when it comes back from Recents: no answer + // then, with no call ringing) + if (stale) { + i.action = null + return + } when (i.action) { ACTION_ANSWER -> { com.neodesktop.dmodem.modem.ModemState.answer()