RESTRICT AUTOMERGE Remove alarms from mPendingNonWakeupAlarms

While setting an alarm, we should remove any existing occurrences
of the same, but we were skipping on removing any past due non-wakeup
alarms.
In rare cases when a caller is spamming the alarm manager, we
might end up accumulating alarms inside mPendingNonWakeupAlarms that
count towards the per-uid limit of the caller, and may result in an
exception.

Test: atest FrameworksMockingServicesTests:AlarmManagerServiceTest
atest CtsAlarmManagerTestCases

Bug: 167595061
Change-Id: I2d2b08019a3b3a1e63b60d3a6e2909db7b1a1864
2 files changed