Revert "Revert "Only allow root/system UIDs to send broadcast to unexported receiver""
This reverts commit 391263ceb44bd490baad3474d409fc9c920cec5e.
Reason for revert: Affected receivers have been updated to remove the RECEIVER_NOT_EXPORTED flag in ag/17597116 and ag/17575182; all other receivers using this flag are either expecting the broadcast from the local app or a protected-broadcast sent from the system UID.
Bug: 225999840
Test: atest ContextTest
Test: atest CtsSensorTestCases
Test: atest CtsAppExitTestCases
Test: atest UiTranslationManagerTest
Test: atest CtsAutoFillServiceTestCases:android.autofillservice.cts.dropdown.LoginActivityTest
Test: atest AccessibilityWindowReportingTest
Test: atest AndroidCarApiTest
Test: atest BugReportAppTest
Test: atest CarSecurityPermissionTest
Test: atest CarServiceTest
Test: atest CarServiceUnitTest
Test: atest com.android.car.obd2.test
Test: atest SampleCustomInputServiceTest
Change-Id: Ifd76ed5d84de43eeb8f5215d07e90b0952673180
diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java
index ea63c08..6ab18d5 100644
--- a/services/core/java/com/android/server/am/BroadcastQueue.java
+++ b/services/core/java/com/android/server/am/BroadcastQueue.java
@@ -869,9 +869,9 @@
// Ensure that broadcasts are only sent to other apps if they are explicitly marked as
// exported, or are System level broadcasts
- if (!skip && !filter.exported && !Process.isCoreUid(r.callingUid)
- && filter.receiverList.uid != r.callingUid) {
-
+ if (!skip && !filter.exported && mService.checkComponentPermission(null, r.callingPid,
+ r.callingUid, filter.receiverList.uid, filter.exported)
+ != PackageManager.PERMISSION_GRANTED) {
Slog.w(TAG, "Exported Denial: sending "
+ r.intent.toString()
+ ", action: " + r.intent.getAction()