Merge "Deferred BOOT_COMPLETED broadcast does not mean queue is not idle." into tm-dev

This commit is contained in:
Hui Yu
2022-04-16 21:33:45 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 5 deletions

View File

@@ -15093,7 +15093,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@GuardedBy("this")
final boolean canGcNowLocked() {
for (BroadcastQueue q : mBroadcastQueues) {
if (!q.mParallelBroadcasts.isEmpty() || !q.mDispatcher.isEmpty()) {
if (!q.mParallelBroadcasts.isEmpty() || !q.mDispatcher.isIdle()) {
return false;
}
}

View File

@@ -511,13 +511,25 @@ public class BroadcastDispatcher {
* Standard contents-are-empty check
*/
public boolean isEmpty() {
synchronized (mLock) {
return isIdle()
&& getBootCompletedBroadcastsUidsSize(Intent.ACTION_LOCKED_BOOT_COMPLETED) == 0
&& getBootCompletedBroadcastsUidsSize(Intent.ACTION_BOOT_COMPLETED) == 0;
}
}
/**
* Have less check than {@link #isEmpty()}.
* The dispatcher is considered as idle even with deferred LOCKED_BOOT_COMPLETED/BOOT_COMPLETED
* broadcasts because those can be deferred until the first time the uid's process is started.
* @return
*/
public boolean isIdle() {
synchronized (mLock) {
return mCurrentBroadcast == null
&& mOrderedBroadcasts.isEmpty()
&& isDeferralsListEmpty(mDeferredBroadcasts)
&& isDeferralsListEmpty(mAlarmBroadcasts)
&& getBootCompletedBroadcastsUidsSize(Intent.ACTION_LOCKED_BOOT_COMPLETED) == 0
&& getBootCompletedBroadcastsUidsSize(Intent.ACTION_BOOT_COMPLETED) == 0;
&& isDeferralsListEmpty(mAlarmBroadcasts);
}
}

View File

@@ -2218,7 +2218,7 @@ public final class BroadcastQueue {
}
boolean isIdle() {
return mParallelBroadcasts.isEmpty() && mDispatcher.isEmpty()
return mParallelBroadcasts.isEmpty() && mDispatcher.isIdle()
&& (mPendingBroadcast == null);
}