Hold wakeup alarms for as long as possible
If the screen is off, but the CPU is awake and epoll_wait returns for a
non-wakeup alarm, sending any wakeup alarm within its eligibility window
would cause all the held non-wakeup alarms to also fire, which could:
1. Elongate the length of the time the CPU is awake.
2. Cause apps to wake up and perform work.
This change defers sending any wakeup alarm as long as it is possible to
defer all such eligible alarms to later.
Also, fixed a bug in sorting after adding multiple alarms to the store.
Test: atest CtsAlarmManagerTestCases
atest FrameworksMockingServicesTests:com.android.server.alarm
Bug: 161497385
Change-Id: I01f98255091baddf4e7529f88733776e27d090d7
1 file changed