summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Philip P. Moltmann <moltmann@google.com> 2019-06-12 16:31:29 -0700
committer Hai Zhang <zhanghai@google.com> 2020-01-14 19:43:02 +0000
commit892ded1e8a56dd622fd2bbddd77c762f0cad8f4e (patch)
tree2a3b99f6fb11dbfdc12c2cb681dd7a0174eda969
parent73e2690eded5d035de8560aaff60a6f47290305d (diff)
DO NOT MERGE Don't throw exception in AppOpsManager.checkOp
In Q we handled the case where the op does not match the package name by returning the default state. NoteOp and StartOp returned errored. Fix up these scenarios. Test: - atest CtsAppOpsTestCases - backported new test to Q to verify the behavior is the same in Q and master Bug: 132885449 Bug: 146463528 Bug: 146590200 Bug: 147649036 Change-Id: I5b94e92af759580f2d2644ece49f159bd006b31c
-rw-r--r--services/core/java/com/android/server/appop/AppOpsService.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 1760371597f1..3e7188c6e8ec 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -1809,7 +1809,14 @@ public class AppOpsService extends IAppOpsService.Stub {
return AppOpsManager.MODE_IGNORED;
}
- boolean isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
+ boolean isPrivileged;
+
+ try {
+ isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
+ } catch (SecurityException e) {
+ Slog.e(TAG, "checkOperation", e);
+ return AppOpsManager.opToDefaultMode(code);
+ }
synchronized (this) {
if (isOpRestrictedLocked(uid, code, packageName, isPrivileged)) {
@@ -1999,8 +2006,8 @@ public class AppOpsService extends IAppOpsService.Stub {
try {
isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
} catch (SecurityException e) {
- Slog.e(TAG, "Cannot startOperation", e);
- return AppOpsManager.MODE_IGNORED;
+ Slog.e(TAG, "noteOperation", e);
+ return AppOpsManager.MODE_ERRORED;
}
synchronized (this) {
@@ -2177,8 +2184,8 @@ public class AppOpsService extends IAppOpsService.Stub {
try {
isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
} catch (SecurityException e) {
- Slog.e(TAG, "Cannot startOperation", e);
- return AppOpsManager.MODE_IGNORED;
+ Slog.e(TAG, "startOperation", e);
+ return AppOpsManager.MODE_ERRORED;
}
synchronized (this) {