Skip to content

fix(mobile): forgetting an Apple Watch stops its microphone - #20810

Open
Itaxh1 wants to merge 1 commit into
BasedHardware:mainfrom
Itaxh1:fix/forget-watch-stops-recording
Open

Itaxh1 wants to merge 1 commit into
BasedHardware:mainfrom
Itaxh1:fix/forget-watch-stops-recording

Conversation

@Itaxh1

@Itaxh1 Itaxh1 commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: Forgetting an Apple Watch from device settings now also stops the Watch's microphone. The phone starts Watch recording when the Watch connects, but nothing on the phone ever told it to stop. So after Forget Device the Watch kept recording, and nothing consumed the audio. DeviceService.forgetDevice now sends the existing stopRecording call to an Apple Watch before tearing the connection down. Best effort; a plain disconnect is unchanged. Mobile only, no backend or Watch app change. Simulator before/after (real DeviceService, AppleWatchDeviceConnection and WatchTransport) below. Closes #20780.

What changed and why

AppleWatchDeviceConnection starts the Watch recorder (WatchTransport.startRecording) on connect, but WatchTransport.stopRecording had no callers. disconnect() and dispose() only cancel timers and close Dart streams.

  • DeviceService.forgetDevice now calls the new AppleWatchDeviceConnection.stopRecording() before _teardownConnection.
  • That method is best effort. The iOS host (RecorderHostApiImpl.stopRecording) sends the message when the Watch is reachable and queues it as application context when it is not, so it never blocks. An error is logged and the forget continues.
  • Only forget changes. disconnectDevice and the teardown that runs before a reconnect still leave Watch recording alone, so reconnects and source switches behave as before.

Closes #20780

Product invariants affected

none

How it was verified

  • flutter test test/unit/forget_watch_stops_recording_test.dart: 3 passed. Without the forgetDevice change, the first two fail (no stopRecording call reaches the Watch host).
  • flutter test test/unit/device_service_connections_test.dart test/services/devices/ test/widgets/device_page_forget_test.dart test/providers/device_provider*_test.dart plus the new file: 60 passed.
  • iOS Simulator (iPhone 16, iOS 18.0), dev flavor. An integration test drives the real DeviceService, AppleWatchDeviceConnection and WatchTransport. Only the WatchRecorderHostAPI pigeon channel is faked, and it counts start/stop calls. The test connects, starts recording, then calls forgetDevice. There is no Watch on the Simulator, so the evidence is the call log:
    • main (7d85fb5): startRecordingCalls=1 stopRecordingCalls=0 watchStillRecording=true connectionExists=false
    • this branch: startRecordingCalls=1 stopRecordingCalls=1 watchStillRecording=false connectionExists=false
  • scripts/pr-preflight --base upstream/main --lane local: passed.
  • make mobile-verify ARGS="fast --paths app/lib/services/devices.dart app/lib/services/devices/connectors/apple_watch_connection.dart": 23/23 hermetic journeys passed.

Tests

app/test/unit/forget_watch_stops_recording_test.dart:

Failure class (fixes)

Failure-Class: none

Review in cubic

The phone starts Watch recording when the Watch connects, but nothing on
the phone ever stopped it. Forget Device tore down the connection and
disposed the WatchTransport (timers and Dart streams only), so the Watch
kept recording after the phone said it was forgotten, and nothing
consumed that audio any more.

DeviceService.forgetDevice now asks an Apple Watch connection to stop
recording before tearing it down. The new
AppleWatchDeviceConnection.stopRecording is best effort: the iOS host
queues the stop for an unreachable Watch, and an error never blocks the
forget. A plain disconnect (reconnects, switching sources) is unchanged.

Fixes BasedHardware#20780
@Itaxh1
Itaxh1 requested a review from mdmohsin7 as a code owner October 6, 2026 09:18

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed file by file — this is a clean, well-scoped fix for #20780.

  • app/lib/services/devices.dart — forgetDevice now calls connection.stopRecording() before _teardownConnection, and only when the connection is an AppleWatchDeviceConnection. Correct placement: after clearStaleBondRecoveryRequirement(), before teardown, so the transport is still alive when the stop is sent.
  • app/lib/services/devices/connectors/apple_watch_connection.dart — the new best-effort stopRecording is a no-op for non-WatchTransport transports and catches every error, so a failed stop can never block or crash the forget. Consistent with the error handling style of the surrounding methods.
  • app/lib/services/devices/transports/watch_transport.dart (context) — the existing stopRecording rethrows, which is why the connector-level catch matters; verified the pigeon call mirrors startRecording exactly.
  • ios/Runner/RecorderHostApiImpl.swift (context) — the "queues the stop when the Watch is not reachable" claim checks out: sendMessage with an updateApplicationContext fallback, so an unreachable Watch still gets the stop on next contact.
  • app/test/unit/forget_watch_stops_recording_test.dart — good regression test: it mocks the real WatchRecorderHostAPI pigeon channels, drives the real DeviceService through its connectionBuilder seam, and covers the three behaviors that matter (stop on forget, forget still succeeds when stop errors, plain disconnect does NOT stop recording). Keeping disconnect semantics unchanged is the right call for reconnects and source switches.
  • app/changelog/unreleased/20261006-forget-watch-stops-mic.json — accurate, user-facing changelog entry.

One non-blocking nit: per repo convention (Definition of Done #7) fix: commits should declare a Failure-Class trailer — worth adding a line to the PR body if you get a chance, no rebase needed.

Thanks for the careful diagnosis and the test design — approving.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added flutter flutter work positive-signal Automation verified a genuine fix/quality contribution labels Oct 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forget Device on an Apple Watch does not stop the Watch microphone

2 participants