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
This commit is contained in:
committed by
Hai Zhang
parent
73e2690ede
commit
892ded1e8a
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user