wake-alarm/phone_app/android/app
Krzysztof kuhy Rudnicki 08b44b4ca2 Fix three defects the hardware run exposed in the room-proof path
All three were invisible to the emulator (no NFC, no step sensor) and to the
widget tests (which mock the platform channel), and each one on its own made
the alarm harder or impossible to dismiss.

1. AlarmActivity.onPause called NfcReader.stop(). enableReaderMode is
   per-activity but disableReaderMode is effectively global, so anything
   briefly coming in front of the ring screen killed NFC polling for the rest
   of the ring. Measured on the Pixel: `flags: 271` immediately followed by
   `flags: 0`. Teardown moves to onDestroy, and onResume re-asserts.

2. StepCounter could never report progress from a standing start.
   TYPE_STEP_COUNTER is an on-change *cumulative* sensor: it emits nothing
   until the user has already walked, and the first emission was being
   consumed as the baseline — so the ring screen sat at 0/25 no matter how far
   you walked. TYPE_STEP_DETECTOR is now primary (one event per stride, no
   baseline to miss); the counter stays as the fallback for devices without a
   detector.

3. NFC cannot be read while the ring shows over the lockscreen. Measured
   A/B on the Pixel with the same tag: registration while unlocked →
   mScreenState=ON_UNLOCKED, tag discovered; ring screen over the keyguard →
   mScreenState=ON_LOCKED, reader mode accepted (flags 271) but no discovery.
   Android gates NFC polling on lock state. showWhenLocked draws *over* the
   keyguard without unlocking, so the alarm now calls
   requestDismissKeyguard() on fire and re-asserts reader mode from the
   dismiss callback. User's call, taken explicitly: on a secured phone this
   surfaces the PIN prompt, which is an acceptable trade for an alarm you
   must get up for.

Without (3) the only satisfiable proof at 06:00 is steps, which is exactly
the single-mechanism dependency the room-proof redundancy exists to prevent.

flutter test: 69 pass. dart analyze lib/ test/: clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EckWmyfetYq3Mi8MAnUudh
2026-08-27 22:23:23 +02:00
..
src Fix three defects the hardware run exposed in the room-proof path 2026-08-27 22:23:23 +02:00
build.gradle.kts Phase 4 prereq: pin explicit min/target/compile SDK on the phone app 2026-08-27 21:09:56 +02:00