From 1e38382b542f5cef9957a89692b02c55a3dd351c Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 10 Apr 2015 14:02:33 -0700 Subject: Fixes to idle alarm scheduling, package importance. - Add new API to ask the activity manager what the current importance of a particular package name is (along with a few new useful importance levels). - Fix my last alarm manager change to actually execute the alarms we have now decided should run even while we are idle. Change-Id: I1f14712b4e390770d53b185c96a1b36f6aadd687 --- .../com/android/server/AlarmManagerService.java | 43 +++++++++++++--------- 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'services/core/java/com/android/server/AlarmManagerService.java') diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java index 34e8b78..9f80fd8 100644 --- a/services/core/java/com/android/server/AlarmManagerService.java +++ b/services/core/java/com/android/server/AlarmManagerService.java @@ -99,6 +99,7 @@ class AlarmManagerService extends SystemService { static final boolean DEBUG_BATCH = localLOGV || false; static final boolean DEBUG_VALIDATE = localLOGV || false; static final boolean DEBUG_ALARM_CLOCK = localLOGV || false; + static final boolean RECORD_ALARMS_IN_HISTORY = true; static final int ALARM_EVENT = 1; static final String TIMEZONE_PROPERTY = "persist.sys.timezone"; @@ -1345,15 +1346,6 @@ class AlarmManagerService extends SystemService { } void rescheduleKernelAlarmsLocked() { - if (mPendingIdleUntil != null) { - // If we have a pending "idle until" alarm, we will just blindly wait until - // it is time for that alarm to go off. We don't want to wake up for any - // other reasons. - mNextWakeup = mNextNonWakeup = mPendingIdleUntil.whenElapsed; - setLocked(ELAPSED_REALTIME_WAKEUP, mNextWakeup); - setLocked(ELAPSED_REALTIME, mNextNonWakeup); - return; - } // Schedule the next upcoming wakeup alarm. If there is a deliverable batch // prior to that which contains no wakeups, we schedule that as well. long nextNonWakeup = 0; @@ -1574,13 +1566,6 @@ class AlarmManagerService extends SystemService { boolean triggerAlarmsLocked(ArrayList triggerList, final long nowELAPSED, final long nowRTC) { boolean hasWakeup = false; - if (mPendingIdleUntil != null) { - // If we have a pending "idle until" alarm, don't trigger any alarms - // until we are past the idle period. - if (nowELAPSED < mPendingIdleUntil.whenElapsed) { - return false; - } - } // batches are temporally sorted, so we need only pull from the // start of the list until we either empty it or hit a batch // that is not yet deliverable @@ -1816,6 +1801,17 @@ class AlarmManagerService extends SystemService { if (localLOGV) { Slog.v(TAG, "sending alarm " + alarm); } + if (RECORD_ALARMS_IN_HISTORY) { + if (alarm.workSource != null && alarm.workSource.size() > 0) { + for (int wi=0; wi 0) { + for (int wi=0; wi