Commit 66a153d
authored
AlarmKit critical alarms: configured sound, backfill-proof, and visible authorization state (#2520)
* Play the configured alert sound on AlarmKit critical alarms
Builds without the Critical Alerts entitlement raise urgent glucose alarms
through AlarmKit on iOS 26, and the alarm was scheduled with no sound, so
it always played AlarmKit's default tone regardless of the sound chosen in
Loop. The notification path had been passing the configured sound all
along; it just isn't what makes the noise on those builds.
Pass the alert's sound by name. The bundled alarm sounds are IMA4 .caf
files under 30 seconds at the bundle root, which are the same constraints
a notification sound has, so AlarmKit can play them directly.
* Don't re-evaluate glucose alerts from a backfill older than the last reading
CGMs deliver the live reading and then backfill the gap behind it, each as
its own batch. evaluate() re-ran on the backfill, which carries a sample no
newer than the one just evaluated, and re-decided the alert from it. Seen
with the G7: a live reading raised an urgent low at 22:58:59 and the
backfill of the same period retracted it at 22:59:00, which also stopped
the in-process alarm audio one second after it started.
Skip any batch whose newest sample is not newer than the last evaluated
reading. Backfill still reaches the glucose store; it just cannot override
an alert decision made on a newer reading.
(cherry picked from commit 125a01b)
* Show AlarmKit authorization under iOS Permissions on builds without Critical Alerts
On builds without the Critical Alerts entitlement, AlarmKit is the audible
channel for urgent alarms, and whether the user has allowed alarms was not
visible anywhere: the permissions screen showed a "Critical Alerts: On" row
that the checker never populates on those builds, so it read On regardless.
A user who dismissed the authorization prompt had no way to see that their
urgent low would fire silently.
Report AlarmManager's authorization state through the permissions checker
as a new flag, show it as an "Alarms" row in place of the Critical Alerts
row where the entitlement is absent, and badge the iOS Permissions entry
when alarms are not allowed. The checker already re-checks on foreground,
so the row updates on return from Settings. Not added to
requiresRiskMitigation, so it does not raise the unsafe-permissions modal.
* Keep a Critical Alerts row on builds without the entitlement
Replacing the row with Alarms hid the fact that Critical Alerts are absent
altogether. Show it as "Not Available" beneath the Alarms row, with a link
to instructions for requesting the entitlement from Apple. The link is a
placeholder for a loopdocs page; the URL is a single constant to swap.
* Treat alarms turned off as an unsafe permission on builds without Critical Alerts
On those builds AlarmKit is how an urgent low makes a sound, so alarms being
off is as unsafe as Critical Alerts being off is elsewhere. Add it to the
risk-mitigation set so it raises the status banner and the unsafe-permissions
modal, with its own text and alert identifier. It takes precedence over the
notification flags in the mapping, since it only exists where the entitlement
is absent. The badge on the iOS Permissions entry now comes from showWarning
like the other flags.1 parent 455f756 commit 66a153d
4 files changed
Lines changed: 102 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| 113 | + | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| 117 | + | |
| 118 | + | |
113 | 119 | | |
114 | 120 | | |
115 | 121 | | |
| |||
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| 130 | + | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
| 143 | + | |
| 144 | + | |
135 | 145 | | |
136 | 146 | | |
137 | 147 | | |
| |||
143 | 153 | | |
144 | 154 | | |
145 | 155 | | |
| 156 | + | |
| 157 | + | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| |||
158 | 170 | | |
159 | 171 | | |
160 | 172 | | |
| 173 | + | |
| 174 | + | |
161 | 175 | | |
162 | 176 | | |
163 | 177 | | |
| |||
169 | 183 | | |
170 | 184 | | |
171 | 185 | | |
| 186 | + | |
| 187 | + | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
| |||
184 | 200 | | |
185 | 201 | | |
186 | 202 | | |
| 203 | + | |
| 204 | + | |
187 | 205 | | |
188 | 206 | | |
189 | 207 | | |
| |||
236 | 254 | | |
237 | 255 | | |
238 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
239 | 263 | | |
240 | 264 | | |
241 | 265 | | |
| |||
319 | 343 | | |
320 | 344 | | |
321 | 345 | | |
| 346 | + | |
322 | 347 | | |
323 | | - | |
| 348 | + | |
324 | 349 | | |
325 | 350 | | |
326 | 351 | | |
| |||
356 | 381 | | |
357 | 382 | | |
358 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
359 | 392 | | |
360 | 393 | | |
361 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
35 | 46 | | |
36 | 47 | | |
37 | 48 | | |
| |||
92 | 103 | | |
93 | 104 | | |
94 | 105 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
99 | 114 | | |
100 | 115 | | |
101 | 116 | | |
102 | | - | |
| 117 | + | |
| 118 | + | |
103 | 119 | | |
104 | 120 | | |
105 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
562 | 569 | | |
563 | 570 | | |
564 | 571 | | |
| |||
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
| |||
110 | 118 | | |
111 | 119 | | |
112 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
113 | 152 | | |
114 | 153 | | |
115 | 154 | | |
| |||
0 commit comments