summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ashwini Oruganti <ashfall@google.com> 2021-10-12 15:06:57 -0700
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2021-10-15 21:33:02 +0000
commit148d7fe341bc509eb97af9660d9ee966eb08042c (patch)
tree9870de5c8773057d46c2b1b4480de00b477d5f54
parent8b770aef8d4cee3dc139001d3be28d48fe2e47f0 (diff)
Update the BroadcastQueue logic for runtime permissions
Previously, we were skipping a broadcast when either the permission or the app op was granted. However, for runtime permissions to be considered "granted" both the permission and the app op need to be granted. This change updates taking this into account. Test: manual Bug: 202436287 Bug: 183537857 Change-Id: I9f12f9e17e61246d723d18ead93c6115bbf6d5cf Merged-In: I9f12f9e17e61246d723d18ead93c6115bbf6d5cf (cherry picked from commit 1e6a9681266986e1d8ceba55646199c02223c7b8) (cherry picked from commit 400ff61cff478ad0a2e79509aaa254d2341c5e3f)
-rw-r--r--services/core/java/com/android/server/am/BroadcastQueue.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java
index 503b3a93b31f..94bf62f8b9b7 100644
--- a/services/core/java/com/android/server/am/BroadcastQueue.java
+++ b/services/core/java/com/android/server/am/BroadcastQueue.java
@@ -1568,17 +1568,23 @@ public final class BroadcastQueue {
perm = PackageManager.PERMISSION_DENIED;
}
- if (perm == PackageManager.PERMISSION_GRANTED) {
- skip = true;
- break;
- }
-
int appOp = AppOpsManager.permissionToOpCode(excludedPermission);
if (appOp != AppOpsManager.OP_NONE) {
- if (mService.getAppOpsManager().checkOpNoThrow(appOp,
+ // When there is an app op associated with the permission,
+ // skip when both the permission and the app op are
+ // granted.
+ if ((perm == PackageManager.PERMISSION_GRANTED) && (
+ mService.getAppOpsManager().checkOpNoThrow(appOp,
info.activityInfo.applicationInfo.uid,
info.activityInfo.packageName)
- == AppOpsManager.MODE_ALLOWED) {
+ == AppOpsManager.MODE_ALLOWED)) {
+ skip = true;
+ break;
+ }
+ } else {
+ // When there is no app op associated with the permission,
+ // skip when permission is granted.
+ if (perm == PackageManager.PERMISSION_GRANTED) {
skip = true;
break;
}