Pass non-null message of window op to AppOps
If the window op is classified as OP_SYSTEM_ALERT_WINDOW (map to a dangerous/appop level permission), the default message will be callstack that causes overhead. Also change the window op related usages to the recommended (not deprecated) ones. Bug: 139522754 Test: atest WindowAddRemovePerfTest Change-Id: I9cf0561dd5877ee05dbb61c8ced25e2eba09b691
This commit is contained in:
@@ -2139,8 +2139,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
|
||||
// check if user has enabled this operation. SecurityException will be thrown if this app
|
||||
// has not been allowed by the user
|
||||
final int mode = mAppOpsManager.noteOpNoThrow(outAppOp[0], callingUid, packageName);
|
||||
// has not been allowed by the user. The reason to use "noteOp" (instead of checkOp) is to
|
||||
// make sure the usage is logged.
|
||||
final int mode = mAppOpsManager.noteOpNoThrow(outAppOp[0], callingUid, packageName,
|
||||
null /* featureId */, "check-add");
|
||||
switch (mode) {
|
||||
case AppOpsManager.MODE_ALLOWED:
|
||||
case AppOpsManager.MODE_IGNORED:
|
||||
|
||||
@@ -2917,8 +2917,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
// and add the window only if the permission was granted. Therefore, if
|
||||
// the mode is MODE_DEFAULT we want the op to succeed as the window is
|
||||
// shown.
|
||||
final int mode = mWmService.mAppOps.startOpNoThrow(mAppOp,
|
||||
getOwningUid(), getOwningPackage(), true);
|
||||
final int mode = mWmService.mAppOps.startOpNoThrow(mAppOp, getOwningUid(),
|
||||
getOwningPackage(), true /* startIfModeDefault */, null /* featureId */,
|
||||
"init-default-visibility");
|
||||
if (mode != MODE_ALLOWED && mode != MODE_DEFAULT) {
|
||||
setAppOpVisibilityLw(false);
|
||||
}
|
||||
@@ -2926,7 +2927,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
|
||||
void resetAppOpsState() {
|
||||
if (mAppOp != OP_NONE && mAppOpVisibility) {
|
||||
mWmService.mAppOps.finishOp(mAppOp, getOwningUid(), getOwningPackage());
|
||||
mWmService.mAppOps.finishOp(mAppOp, getOwningUid(), getOwningPackage(),
|
||||
null /* featureId */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2941,11 +2943,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
// as this would mean we will get another change callback and will reconcile.
|
||||
int mode = mWmService.mAppOps.checkOpNoThrow(mAppOp, uid, packageName);
|
||||
if (mode != MODE_ALLOWED && mode != MODE_DEFAULT) {
|
||||
mWmService.mAppOps.finishOp(mAppOp, uid, packageName);
|
||||
mWmService.mAppOps.finishOp(mAppOp, uid, packageName, null /* featureId */);
|
||||
setAppOpVisibilityLw(false);
|
||||
}
|
||||
} else {
|
||||
final int mode = mWmService.mAppOps.startOpNoThrow(mAppOp, uid, packageName, true);
|
||||
final int mode = mWmService.mAppOps.startOpNoThrow(mAppOp, uid, packageName,
|
||||
true /* startIfModeDefault */, null /* featureId */, "attempt-to-be-visible");
|
||||
if (mode == MODE_ALLOWED || mode == MODE_DEFAULT) {
|
||||
setAppOpVisibilityLw(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user