diff options
| author | 2021-10-12 15:06:57 -0700 | |
|---|---|---|
| committer | 2021-10-13 14:24:42 -0700 | |
| commit | 1e6a9681266986e1d8ceba55646199c02223c7b8 (patch) | |
| tree | 9c25ab4847d7ec79ad1a935908cf927fb7f40212 | |
| parent | 7c7bb9ab403cadac5113e0b0a7b1d232f1e27e59 (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
| -rw-r--r-- | services/core/java/com/android/server/am/BroadcastQueue.java | 20 |
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 ed70d2b92ecc..8638c7da4da2 100644 --- a/services/core/java/com/android/server/am/BroadcastQueue.java +++ b/services/core/java/com/android/server/am/BroadcastQueue.java @@ -1588,17 +1588,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; } |