diff options
| -rw-r--r-- | services/core/java/com/android/server/am/BroadcastProcessQueue.java | 6 | ||||
| -rw-r--r-- | services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java | 22 |
2 files changed, 25 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/am/BroadcastProcessQueue.java b/services/core/java/com/android/server/am/BroadcastProcessQueue.java index 0fcec6faa0cc..fc8175b76ecd 100644 --- a/services/core/java/com/android/server/am/BroadcastProcessQueue.java +++ b/services/core/java/com/android/server/am/BroadcastProcessQueue.java @@ -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; diff --git a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java index ff04728912ef..08f5d03e0148 100644 --- a/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java @@ -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. |