Skip to content

Commit 0909fce

Browse files
Suprabh Shuklaofficialputuid
authored andcommitted
Stop crashing the system on hitting the alarm limit
Exempting the system as a runtime restart is not clearly better than extreme memory and computation pressure that can result from the originating spam. Callers in the system should guard against any spammy requests that lead them to create a lot of alarms. Test: Builds, boots and existing tests should pass. atest CtsAlarmManagerTestCases:UidCapTests atest FrameworksMockingServicesTests:AlarmManagerServiceTest Bug: 234441463 Change-Id: Id5e94d44ac9ab24870a8213ec7583da0f592a5ff (cherry picked from commit 3b9f3f4) Merged-In: Id5e94d44ac9ab24870a8213ec7583da0f592a5ff (cherry picked from commit c010da3) (cherry picked from commit 909251a) Merged-In: Id5e94d44ac9ab24870a8213ec7583da0f592a5ff
1 parent 24f74b3 commit 0909fce

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

services/core/java/com/android/server/AlarmManagerService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
import android.text.format.DateUtils;
7676
import android.util.ArrayMap;
7777
import android.util.ArraySet;
78+
import android.util.EventLog;
7879
import android.util.KeyValueListParser;
7980
import android.util.Log;
8081
import android.util.LongArrayQueue;
@@ -1824,7 +1825,11 @@ void setImpl(int type, long triggerAtTime, long windowLength, long interval,
18241825
if (DEBUG_PER_UID_LIMIT && UserHandle.isCore(callingUid)) {
18251826
logAllAlarmsForUidLocked(callingUid);
18261827
}
1827-
throw new IllegalStateException(errorMsg);
1828+
if (callingUid != Process.SYSTEM_UID) {
1829+
throw new IllegalStateException(errorMsg);
1830+
} else {
1831+
EventLog.writeEvent(0x534e4554, "234441463", -1, errorMsg);
1832+
}
18281833
}
18291834
setImplLocked(type, triggerAtTime, triggerElapsed, windowLength, maxElapsed,
18301835
interval, operation, directReceiver, listenerTag, flags, true, workSource,

0 commit comments

Comments
 (0)