[verified] feat: follow phone Do Not Disturb for notification wake

This commit is contained in:
MasterControl committed 2026-11-11 17:43:35 +00:00
1 parent 54ba6b4f10
commit 9ca3574ae7
14 files changed
+574 -20

No files matched your search

+26
View File
@@ -84,6 +84,32 @@ test("reposts can bring a popup forward but never push it back", () => {
assert.deepEqual(ready, ["a", "b"], "the earlier timer was cancelled");
});
test("a notification retains its arrival-time no-wake policy through the popup delay", () => {
const clock = makeClock();
const ready = [];
const delay = new NotificationPopupDelay((key, canWakeScreen) => ready.push([key, canWakeScreen]), clock.schedule, clock.now);
delay.post("quiet", 500, false);
delay.post("normal", 500);
clock.advance(500);
assert.deepEqual(ready, [["quiet", false], ["normal", true]]);
});
test("a repost cannot re-enable wake after a DND arrival or discard a new DND restriction", () => {
for (const firstAllowed of [false, true]) {
for (const nextDelay of [500, 100]) {
const clock = makeClock();
const ready = [];
const delay = new NotificationPopupDelay((key, canWakeScreen) => ready.push([key, canWakeScreen]), clock.schedule, clock.now);
delay.post("message", 500, firstAllowed);
clock.advance(50);
delay.post("message", nextDelay, !firstAllowed);
clock.advance(1000);
assert.deepEqual(ready, [["message", false]], `firstAllowed=${firstAllowed}, nextDelay=${nextDelay}`);
assert.deepEqual(delay.pendingKeys(), []);
}
}
});
test("foreground-service notifications wait longer, unless urgent", () => {
assert.equal(notificationPopupDelayMs({ category: "msg" }), NOTIFICATION_POPUP_DELAY_MS);
assert.equal(notificationPopupDelayMs({ category: "", foregroundService: true }), FOREGROUND_SERVICE_POPUP_DELAY_MS);