Loading services/core/java/com/android/server/am/BroadcastQueueModernImpl.java +23 −11 Original line number Diff line number Diff line Loading @@ -192,6 +192,12 @@ class BroadcastQueueModernImpl extends BroadcastQueue { @GuardedBy("mService") private @Nullable BroadcastProcessQueue mRunningColdStart; /** * Indicates whether we have queued a message to check pending cold start validity. */ @GuardedBy("mService") private boolean mCheckPendingColdStartQueued; /** * Collection of latches waiting for device to reach specific state. The * first argument is a function to test for the desired state, and the Loading Loading @@ -302,7 +308,11 @@ class BroadcastQueueModernImpl extends BroadcastQueue { return true; } case MSG_CHECK_PENDING_COLD_START_VALIDITY: { checkPendingColdStartValidity(); synchronized (mService) { /* Clear this as we have just received the broadcast. */ mCheckPendingColdStartQueued = false; checkPendingColdStartValidityLocked(); } return true; } case MSG_PROCESS_FREEZABLE_CHANGED: { Loading Loading @@ -549,7 +559,7 @@ class BroadcastQueueModernImpl extends BroadcastQueue { mService.updateOomAdjPendingTargetsLocked(OOM_ADJ_REASON_START_RECEIVER); } checkPendingColdStartValidity(); checkPendingColdStartValidityLocked(); checkAndRemoveWaitingFor(); traceEnd(cookie); Loading @@ -573,24 +583,26 @@ class BroadcastQueueModernImpl extends BroadcastQueue { enqueueUpdateRunningList(); } private void checkPendingColdStartValidity() { @GuardedBy("mService") private void checkPendingColdStartValidityLocked() { // There are a few cases where a starting process gets killed but AMS doesn't report // this event. So, once we start waiting for a pending cold start, periodically check // if the pending start is still valid and if not, clear it so that the queue doesn't // keep waiting for the process start forever. synchronized (mService) { // If there is no pending cold start, then nothing to do. if (mRunningColdStart == null) { return; } if (isPendingColdStartValid()) { if (!mCheckPendingColdStartQueued) { mLocalHandler.sendEmptyMessageDelayed(MSG_CHECK_PENDING_COLD_START_VALIDITY, mConstants.PENDING_COLD_START_CHECK_INTERVAL_MILLIS); mCheckPendingColdStartQueued = true; } } else { clearInvalidPendingColdStart(); } } } private void reEnqueueActiveBroadcast(@NonNull BroadcastProcessQueue queue) { checkState(queue.isActive(), "isActive"); Loading Loading
services/core/java/com/android/server/am/BroadcastQueueModernImpl.java +23 −11 Original line number Diff line number Diff line Loading @@ -192,6 +192,12 @@ class BroadcastQueueModernImpl extends BroadcastQueue { @GuardedBy("mService") private @Nullable BroadcastProcessQueue mRunningColdStart; /** * Indicates whether we have queued a message to check pending cold start validity. */ @GuardedBy("mService") private boolean mCheckPendingColdStartQueued; /** * Collection of latches waiting for device to reach specific state. The * first argument is a function to test for the desired state, and the Loading Loading @@ -302,7 +308,11 @@ class BroadcastQueueModernImpl extends BroadcastQueue { return true; } case MSG_CHECK_PENDING_COLD_START_VALIDITY: { checkPendingColdStartValidity(); synchronized (mService) { /* Clear this as we have just received the broadcast. */ mCheckPendingColdStartQueued = false; checkPendingColdStartValidityLocked(); } return true; } case MSG_PROCESS_FREEZABLE_CHANGED: { Loading Loading @@ -549,7 +559,7 @@ class BroadcastQueueModernImpl extends BroadcastQueue { mService.updateOomAdjPendingTargetsLocked(OOM_ADJ_REASON_START_RECEIVER); } checkPendingColdStartValidity(); checkPendingColdStartValidityLocked(); checkAndRemoveWaitingFor(); traceEnd(cookie); Loading @@ -573,24 +583,26 @@ class BroadcastQueueModernImpl extends BroadcastQueue { enqueueUpdateRunningList(); } private void checkPendingColdStartValidity() { @GuardedBy("mService") private void checkPendingColdStartValidityLocked() { // There are a few cases where a starting process gets killed but AMS doesn't report // this event. So, once we start waiting for a pending cold start, periodically check // if the pending start is still valid and if not, clear it so that the queue doesn't // keep waiting for the process start forever. synchronized (mService) { // If there is no pending cold start, then nothing to do. if (mRunningColdStart == null) { return; } if (isPendingColdStartValid()) { if (!mCheckPendingColdStartQueued) { mLocalHandler.sendEmptyMessageDelayed(MSG_CHECK_PENDING_COLD_START_VALIDITY, mConstants.PENDING_COLD_START_CHECK_INTERVAL_MILLIS); mCheckPendingColdStartQueued = true; } } else { clearInvalidPendingColdStart(); } } } private void reEnqueueActiveBroadcast(@NonNull BroadcastProcessQueue queue) { checkState(queue.isActive(), "isActive"); Loading