Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a3eae63 authored by Palak Chaudhary's avatar Palak Chaudhary Committed by Android (Google) Code Review
Browse files

Merge "Use canSendBroadcast instead of enforceAllowedToSendBroadcast"

parents 2186139d 2e0b2357
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -14298,6 +14298,21 @@ public class ActivityManagerService extends IActivityManager.Stub
        // Ensure all internal loopers are registered for idle checks
        BroadcastLoopers.addMyLooper();
        if (Process.isSdkSandboxUid(realCallingUid)) {
            final SdkSandboxManagerLocal sdkSandboxManagerLocal = LocalManagerRegistry.getManager(
                    SdkSandboxManagerLocal.class);
            if (sdkSandboxManagerLocal == null) {
                throw new IllegalStateException("SdkSandboxManagerLocal not found when sending"
                        + " a broadcast from an SDK sandbox uid.");
            }
            if (!sdkSandboxManagerLocal.canSendBroadcast(intent)) {
                throw new SecurityException(
                        "Intent " + intent.getAction() + " may not be broadcast from an SDK sandbox"
                        + " uid. Given caller package " + callerPackage + " (pid=" + callingPid
                        + ", uid=" + callingUid + ")");
            }
        }
        if ((resultTo != null) && (resultToApp == null)) {
            if (resultTo.asBinder() instanceof BinderProxy) {
                // Warn when requesting results without a way to deliver them
@@ -14502,16 +14517,6 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        if (Process.isSdkSandboxUid(realCallingUid)) {
            SdkSandboxManagerLocal sdkSandboxManagerLocal = LocalManagerRegistry.getManager(
                    SdkSandboxManagerLocal.class);
            if (sdkSandboxManagerLocal == null) {
                throw new IllegalStateException("SdkSandboxManagerLocal not found when sending"
                    + " a broadcast from an SDK sandbox uid.");
            }
            sdkSandboxManagerLocal.enforceAllowedToSendBroadcast(intent);
        }
        boolean timeoutExempt = false;
        if (action != null) {