Adding Battery saver policy to alarms
Adding a separate policy to control whether alarms are eligible to go
off or not. This decouples battery saver and user applied background
restriction (a.k.a. forced-app-standby) logic, which have diverged due
to a lot of special exceptions in battery saver policy. This should make
it easier to maintain both in the future.
A side effect of this separation of logic is that any alarms that were
due before battery saver was turned on but were held back due to user FAS
will be delivered when the user turns off FAS, even when battery saver
is on.
This also has the benefit of deferring the relevant alarms
before setting the kernel timer so no redundant wakeups are incurred.
Also fixed a bug where adding an app to the power exemption list was not
unblocking restricted alarms for that app.
Test: atest CtsAlarmManagerTestCases
atest FrameworksMockingServicesTests:com.android.server.alarm
atest FrameworksMockingServicesTests:AppStateTrackerTest
Bug: 158795479
Bug: 170279979
Change-Id: Ic05e06c2576113a82d4f39ee61b86af63c23ac02
5 files changed