diff options
author | 2021-11-22 17:54:04 +0000 | |
---|---|---|
committer | 2021-11-22 17:54:04 +0000 | |
commit | 811ae06be3fd471d828bd0a17d96169d40996c47 (patch) | |
tree | 2fafe692856624ecede8afc50c8de87b18b58da0 | |
parent | 64141a96131100f914223ad955be9d6209f600b6 (diff) | |
parent | afe8e4eb0b70252742a04a587ac146a3d904db6e (diff) |
Merge "Revert "Allow protected or sticky broadcsts without flags.""
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 15871aa8094b..1fe4d1405dca 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -12690,38 +12690,30 @@ public class ActivityManagerService extends IActivityManager.Stub "Receiver can't specify both RECEIVER_EXPORTED and RECEIVER_NOT_EXPORTED" + "flag"); } - - // Don't enforce the flag check if we're EITHER registering for only protected - // broadcasts, or the receiver is null (a sticky broadcast). Sticky broadcasts should - // not be used generally, so we will be marking them as exported by default - final boolean requireExplicitFlagForDynamicReceivers = CompatChanges.isChangeEnabled( - DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED, callingUid); - if (!onlyProtectedBroadcasts) { - if (receiver == null && !explicitExportStateDefined) { - // sticky broadcast, no flag specified (flag isn't required) - flags |= Context.RECEIVER_EXPORTED; - } else if (requireExplicitFlagForDynamicReceivers && !explicitExportStateDefined) { - if (ENFORCE_DYNAMIC_RECEIVER_EXPLICIT_EXPORT) { - throw new SecurityException( - callerPackage + ": Targeting T+ (version " - + Build.VERSION_CODES.TIRAMISU - + " and above) requires that one of RECEIVER_EXPORTED or " - + "RECEIVER_NOT_EXPORTED be specified when registering a " - + "receiver"); - } else { - Slog.wtf(TAG, - callerPackage + ": Targeting T+ (version " - + Build.VERSION_CODES.TIRAMISU - + " and above) requires that one of RECEIVER_EXPORTED or " - + "RECEIVER_NOT_EXPORTED be specified when registering a " - + "receiver"); - // Assume default behavior-- flag check is not enforced - flags |= Context.RECEIVER_EXPORTED; - } - } else if (!requireExplicitFlagForDynamicReceivers) { - // Change is not enabled, thus not targeting T+. Assume exported. + if (CompatChanges.isChangeEnabled(DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED, + callingUid) + && !explicitExportStateDefined) { + if (ENFORCE_DYNAMIC_RECEIVER_EXPLICIT_EXPORT) { + throw new SecurityException( + callerPackage + ": Targeting T+ (version " + + Build.VERSION_CODES.TIRAMISU + + " and above) requires that one of RECEIVER_EXPORTED or " + + "RECEIVER_NOT_EXPORTED be specified when registering a " + + "receiver"); + } else { + Slog.wtf(TAG, + callerPackage + ": Targeting T+ (version " + + Build.VERSION_CODES.TIRAMISU + + " and above) requires that one of RECEIVER_EXPORTED or " + + "RECEIVER_NOT_EXPORTED be specified when registering a " + + "receiver"); + // Assume default behavior-- flag check is not enforced flags |= Context.RECEIVER_EXPORTED; } + } else if (!CompatChanges.isChangeEnabled(DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED, + callingUid)) { + // Change is not enabled, thus not targeting T+. Assume exported. + flags |= Context.RECEIVER_EXPORTED; } } @@ -12739,7 +12731,7 @@ public class ActivityManagerService extends IActivityManager.Stub (intent.getFlags() & Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS) == 0) { continue; } - // If intent has scheme "content", it will need to access + // If intent has scheme "content", it will need to acccess // provider that needs to lock mProviderMap in ActivityThread // and also it may need to wait application response, so we // cannot lock ActivityManagerService here. |