Loading services/core/java/com/android/server/AlarmManagerService.java +7 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ class AlarmManagerService extends SystemService { static final boolean DEBUG_VALIDATE = localLOGV || false; static final boolean DEBUG_ALARM_CLOCK = localLOGV || false; static final boolean DEBUG_LISTENER_CALLBACK = localLOGV || false; static final boolean DEBUG_WAKELOCK = localLOGV || false; static final boolean RECORD_ALARMS_IN_HISTORY = true; static final boolean RECORD_DEVICE_IDLE_ALARMS = false; static final int ALARM_EVENT = 1; Loading Loading @@ -2934,6 +2935,9 @@ class AlarmManagerService extends SystemService { updateStatsLocked(inflight); } mBroadcastRefCount--; if (DEBUG_WAKELOCK) { Slog.d(TAG, "mBroadcastRefCount -> " + mBroadcastRefCount); } if (mBroadcastRefCount == 0) { mHandler.obtainMessage(AlarmHandler.REPORT_ALARMS_ACTIVE, 0).sendToTarget(); mWakeLock.release(); Loading Loading @@ -3074,6 +3078,9 @@ class AlarmManagerService extends SystemService { } // The alarm is now in flight; now arrange wakelock and stats tracking if (DEBUG_WAKELOCK) { Slog.d(TAG, "mBroadcastRefCount -> " + (mBroadcastRefCount + 1)); } if (mBroadcastRefCount == 0) { setWakelockWorkSource(alarm.operation, alarm.workSource, alarm.type, alarm.statsTag, (alarm.operation == null) ? alarm.uid : -1, Loading services/core/java/com/android/server/am/ActivityManagerService.java +22 −3 Original line number Diff line number Diff line Loading @@ -18877,7 +18877,9 @@ public class ActivityManagerService extends IActivityManager.Stub appOp, brOptions, registeredReceivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, false, userId); if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing parallel broadcast " + r); final boolean replaced = replacePending && queue.replaceParallelBroadcastLocked(r); final boolean replaced = replacePending && (queue.replaceParallelBroadcastLocked(r) != null); // Note: We assume resultTo is null for non-ordered broadcasts. if (!replaced) { queue.enqueueParallelBroadcastLocked(r); queue.scheduleBroadcastsLocked(); Loading Loading @@ -18976,8 +18978,25 @@ public class ActivityManagerService extends IActivityManager.Stub if (DEBUG_BROADCAST) Slog.i(TAG_BROADCAST, "Enqueueing broadcast " + r.intent.getAction()); boolean replaced = replacePending && queue.replaceOrderedBroadcastLocked(r); if (!replaced) { final BroadcastRecord oldRecord = replacePending ? queue.replaceOrderedBroadcastLocked(r) : null; if (oldRecord != null) { // Replaced, fire the result-to receiver. if (oldRecord.resultTo != null) { final BroadcastQueue oldQueue = broadcastQueueForIntent(oldRecord.intent); try { oldQueue.performReceiveLocked(oldRecord.callerApp, oldRecord.resultTo, oldRecord.intent, Activity.RESULT_CANCELED, null, null, false, false, oldRecord.userId); } catch (RemoteException e) { Slog.w(TAG, "Failure [" + queue.mQueueName + "] sending broadcast result of " + intent, e); } } } else { queue.enqueueOrderedBroadcastLocked(r); queue.scheduleBroadcastsLocked(); } services/core/java/com/android/server/am/BroadcastQueue.java +26 −22 Original line number Diff line number Diff line Loading @@ -239,33 +239,37 @@ public final class BroadcastQueue { } } public final boolean replaceParallelBroadcastLocked(BroadcastRecord r) { final Intent intent = r.intent; for (int i = mParallelBroadcasts.size() - 1; i >= 0; i--) { final Intent curIntent = mParallelBroadcasts.get(i).intent; if (intent.filterEquals(curIntent)) { if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "***** DROPPING PARALLEL [" + mQueueName + "]: " + intent); mParallelBroadcasts.set(i, r); return true; } /** * Find the same intent from queued parallel broadcast, replace with a new one and return * the old one. */ public final BroadcastRecord replaceParallelBroadcastLocked(BroadcastRecord r) { return replaceBroadcastLocked(mParallelBroadcasts, r, "PARALLEL"); } return false; /** * Find the same intent from queued ordered broadcast, replace with a new one and return * the old one. */ public final BroadcastRecord replaceOrderedBroadcastLocked(BroadcastRecord r) { return replaceBroadcastLocked(mOrderedBroadcasts, r, "ORDERED"); } public final boolean replaceOrderedBroadcastLocked(BroadcastRecord r) { private BroadcastRecord replaceBroadcastLocked(ArrayList<BroadcastRecord> queue, BroadcastRecord r, String typeForLogging) { final Intent intent = r.intent; for (int i = mOrderedBroadcasts.size() - 1; i > 0; i--) { if (intent.filterEquals(mOrderedBroadcasts.get(i).intent)) { if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "***** DROPPING ORDERED [" + mQueueName + "]: " + intent); mOrderedBroadcasts.set(i, r); return true; for (int i = queue.size() - 1; i > 0; i--) { final BroadcastRecord old = queue.get(i); if (old.userId == r.userId && intent.filterEquals(old.intent)) { if (DEBUG_BROADCAST) { Slog.v(TAG_BROADCAST, "***** DROPPING " + typeForLogging + " [" + mQueueName + "]: " + intent); } queue.set(i, r); return old; } return false; } return null; } private final void processCurBroadcastLocked(BroadcastRecord r, Loading Loading
services/core/java/com/android/server/AlarmManagerService.java +7 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ class AlarmManagerService extends SystemService { static final boolean DEBUG_VALIDATE = localLOGV || false; static final boolean DEBUG_ALARM_CLOCK = localLOGV || false; static final boolean DEBUG_LISTENER_CALLBACK = localLOGV || false; static final boolean DEBUG_WAKELOCK = localLOGV || false; static final boolean RECORD_ALARMS_IN_HISTORY = true; static final boolean RECORD_DEVICE_IDLE_ALARMS = false; static final int ALARM_EVENT = 1; Loading Loading @@ -2934,6 +2935,9 @@ class AlarmManagerService extends SystemService { updateStatsLocked(inflight); } mBroadcastRefCount--; if (DEBUG_WAKELOCK) { Slog.d(TAG, "mBroadcastRefCount -> " + mBroadcastRefCount); } if (mBroadcastRefCount == 0) { mHandler.obtainMessage(AlarmHandler.REPORT_ALARMS_ACTIVE, 0).sendToTarget(); mWakeLock.release(); Loading Loading @@ -3074,6 +3078,9 @@ class AlarmManagerService extends SystemService { } // The alarm is now in flight; now arrange wakelock and stats tracking if (DEBUG_WAKELOCK) { Slog.d(TAG, "mBroadcastRefCount -> " + (mBroadcastRefCount + 1)); } if (mBroadcastRefCount == 0) { setWakelockWorkSource(alarm.operation, alarm.workSource, alarm.type, alarm.statsTag, (alarm.operation == null) ? alarm.uid : -1, Loading
services/core/java/com/android/server/am/ActivityManagerService.java +22 −3 Original line number Diff line number Diff line Loading @@ -18877,7 +18877,9 @@ public class ActivityManagerService extends IActivityManager.Stub appOp, brOptions, registeredReceivers, resultTo, resultCode, resultData, resultExtras, ordered, sticky, false, userId); if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "Enqueueing parallel broadcast " + r); final boolean replaced = replacePending && queue.replaceParallelBroadcastLocked(r); final boolean replaced = replacePending && (queue.replaceParallelBroadcastLocked(r) != null); // Note: We assume resultTo is null for non-ordered broadcasts. if (!replaced) { queue.enqueueParallelBroadcastLocked(r); queue.scheduleBroadcastsLocked(); Loading Loading @@ -18976,8 +18978,25 @@ public class ActivityManagerService extends IActivityManager.Stub if (DEBUG_BROADCAST) Slog.i(TAG_BROADCAST, "Enqueueing broadcast " + r.intent.getAction()); boolean replaced = replacePending && queue.replaceOrderedBroadcastLocked(r); if (!replaced) { final BroadcastRecord oldRecord = replacePending ? queue.replaceOrderedBroadcastLocked(r) : null; if (oldRecord != null) { // Replaced, fire the result-to receiver. if (oldRecord.resultTo != null) { final BroadcastQueue oldQueue = broadcastQueueForIntent(oldRecord.intent); try { oldQueue.performReceiveLocked(oldRecord.callerApp, oldRecord.resultTo, oldRecord.intent, Activity.RESULT_CANCELED, null, null, false, false, oldRecord.userId); } catch (RemoteException e) { Slog.w(TAG, "Failure [" + queue.mQueueName + "] sending broadcast result of " + intent, e); } } } else { queue.enqueueOrderedBroadcastLocked(r); queue.scheduleBroadcastsLocked(); }
services/core/java/com/android/server/am/BroadcastQueue.java +26 −22 Original line number Diff line number Diff line Loading @@ -239,33 +239,37 @@ public final class BroadcastQueue { } } public final boolean replaceParallelBroadcastLocked(BroadcastRecord r) { final Intent intent = r.intent; for (int i = mParallelBroadcasts.size() - 1; i >= 0; i--) { final Intent curIntent = mParallelBroadcasts.get(i).intent; if (intent.filterEquals(curIntent)) { if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "***** DROPPING PARALLEL [" + mQueueName + "]: " + intent); mParallelBroadcasts.set(i, r); return true; } /** * Find the same intent from queued parallel broadcast, replace with a new one and return * the old one. */ public final BroadcastRecord replaceParallelBroadcastLocked(BroadcastRecord r) { return replaceBroadcastLocked(mParallelBroadcasts, r, "PARALLEL"); } return false; /** * Find the same intent from queued ordered broadcast, replace with a new one and return * the old one. */ public final BroadcastRecord replaceOrderedBroadcastLocked(BroadcastRecord r) { return replaceBroadcastLocked(mOrderedBroadcasts, r, "ORDERED"); } public final boolean replaceOrderedBroadcastLocked(BroadcastRecord r) { private BroadcastRecord replaceBroadcastLocked(ArrayList<BroadcastRecord> queue, BroadcastRecord r, String typeForLogging) { final Intent intent = r.intent; for (int i = mOrderedBroadcasts.size() - 1; i > 0; i--) { if (intent.filterEquals(mOrderedBroadcasts.get(i).intent)) { if (DEBUG_BROADCAST) Slog.v(TAG_BROADCAST, "***** DROPPING ORDERED [" + mQueueName + "]: " + intent); mOrderedBroadcasts.set(i, r); return true; for (int i = queue.size() - 1; i > 0; i--) { final BroadcastRecord old = queue.get(i); if (old.userId == r.userId && intent.filterEquals(old.intent)) { if (DEBUG_BROADCAST) { Slog.v(TAG_BROADCAST, "***** DROPPING " + typeForLogging + " [" + mQueueName + "]: " + intent); } queue.set(i, r); return old; } return false; } return null; } private final void processCurBroadcastLocked(BroadcastRecord r, Loading