From 867ff8da22f173402a679d42420600321198a8ee Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Thu, 27 Aug 2026 23:07:57 +0200 Subject: [PATCH] Qualify the DND claim: priority DND yes, total silence no MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Measured on the Pixel via the muted-stream mask in `dumpsys audio`: STREAM_ALARM is unmuted under priority DND (zen_mode=1, mask 0x1a6) and MUTED under total silence (zen_mode=2, mask 0x9be). The verified ring was priority DND, so "STREAM_ALARM ignores DND" was true but overstated — no audio flag escapes total silence, and the fix if that gap ever matters is a zen-policy check at arm time, not an audio change. Also records that raiseAlarmVolume() genuinely runs on this hardware (observed raising oldIndex:0 -> 7, no SecurityException), so it recovers a stream turned down to zero but not one muted by total silence. Two probe-harness traps kept: --build-number produces a non-running APK, and the arm probe can register for TOMORROW because main.dart's rearm() recomputes nextOccurrence after the armed minute has passed. Folded in from scratch notes left mid-session (.dnd-findings/, TODO-verify-dnd-ring.md), both now deleted — the verification they asked for has since been done. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01EckWmyfetYq3Mi8MAnUudh --- DOCS-phone-alarm.md | 24 +++++++++++++++++++----- TODO-hardening-continue.md | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/DOCS-phone-alarm.md b/DOCS-phone-alarm.md index 44bb005..04bdeca 100644 --- a/DOCS-phone-alarm.md +++ b/DOCS-phone-alarm.md @@ -23,10 +23,25 @@ scanning) — never for the ring path. Things that are a hard crash or a silent no-ring, not a warning: -- **`STREAM_ALARM` is load-bearing.** `AlarmService` sets - `AudioAttributes.USAGE_ALARM`, which is what ignores DND and silent mode. - Never `USAGE_MEDIA`/`STREAM_MUSIC` — it would be muted exactly when the - alarm matters most. +- **`STREAM_ALARM` is load-bearing — but it does not beat *every* DND mode.** + `AlarmService` sets `AudioAttributes.USAGE_ALARM`; never + `USAGE_MEDIA`/`STREAM_MUSIC`, which would be muted exactly when the alarm + matters most. Measured on the Pixel 6a (2026-08-27), the muted-stream mask + from `dumpsys audio` differs by zen mode: + + | DND mode | `zen_mode` | `STREAM_ALARM` | + |---|---|---| + | priority (`ZEN_MODE_IMPORTANT_INTERRUPTIONS`) | 1 | **not muted** (mask `0x1a6`) | + | total silence (`ZEN_MODE_NO_INTERRUPTIONS`) | 2 | **MUTED** (mask `0x9be`) | + + The confirmed ring was under **priority DND** (`zen_mode=1`): player + `state:started`, `usage=USAGE_ALARM` → `STREAM_ALARM(4)`, `mutedState:none`. + **Total silence mutes the alarm stream system-wide**, and no audio flag + escapes it — so "ignores DND" means priority DND, not total silence. If that + gap ever matters, the fix is a zen-policy check at arm time, not an audio + change. `raiseAlarmVolume()` does run on this hardware (observed raising + `oldIndex:0` → 7, no `SecurityException`), which recovers a stream turned + down to zero but not one muted by total silence. - **`android:foregroundServiceType="mediaPlayback"` must be on the `` in the manifest AND passed to `startForeground()`.** Omitting either is a hard crash the moment the alarm fires on API 34+ — and it is invisible on an @@ -89,4 +104,3 @@ cannot finish an activity). Without it the dismiss screen stays up over the lockscreen forever — back is disabled by design in both halves — and the live instance would carry a satisfied room proof and the solved answer into the next ring. - diff --git a/TODO-hardening-continue.md b/TODO-hardening-continue.md index f1aead5..2ad8fce 100644 --- a/TODO-hardening-continue.md +++ b/TODO-hardening-continue.md @@ -99,6 +99,23 @@ The alarm is no longer opt-in and can no longer be weakened: later than 08:00 whatever its source, so a stale or tampered remote value cannot move the alarm later through sync. +### DND: verified for priority mode, NOT for total silence + +Measured on the Pixel: `STREAM_ALARM` is unmuted under **priority** DND +(`zen_mode=1`, mask `0x1a6`) and **muted** under **total silence** +(`zen_mode=2`, mask `0x9be`). The confirmed ring was priority DND. No audio +flag escapes total silence, so if that gap matters the fix is a zen-policy +check at arm time, not an audio change. Detail in `DOCS-phone-alarm.md`. + +Two harness traps found while testing this, worth keeping: + +- **Do not pass `--build-number` to a probe build** — it produced a + non-running APK. +- **The arm probe can register for TOMORROW.** It calls `schedule()`, then + `main.dart`'s `rearm()` recomputes `nextOccurrence`; if the armed minute has + passed by then the alarm lands on the next day. Always re-check the + registered `triggerTime` is today before waiting for a ring. + ### Still unverified - The **QR** proof has no scanner UI (`mobile_scanner`); `checkQr` and its