Commit 29dc05d
Cache package names and Fix stats update loop continuing every 10s when screen is off (#549)
* Fix stats update loop continuing every 10s when screen is off
The recent battery optimization (9f15d42) introduced a race condition:
when screen turns off, stopStats() removes pending MSG_STATS_UPDATE
messages and sets stats=false. However, if an already-delayed update
fires after stopStats(), updateStats() would reschedule itself every
10 seconds indefinitely since it never checked the stats flag.
This caused ~360 unnecessary handler wakeups per hour while screen off.
Fix: check the stats flag at the start of updateStats() and bail out
without rescheduling if stats have been stopped.
https://claude.ai/code/session_01XpUzMgtH7S4K72UX2DQ1cC
* Cache getPackagesForUid() result in shouldTrackApp() to avoid per-packet Binder IPC
shouldTrackApp() is called twice per packet (from blockKnownTracker
and from log) and each call made an uncached getPackagesForUid()
Binder IPC. Cache uid→packageName in a ConcurrentHashMap, invalidated
on package removal and cleared during 12-hour housekeeping.
https://claude.ai/code/session_01XpUzMgtH7S4K72UX2DQ1cC
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 13f66c3 commit 29dc05d
1 file changed
Lines changed: 25 additions & 14 deletions
Lines changed: 25 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
731 | 731 | | |
732 | 732 | | |
733 | 733 | | |
| 734 | + | |
734 | 735 | | |
735 | 736 | | |
736 | 737 | | |
| |||
1091 | 1092 | | |
1092 | 1093 | | |
1093 | 1094 | | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1094 | 1100 | | |
1095 | 1101 | | |
1096 | | - | |
1097 | 1102 | | |
1098 | 1103 | | |
1099 | 1104 | | |
| |||
2144 | 2149 | | |
2145 | 2150 | | |
2146 | 2151 | | |
| 2152 | + | |
2147 | 2153 | | |
2148 | 2154 | | |
2149 | 2155 | | |
| |||
2236 | 2242 | | |
2237 | 2243 | | |
2238 | 2244 | | |
2239 | | - | |
2240 | | - | |
2241 | | - | |
2242 | | - | |
2243 | | - | |
2244 | | - | |
2245 | | - | |
2246 | | - | |
2247 | | - | |
2248 | | - | |
2249 | | - | |
2250 | | - | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
2251 | 2262 | | |
2252 | | - | |
2253 | 2263 | | |
2254 | 2264 | | |
2255 | 2265 | | |
| |||
2686 | 2696 | | |
2687 | 2697 | | |
2688 | 2698 | | |
| 2699 | + | |
2689 | 2700 | | |
2690 | 2701 | | |
2691 | 2702 | | |
| |||
0 commit comments