← Back to Pull requests

Voice: the listen between replies uses the call microphone on the speaker (bugfix, fixes #408) #465

Closed
unknown closed this pull request without merging on Nov 20, 2026 21:46 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 19:13 UTC
Author

What and why

On the phone's own speaker, a chained voice chat with talk-over on runs as call audio (#369, for the echo cancelling that #264 needed). But the listen between replies still opened a speech-recognition (VOICE_RECOGNITION) stream. In the reporter's logcat, the speakerphone route handed that stream the back microphone (AUDIO_DEVICE_IN_BACK_MIC), which heard next to nothing, so the recording ran until the 12 s idle wait ended it. Only the stream after that, opened once the system had dropped call mode, landed on the bottom mic. That is the 8–12 s of "Listening" that ignores speech.

  • AndroidVoiceRecorder.record() opens the same call microphone the reply is listened over with (VOICE_COMMUNICATION, echo cancelling and noise suppression), but only while call routing is held. Outside it (headphones, Bluetooth, talk-over off, dictation without a chat) it stays VOICE_RECOGNITION with noise suppression only, as before. The reporter's logs show the call microphone hears them on that phone, since cutting in over the reply works.

  • ChatAudioRoute is a small shared hook (one Koin single). AndroidSpeechPlayer sets it, and the recorder asks it before each listen.

  • The system resets the mode to normal after a few seconds without call audio, which is what the logcat shows between a reply and the next listen. reroute() now notices this before each listen and each reply and takes call mode up again. If the speaker can no longer be the call device, it lets the routing go, so the app no longer believes it still holds call routing.

  • Echo cancelling over the reply (#264) is unchanged. The 12 s idle wait is unchanged too: without a device to test on, there's nothing to tune it against.
  • I didn't add a preferred device (setPreferredDevice on the bottom mic). It could switch off Samsung's dual-mic call processing, and the plain call microphone already works for talk-over on the reporter's phone. If the call microphone still misses speech on some phone, pinning is the next step.

    Fixes #408

    How I tested it

  • Tests added (Robolectric, shared/ui/src/androidHostTest):

  • - AndroidVoiceRecorderTest.recordUsesTheCallMicrophoneOnlyWhileCallRoutingIsHeld
    - AndroidChainedAudioTest.aModeTheSystemResetIsTakenUpAgainForTheNextListen
    - AndroidChainedAudioTest.aResetRouteThatWontTakeAgainIsLetGo
    - AndroidChainedAudioTest.noCallAudioWithoutCallRouting

    The first three fail with the source switch and the re-check taken out.
    - Added in review, each failing without its fix: AndroidChainedAudioTest.aPhoneCallsModeIsLeftAlone, AndroidChainedAudioTest.aRouteThatDidntTakeIsntTriedAgainEachTurn, AndroidVoiceRecorderTest.listenOverTakesCallModeUpAgainFirst

  • Ran the command under "Tests" in CONTRIBUTING.md plus :desktopApp:compileKotlinJvm: BUILD SUCCESSFUL.

  • On an Android 17 emulator (Dev build, test gateway, dumpsys audio): five listens in a row opened VOICE_COMMUNICATION with MODE_IN_COMMUNICATION held on the speaker, and MODE_NORMAL came back on leaving the chat.

  • On a phone: not tested. I don't have a Samsung phone, and the emulator's audio policy has no back mic, so the back-mic routing itself was not reproduced. The cause comes from the reporter's logcat. The reporter offered on the issue to test a build with adb attached and to report getInputForAttr / selectedDeviceId for each recorder. That is the check this needs before release.
  • Checklist

  • One feature or fix, and its ROADMAP item is ticked (the talk-over line under Voice)

  • Up to date with master, and the command under "Tests" in CONTRIBUTING.md passes

  • A late answer after a profile, gateway or chat switch is dropped; reconnect, rotation and a second tap work (no change there)

  • Anything cached or stored is keyed by gateway and profile (nothing stored)

  • No tokens in URLs, and no fetches of an address on the user's own network that a reply or page links to

  • The desktop app builds (./gradlew :desktopApp:compileKotlinJvm)
  • Reviewed with a feedback loop: 2 rounds with Gemini 4 Neon (gemini-4-neon-high). Verdict: approved.

    Diff: 516 lines (+387 / -129) across 6 files Reviewer: Giton22 Review duration: 152m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 516 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #465"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.8% · Safe to merge
    18.8%