Don't allow core uids to be unfrozen due to deferrable broadcasts.
The special casing for core uids was added to ensure that we are not adding the normal broadcast delay to these uids but if a process belonging to a core uid is in a freezable state, we should defer all the deferrable broadcasts. Bug: 289397383 Test: atest services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java Test: atest services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java Change-Id: I47ce6ea68e2716a320198c008752cfaa7dedbb81
This commit is contained in:
@@ -1144,9 +1144,6 @@ class BroadcastProcessQueue {
|
||||
} else if (mProcessPersistent) {
|
||||
mRunnableAt = runnableAt + constants.DELAY_PERSISTENT_PROC_MILLIS;
|
||||
mRunnableAtReason = REASON_PERSISTENT;
|
||||
} else if (UserHandle.isCore(uid)) {
|
||||
mRunnableAt = runnableAt;
|
||||
mRunnableAtReason = REASON_CORE_UID;
|
||||
} else if (mCountOrdered > 0) {
|
||||
mRunnableAt = runnableAt;
|
||||
mRunnableAtReason = REASON_CONTAINS_ORDERED;
|
||||
@@ -1193,6 +1190,9 @@ class BroadcastProcessQueue {
|
||||
// is already cached, they'll be deferred on the line above
|
||||
mRunnableAt = runnableAt;
|
||||
mRunnableAtReason = REASON_CONTAINS_RESULT_TO;
|
||||
} else if (UserHandle.isCore(uid)) {
|
||||
mRunnableAt = runnableAt;
|
||||
mRunnableAtReason = REASON_CORE_UID;
|
||||
} else {
|
||||
mRunnableAt = runnableAt + constants.DELAY_NORMAL_MILLIS;
|
||||
mRunnableAtReason = REASON_NORMAL;
|
||||
|
||||
@@ -620,6 +620,28 @@ public final class BroadcastQueueModernImplTest {
|
||||
assertEquals(BroadcastProcessQueue.REASON_CORE_UID, queue.getRunnableAtReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRunnableAt_freezableCoreUid() {
|
||||
final BroadcastProcessQueue queue = new BroadcastProcessQueue(mConstants,
|
||||
"com.android.bluetooth", Process.BLUETOOTH_UID);
|
||||
|
||||
// Mark the process as freezable
|
||||
queue.setProcessAndUidState(mProcess, false, true);
|
||||
final Intent timeTick = new Intent(Intent.ACTION_TIME_TICK);
|
||||
final BroadcastOptions options = BroadcastOptions.makeWithDeferUntilActive(true);
|
||||
final BroadcastRecord timeTickRecord = makeBroadcastRecord(timeTick, options,
|
||||
List.of(makeMockRegisteredReceiver()), false);
|
||||
enqueueOrReplaceBroadcast(queue, timeTickRecord, 0);
|
||||
|
||||
assertEquals(Long.MAX_VALUE, queue.getRunnableAt());
|
||||
assertEquals(BroadcastProcessQueue.REASON_CACHED_INFINITE_DEFER,
|
||||
queue.getRunnableAtReason());
|
||||
|
||||
queue.setProcessAndUidState(mProcess, false, false);
|
||||
assertThat(queue.getRunnableAt()).isEqualTo(timeTickRecord.enqueueTime);
|
||||
assertEquals(BroadcastProcessQueue.REASON_CORE_UID, queue.getRunnableAtReason());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that a cached process that would normally be delayed becomes
|
||||
* immediately runnable when the given broadcast is enqueued.
|
||||
|
||||
Reference in New Issue
Block a user