Commit f291f69
committed
FullCharge: Arm the reconnect gesture at the limit without waiting for the battery status
The gesture armed only when the charging-policy hardware state, a
non-CHARGING battery status and an in-band percent held at once. After
any write of the limit the phone is physically topping back up, so the
battery status stays CHARGING for the ~10-12s Pixel HAL transition and
nothing armed. An unplug in that window opened no reconnect window and
the replug had nothing to consume, so a gesture right after "Restore
now" silently did nothing. Every path that writes the limit while
already in the band was affected - session restore, boot recovery, the
widget's persistent-policy buttons - not just restore.
Arming now also accepts a second path: the policy state is reported and
the battery has already reached a *verified* limit percent. Reaching the
limit replaces the dropped battery status as the signal that separates
sitting at the limit from climbing through the band, so a replug at 76%
under an 80% limit still arms nothing. The percent is sourced from
GestureBasis.limitPercent(), which answers only from a verified
readback; GestureBasis.evidence() is deliberately not used, as its
journal fallback would arm the default basis off a limit Amply merely
remembers writing.
Accepting a CHARGING reading needs a counterweight, because the hardware
state lags a policy change in both directions: leaving an 80% limit at
80% briefly still reports the old policy state, which would latch a hold
that no longer exists and survive - the steady-plugged branch has never
dropped a latch - until the battery left the band. That branch now
retires a limit-hold basis on positive proof the limit is not holding:
current flowing while no policy state is reported, from a readable
broadcast. It is confined to the steady-plugged branch because a replug
legitimately reads CHARGING before the policy state is re-reported, and
dropping there would destroy the carried basis the reconnect window
exists to preserve.
Verified on a Pixel 9 Pro: re-arming after a restore went from ~10.5s to
108ms, and the full replay (gesture, Restore now, gesture again within
the window) starts a second session where it previously did nothing. The
climbing case (76% under an 80% limit) stays idle.1 parent 9d34285 commit f291f69
4 files changed
Lines changed: 203 additions & 13 deletions
File tree
- app/src
- main/java/eu/darken/amply/fullcharge/core
- test/java/eu/darken/amply/fullcharge/core
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
381 | 385 | | |
382 | 386 | | |
383 | 387 | | |
| |||
387 | 391 | | |
388 | 392 | | |
389 | 393 | | |
| 394 | + | |
390 | 395 | | |
391 | 396 | | |
392 | 397 | | |
| |||
438 | 443 | | |
439 | 444 | | |
440 | 445 | | |
441 | | - | |
| 446 | + | |
442 | 447 | | |
443 | 448 | | |
444 | 449 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
Lines changed: 58 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
35 | 50 | | |
36 | 51 | | |
37 | 52 | | |
| |||
84 | 99 | | |
85 | 100 | | |
86 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
87 | 108 | | |
88 | 109 | | |
89 | 110 | | |
| |||
111 | 132 | | |
112 | 133 | | |
113 | 134 | | |
114 | | - | |
115 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
116 | 140 | | |
117 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
118 | 150 | | |
119 | 151 | | |
120 | 152 | | |
| |||
154 | 186 | | |
155 | 187 | | |
156 | 188 | | |
157 | | - | |
| 189 | + | |
158 | 190 | | |
159 | 191 | | |
160 | 192 | | |
| |||
186 | 218 | | |
187 | 219 | | |
188 | 220 | | |
189 | | - | |
| 221 | + | |
190 | 222 | | |
191 | 223 | | |
192 | 224 | | |
193 | 225 | | |
194 | | - | |
| 226 | + | |
195 | 227 | | |
196 | 228 | | |
197 | 229 | | |
198 | 230 | | |
199 | 231 | | |
200 | 232 | | |
201 | | - | |
| 233 | + | |
202 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
203 | 250 | | |
204 | 251 | | |
205 | 252 | | |
| |||
215 | 262 | | |
216 | 263 | | |
217 | 264 | | |
218 | | - | |
219 | | - | |
| 265 | + | |
| 266 | + | |
220 | 267 | | |
221 | 268 | | |
222 | 269 | | |
| |||
Lines changed: 134 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 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 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
56 | 171 | | |
57 | 172 | | |
58 | 173 | | |
| |||
670 | 785 | | |
671 | 786 | | |
672 | 787 | | |
| 788 | + | |
673 | 789 | | |
674 | 790 | | |
675 | 791 | | |
| |||
678 | 794 | | |
679 | 795 | | |
680 | 796 | | |
| 797 | + | |
681 | 798 | | |
682 | 799 | | |
683 | 800 | | |
| |||
688 | 805 | | |
689 | 806 | | |
690 | 807 | | |
| 808 | + | |
691 | 809 | | |
692 | | - | |
| 810 | + | |
693 | 811 | | |
694 | 812 | | |
| 813 | + | |
695 | 814 | | |
696 | 815 | | |
697 | 816 | | |
698 | 817 | | |
699 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
700 | 833 | | |
701 | 834 | | |
702 | 835 | | |
| |||
0 commit comments