Loading services/core/java/com/android/server/am/BroadcastProcessQueue.java +1 −2 Original line number Diff line number Diff line Loading @@ -353,8 +353,7 @@ class BroadcastProcessQueue { // If we come across the record that's being enqueued in the queue, then that means // we already enqueued it for a receiver in this process and trying to insert a new // one past this could create priority inversion in the queue, so bail out. if (record == testRecord && record.blockedUntilBeyondCount[recordIndex] > testRecord.blockedUntilBeyondCount[testRecordIndex]) { if (record == testRecord) { break; } if ((record.callingUid == testRecord.callingUid) Loading services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import android.content.IIntentReceiver; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Binder; import android.os.Bundle; import android.os.DeadObjectException; Loading Loading @@ -1877,6 +1878,32 @@ public class BroadcastQueueTest extends BaseBroadcastQueueTest { verifyScheduleRegisteredReceiver(times(1), receiverBlueApp, airplane); } @Test public void testReplacePending_withSingletonReceiver() throws Exception { final ProcessRecord callerApp = makeActiveProcessRecord(PACKAGE_PHONE); final ProcessRecord systemApp = makeActiveProcessRecord(PACKAGE_ANDROID, PROCESS_SYSTEM); final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED) .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); final ResolveInfo systemReceiverA = makeManifestReceiver(PACKAGE_ANDROID, PROCESS_SYSTEM, CLASS_BLUE, USER_SYSTEM); final ResolveInfo systemReceiverB = makeManifestReceiver(PACKAGE_ANDROID, PROCESS_SYSTEM, CLASS_BLUE, USER_GUEST); enqueueBroadcast(makeBroadcastRecord(airplane, callerApp, List.of( systemReceiverA, systemReceiverB))); assertEquals("Unexpected userId for receiverA", USER_SYSTEM, UserHandle.getUserId(systemReceiverA.activityInfo.applicationInfo.uid)); assertEquals("Unexpected userId for receiverB", USER_SYSTEM, UserHandle.getUserId(systemReceiverB.activityInfo.applicationInfo.uid)); waitForIdle(); verifyScheduleReceiver(times(2), systemApp, airplane); } @Test public void testIdleAndBarrier() throws Exception { final ProcessRecord callerApp = makeActiveProcessRecord(PACKAGE_RED); Loading Loading
services/core/java/com/android/server/am/BroadcastProcessQueue.java +1 −2 Original line number Diff line number Diff line Loading @@ -353,8 +353,7 @@ class BroadcastProcessQueue { // If we come across the record that's being enqueued in the queue, then that means // we already enqueued it for a receiver in this process and trying to insert a new // one past this could create priority inversion in the queue, so bail out. if (record == testRecord && record.blockedUntilBeyondCount[recordIndex] > testRecord.blockedUntilBeyondCount[testRecordIndex]) { if (record == testRecord) { break; } if ((record.callingUid == testRecord.callingUid) Loading
services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java +27 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ import android.content.IIntentReceiver; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Binder; import android.os.Bundle; import android.os.DeadObjectException; Loading Loading @@ -1877,6 +1878,32 @@ public class BroadcastQueueTest extends BaseBroadcastQueueTest { verifyScheduleRegisteredReceiver(times(1), receiverBlueApp, airplane); } @Test public void testReplacePending_withSingletonReceiver() throws Exception { final ProcessRecord callerApp = makeActiveProcessRecord(PACKAGE_PHONE); final ProcessRecord systemApp = makeActiveProcessRecord(PACKAGE_ANDROID, PROCESS_SYSTEM); final Intent airplane = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED) .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); final ResolveInfo systemReceiverA = makeManifestReceiver(PACKAGE_ANDROID, PROCESS_SYSTEM, CLASS_BLUE, USER_SYSTEM); final ResolveInfo systemReceiverB = makeManifestReceiver(PACKAGE_ANDROID, PROCESS_SYSTEM, CLASS_BLUE, USER_GUEST); enqueueBroadcast(makeBroadcastRecord(airplane, callerApp, List.of( systemReceiverA, systemReceiverB))); assertEquals("Unexpected userId for receiverA", USER_SYSTEM, UserHandle.getUserId(systemReceiverA.activityInfo.applicationInfo.uid)); assertEquals("Unexpected userId for receiverB", USER_SYSTEM, UserHandle.getUserId(systemReceiverB.activityInfo.applicationInfo.uid)); waitForIdle(); verifyScheduleReceiver(times(2), systemApp, airplane); } @Test public void testIdleAndBarrier() throws Exception { final ProcessRecord callerApp = makeActiveProcessRecord(PACKAGE_RED); Loading