From 892ded1e8a56dd622fd2bbddd77c762f0cad8f4e Mon Sep 17 00:00:00 2001 From: "Philip P. Moltmann" Date: Wed, 12 Jun 2019 16:31:29 -0700 Subject: 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 --- .../java/com/android/server/appop/AppOpsService.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'services') 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) { -- cgit v1.2.3-59-g8ed1b