Skip to content

Commit 892ded1

Browse files
moltmannzhanghai
authored andcommitted
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
1 parent 73e2690 commit 892ded1

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

services/core/java/com/android/server/appop/AppOpsService.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,14 @@ private int checkOperationImpl(int code, int uid, String packageName,
18091809
return AppOpsManager.MODE_IGNORED;
18101810
}
18111811

1812-
boolean isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
1812+
boolean isPrivileged;
1813+
1814+
try {
1815+
isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
1816+
} catch (SecurityException e) {
1817+
Slog.e(TAG, "checkOperation", e);
1818+
return AppOpsManager.opToDefaultMode(code);
1819+
}
18131820

18141821
synchronized (this) {
18151822
if (isOpRestrictedLocked(uid, code, packageName, isPrivileged)) {
@@ -1999,8 +2006,8 @@ private int noteOperationUnchecked(int code, int uid, String packageName,
19992006
try {
20002007
isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
20012008
} catch (SecurityException e) {
2002-
Slog.e(TAG, "Cannot startOperation", e);
2003-
return AppOpsManager.MODE_IGNORED;
2009+
Slog.e(TAG, "noteOperation", e);
2010+
return AppOpsManager.MODE_ERRORED;
20042011
}
20052012

20062013
synchronized (this) {
@@ -2177,8 +2184,8 @@ public int startOperation(IBinder token, int code, int uid, String packageName,
21772184
try {
21782185
isPrivileged = verifyAndGetIsPrivileged(uid, packageName);
21792186
} catch (SecurityException e) {
2180-
Slog.e(TAG, "Cannot startOperation", e);
2181-
return AppOpsManager.MODE_IGNORED;
2187+
Slog.e(TAG, "startOperation", e);
2188+
return AppOpsManager.MODE_ERRORED;
21822189
}
21832190

21842191
synchronized (this) {

0 commit comments

Comments
 (0)