Loading core/java/android/app/AlarmManager.java +7 −15 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.RemoteException; import android.os.WorkSource; /** * This class provides access to the system alarm services. These allow you Loading Loading @@ -156,7 +155,7 @@ public class AlarmManager * @see #RTC_WAKEUP */ public void set(int type, long triggerAtMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, legacyExactLength(), 0, operation, null); setImpl(type, triggerAtMillis, legacyExactLength(), 0, operation); } /** Loading Loading @@ -210,7 +209,7 @@ public class AlarmManager */ public void setRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, legacyExactLength(), intervalMillis, operation, null); setImpl(type, triggerAtMillis, legacyExactLength(), intervalMillis, operation); } /** Loading Loading @@ -245,7 +244,7 @@ public class AlarmManager */ public void setWindow(int type, long windowStartMillis, long windowLengthMillis, PendingIntent operation) { setImpl(type, windowStartMillis, windowLengthMillis, 0, operation, null); setImpl(type, windowStartMillis, windowLengthMillis, 0, operation); } /** Loading @@ -253,20 +252,13 @@ public class AlarmManager * to the precise time specified. */ public void setExact(int type, long triggerAtMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, WINDOW_EXACT, 0, operation, null); } /** @hide */ public void set(int type, long triggerAtMillis, long windowMillis, long intervalMillis, PendingIntent operation, WorkSource workSource) { setImpl(type, triggerAtMillis, windowMillis, intervalMillis, operation, workSource); setImpl(type, triggerAtMillis, WINDOW_EXACT, 0, operation); } private void setImpl(int type, long triggerAtMillis, long windowMillis, long intervalMillis, PendingIntent operation, WorkSource workSource) { PendingIntent operation) { try { mService.set(type, triggerAtMillis, windowMillis, intervalMillis, operation, workSource); mService.set(type, triggerAtMillis, windowMillis, intervalMillis, operation); } catch (RemoteException ex) { } } Loading Loading @@ -359,7 +351,7 @@ public class AlarmManager @Deprecated public void setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, WINDOW_HEURISTIC, intervalMillis, operation, null); setImpl(type, triggerAtMillis, WINDOW_HEURISTIC, intervalMillis, operation); } /** Loading core/java/android/app/IAlarmManager.aidl +1 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.app; import android.app.PendingIntent; import android.os.WorkSource; /** * System private API for talking with the alarm manager service. Loading @@ -27,7 +26,7 @@ import android.os.WorkSource; interface IAlarmManager { /** windowLength == 0 means exact; windowLength < 0 means the let the OS decide */ void set(int type, long triggerAtTime, long windowLength, long interval, in PendingIntent operation, in WorkSource workSource); long interval, in PendingIntent operation); void setTime(long millis); void setTimeZone(String zone); void remove(in PendingIntent operation); Loading services/java/com/android/server/AlarmManagerService.java +18 −41 Original line number Diff line number Diff line Loading @@ -385,13 +385,13 @@ class AlarmManagerService extends IAlarmManager.Stub { if (batch.standalone) { // this will also be the only alarm in the batch a = new Alarm(a.type, a.when, whenElapsed, maxElapsed, a.repeatInterval, a.operation, a.workSource); a.repeatInterval, a.operation); Batch newBatch = new Batch(a); newBatch.standalone = true; addBatchLocked(mAlarmBatches, newBatch); } else { setImplLocked(a.type, a.when, whenElapsed, maxElapsed, a.repeatInterval, a.operation, false, a.workSource); a.repeatInterval, a.operation, false); } } } Loading @@ -400,14 +400,12 @@ class AlarmManagerService extends IAlarmManager.Stub { private static final class InFlight extends Intent { final PendingIntent mPendingIntent; final WorkSource mWorkSource; final Pair<String, ComponentName> mTarget; final BroadcastStats mBroadcastStats; final FilterStats mFilterStats; InFlight(AlarmManagerService service, PendingIntent pendingIntent, WorkSource workSource) { InFlight(AlarmManagerService service, PendingIntent pendingIntent) { mPendingIntent = pendingIntent; mWorkSource = workSource; Intent intent = pendingIntent.getIntent(); mTarget = intent != null ? new Pair<String, ComponentName>(intent.getAction(), intent.getComponent()) Loading Loading @@ -504,17 +502,12 @@ class AlarmManagerService extends IAlarmManager.Stub { @Override public void set(int type, long triggerAtTime, long windowLength, long interval, PendingIntent operation, WorkSource workSource) { if (workSource != null) { mContext.enforceCallingPermission( android.Manifest.permission.UPDATE_DEVICE_STATS, "AlarmManager.set"); } set(type, triggerAtTime, windowLength, interval, operation, false, workSource); PendingIntent operation) { set(type, triggerAtTime, windowLength, interval, operation, false); } public void set(int type, long triggerAtTime, long windowLength, long interval, PendingIntent operation, boolean isStandalone, WorkSource workSource) { PendingIntent operation, boolean isStandalone) { if (operation == null) { Slog.w(TAG, "set/setRepeating ignored because there is no intent"); return; Loading Loading @@ -551,13 +544,13 @@ class AlarmManagerService extends IAlarmManager.Stub { + " interval=" + interval + " standalone=" + isStandalone); } setImplLocked(type, triggerAtTime, triggerElapsed, maxElapsed, interval, operation, isStandalone, workSource); interval, operation, isStandalone); } } private void setImplLocked(int type, long when, long whenElapsed, long maxWhen, long interval, PendingIntent operation, boolean isStandalone, WorkSource workSource) { Alarm a = new Alarm(type, when, whenElapsed, maxWhen, interval, operation, workSource); PendingIntent operation, boolean isStandalone) { Alarm a = new Alarm(type, when, whenElapsed, maxWhen, interval, operation); removeLocked(operation); final boolean reschedule; Loading Loading @@ -969,8 +962,7 @@ class AlarmManagerService extends IAlarmManager.Stub { final long nextElapsed = alarm.whenElapsed + delta; setImplLocked(alarm.type, alarm.when + delta, nextElapsed, maxTriggerTime(nowELAPSED, nextElapsed, alarm.repeatInterval), alarm.repeatInterval, alarm.operation, batch.standalone, alarm.workSource); alarm.repeatInterval, alarm.operation, batch.standalone); } } Loading Loading @@ -1002,17 +994,15 @@ class AlarmManagerService extends IAlarmManager.Stub { public long maxWhen; // also in the elapsed time base public long repeatInterval; public PendingIntent operation; public WorkSource workSource; public Alarm(int _type, long _when, long _whenElapsed, long _maxWhen, long _interval, PendingIntent _op, WorkSource _ws) { long _interval, PendingIntent _op) { type = _type; when = _when; whenElapsed = _whenElapsed; maxWhen = _maxWhen; repeatInterval = _interval; operation = _op; workSource = _ws; } @Override Loading Loading @@ -1126,11 +1116,11 @@ class AlarmManagerService extends IAlarmManager.Stub { // we have an active broadcast so stay awake. if (mBroadcastRefCount == 0) { setWakelockWorkSource(alarm.operation, alarm.workSource); setWakelockWorkSource(alarm.operation); mWakeLock.acquire(); } final InFlight inflight = new InFlight(AlarmManagerService.this, alarm.operation, alarm.workSource); alarm.operation); mInFlight.add(inflight); mBroadcastRefCount++; Loading Loading @@ -1172,18 +1162,8 @@ class AlarmManagerService extends IAlarmManager.Stub { } } /** * Attribute blame for a WakeLock. * @param pi PendingIntent to attribute blame to if ws is null. * @param ws WorkSource to attribute blame. */ void setWakelockWorkSource(PendingIntent pi, WorkSource ws) { void setWakelockWorkSource(PendingIntent pi) { try { if (ws != null) { mWakeLock.setWorkSource(ws); return; } final int uid = ActivityManagerNative.getDefault() .getUidForIntentSender(pi.getTarget()); if (uid >= 0) { Loading Loading @@ -1266,9 +1246,8 @@ class AlarmManagerService extends IAlarmManager.Stub { // the top of the next minute. final long tickEventDelay = nextTime - currentTime; final WorkSource workSource = null; // Let system take blame for time tick events. set(ELAPSED_REALTIME, SystemClock.elapsedRealtime() + tickEventDelay, 0, 0, mTimeTickSender, true, workSource); 0, mTimeTickSender, true); } public void scheduleDateChangedEvent() { Loading @@ -1280,8 +1259,7 @@ class AlarmManagerService extends IAlarmManager.Stub { calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, 1); final WorkSource workSource = null; // Let system take blame for date change events. set(RTC, calendar.getTimeInMillis(), 0, 0, mDateChangeSender, true, workSource); set(RTC, calendar.getTimeInMillis(), 0, 0, mDateChangeSender, true); } } Loading Loading @@ -1397,8 +1375,7 @@ class AlarmManagerService extends IAlarmManager.Stub { } else { // the next of our alarms is now in flight. reattribute the wakelock. if (mInFlight.size() > 0) { InFlight inFlight = mInFlight.get(0); setWakelockWorkSource(inFlight.mPendingIntent, inFlight.mWorkSource); setWakelockWorkSource(mInFlight.get(0).mPendingIntent); } else { // should never happen mLog.w("Alarm wakelock still held but sent queue empty"); Loading Loading
core/java/android/app/AlarmManager.java +7 −15 Original line number Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.RemoteException; import android.os.WorkSource; /** * This class provides access to the system alarm services. These allow you Loading Loading @@ -156,7 +155,7 @@ public class AlarmManager * @see #RTC_WAKEUP */ public void set(int type, long triggerAtMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, legacyExactLength(), 0, operation, null); setImpl(type, triggerAtMillis, legacyExactLength(), 0, operation); } /** Loading Loading @@ -210,7 +209,7 @@ public class AlarmManager */ public void setRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, legacyExactLength(), intervalMillis, operation, null); setImpl(type, triggerAtMillis, legacyExactLength(), intervalMillis, operation); } /** Loading Loading @@ -245,7 +244,7 @@ public class AlarmManager */ public void setWindow(int type, long windowStartMillis, long windowLengthMillis, PendingIntent operation) { setImpl(type, windowStartMillis, windowLengthMillis, 0, operation, null); setImpl(type, windowStartMillis, windowLengthMillis, 0, operation); } /** Loading @@ -253,20 +252,13 @@ public class AlarmManager * to the precise time specified. */ public void setExact(int type, long triggerAtMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, WINDOW_EXACT, 0, operation, null); } /** @hide */ public void set(int type, long triggerAtMillis, long windowMillis, long intervalMillis, PendingIntent operation, WorkSource workSource) { setImpl(type, triggerAtMillis, windowMillis, intervalMillis, operation, workSource); setImpl(type, triggerAtMillis, WINDOW_EXACT, 0, operation); } private void setImpl(int type, long triggerAtMillis, long windowMillis, long intervalMillis, PendingIntent operation, WorkSource workSource) { PendingIntent operation) { try { mService.set(type, triggerAtMillis, windowMillis, intervalMillis, operation, workSource); mService.set(type, triggerAtMillis, windowMillis, intervalMillis, operation); } catch (RemoteException ex) { } } Loading Loading @@ -359,7 +351,7 @@ public class AlarmManager @Deprecated public void setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation) { setImpl(type, triggerAtMillis, WINDOW_HEURISTIC, intervalMillis, operation, null); setImpl(type, triggerAtMillis, WINDOW_HEURISTIC, intervalMillis, operation); } /** Loading
core/java/android/app/IAlarmManager.aidl +1 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.app; import android.app.PendingIntent; import android.os.WorkSource; /** * System private API for talking with the alarm manager service. Loading @@ -27,7 +26,7 @@ import android.os.WorkSource; interface IAlarmManager { /** windowLength == 0 means exact; windowLength < 0 means the let the OS decide */ void set(int type, long triggerAtTime, long windowLength, long interval, in PendingIntent operation, in WorkSource workSource); long interval, in PendingIntent operation); void setTime(long millis); void setTimeZone(String zone); void remove(in PendingIntent operation); Loading
services/java/com/android/server/AlarmManagerService.java +18 −41 Original line number Diff line number Diff line Loading @@ -385,13 +385,13 @@ class AlarmManagerService extends IAlarmManager.Stub { if (batch.standalone) { // this will also be the only alarm in the batch a = new Alarm(a.type, a.when, whenElapsed, maxElapsed, a.repeatInterval, a.operation, a.workSource); a.repeatInterval, a.operation); Batch newBatch = new Batch(a); newBatch.standalone = true; addBatchLocked(mAlarmBatches, newBatch); } else { setImplLocked(a.type, a.when, whenElapsed, maxElapsed, a.repeatInterval, a.operation, false, a.workSource); a.repeatInterval, a.operation, false); } } } Loading @@ -400,14 +400,12 @@ class AlarmManagerService extends IAlarmManager.Stub { private static final class InFlight extends Intent { final PendingIntent mPendingIntent; final WorkSource mWorkSource; final Pair<String, ComponentName> mTarget; final BroadcastStats mBroadcastStats; final FilterStats mFilterStats; InFlight(AlarmManagerService service, PendingIntent pendingIntent, WorkSource workSource) { InFlight(AlarmManagerService service, PendingIntent pendingIntent) { mPendingIntent = pendingIntent; mWorkSource = workSource; Intent intent = pendingIntent.getIntent(); mTarget = intent != null ? new Pair<String, ComponentName>(intent.getAction(), intent.getComponent()) Loading Loading @@ -504,17 +502,12 @@ class AlarmManagerService extends IAlarmManager.Stub { @Override public void set(int type, long triggerAtTime, long windowLength, long interval, PendingIntent operation, WorkSource workSource) { if (workSource != null) { mContext.enforceCallingPermission( android.Manifest.permission.UPDATE_DEVICE_STATS, "AlarmManager.set"); } set(type, triggerAtTime, windowLength, interval, operation, false, workSource); PendingIntent operation) { set(type, triggerAtTime, windowLength, interval, operation, false); } public void set(int type, long triggerAtTime, long windowLength, long interval, PendingIntent operation, boolean isStandalone, WorkSource workSource) { PendingIntent operation, boolean isStandalone) { if (operation == null) { Slog.w(TAG, "set/setRepeating ignored because there is no intent"); return; Loading Loading @@ -551,13 +544,13 @@ class AlarmManagerService extends IAlarmManager.Stub { + " interval=" + interval + " standalone=" + isStandalone); } setImplLocked(type, triggerAtTime, triggerElapsed, maxElapsed, interval, operation, isStandalone, workSource); interval, operation, isStandalone); } } private void setImplLocked(int type, long when, long whenElapsed, long maxWhen, long interval, PendingIntent operation, boolean isStandalone, WorkSource workSource) { Alarm a = new Alarm(type, when, whenElapsed, maxWhen, interval, operation, workSource); PendingIntent operation, boolean isStandalone) { Alarm a = new Alarm(type, when, whenElapsed, maxWhen, interval, operation); removeLocked(operation); final boolean reschedule; Loading Loading @@ -969,8 +962,7 @@ class AlarmManagerService extends IAlarmManager.Stub { final long nextElapsed = alarm.whenElapsed + delta; setImplLocked(alarm.type, alarm.when + delta, nextElapsed, maxTriggerTime(nowELAPSED, nextElapsed, alarm.repeatInterval), alarm.repeatInterval, alarm.operation, batch.standalone, alarm.workSource); alarm.repeatInterval, alarm.operation, batch.standalone); } } Loading Loading @@ -1002,17 +994,15 @@ class AlarmManagerService extends IAlarmManager.Stub { public long maxWhen; // also in the elapsed time base public long repeatInterval; public PendingIntent operation; public WorkSource workSource; public Alarm(int _type, long _when, long _whenElapsed, long _maxWhen, long _interval, PendingIntent _op, WorkSource _ws) { long _interval, PendingIntent _op) { type = _type; when = _when; whenElapsed = _whenElapsed; maxWhen = _maxWhen; repeatInterval = _interval; operation = _op; workSource = _ws; } @Override Loading Loading @@ -1126,11 +1116,11 @@ class AlarmManagerService extends IAlarmManager.Stub { // we have an active broadcast so stay awake. if (mBroadcastRefCount == 0) { setWakelockWorkSource(alarm.operation, alarm.workSource); setWakelockWorkSource(alarm.operation); mWakeLock.acquire(); } final InFlight inflight = new InFlight(AlarmManagerService.this, alarm.operation, alarm.workSource); alarm.operation); mInFlight.add(inflight); mBroadcastRefCount++; Loading Loading @@ -1172,18 +1162,8 @@ class AlarmManagerService extends IAlarmManager.Stub { } } /** * Attribute blame for a WakeLock. * @param pi PendingIntent to attribute blame to if ws is null. * @param ws WorkSource to attribute blame. */ void setWakelockWorkSource(PendingIntent pi, WorkSource ws) { void setWakelockWorkSource(PendingIntent pi) { try { if (ws != null) { mWakeLock.setWorkSource(ws); return; } final int uid = ActivityManagerNative.getDefault() .getUidForIntentSender(pi.getTarget()); if (uid >= 0) { Loading Loading @@ -1266,9 +1246,8 @@ class AlarmManagerService extends IAlarmManager.Stub { // the top of the next minute. final long tickEventDelay = nextTime - currentTime; final WorkSource workSource = null; // Let system take blame for time tick events. set(ELAPSED_REALTIME, SystemClock.elapsedRealtime() + tickEventDelay, 0, 0, mTimeTickSender, true, workSource); 0, mTimeTickSender, true); } public void scheduleDateChangedEvent() { Loading @@ -1280,8 +1259,7 @@ class AlarmManagerService extends IAlarmManager.Stub { calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, 1); final WorkSource workSource = null; // Let system take blame for date change events. set(RTC, calendar.getTimeInMillis(), 0, 0, mDateChangeSender, true, workSource); set(RTC, calendar.getTimeInMillis(), 0, 0, mDateChangeSender, true); } } Loading Loading @@ -1397,8 +1375,7 @@ class AlarmManagerService extends IAlarmManager.Stub { } else { // the next of our alarms is now in flight. reattribute the wakelock. if (mInFlight.size() > 0) { InFlight inFlight = mInFlight.get(0); setWakelockWorkSource(inFlight.mPendingIntent, inFlight.mWorkSource); setWakelockWorkSource(mInFlight.get(0).mPendingIntent); } else { // should never happen mLog.w("Alarm wakelock still held but sent queue empty"); Loading