Avoid lock inversion.
The PowerManager lock (which is used in the Battery Saver code) sits low in the lock hierarchy. NotificationManagerService is higher, so nothing should call into NotificationManagerService with the PowerManager lock held. This change calls into NMS on a background thread so that the call occurs without the PM lock held. Also fixing the cancel notification bug. We create the notifications using notifyAsUser(... UserHandle.ALL). The cancel() call wasn't properly dismissing the notification. Switching to cancelAsUser(UserHandle.ALL) fixes the issue. Bug: 145886051 Test: atest BatterySaverStateMachineTest Test: Manually ensure notification disappears when BS turns on Change-Id: I3315357e810d92938e4a34929235d233b07deebb
Loading
Please register or sign in to comment