Use start/finish app ops in window manager - frameworks native
Add infrastructure to app ops to specify how to treat mode_default
(for now only for startOp) allowing the caller to decide of this
mode should be treated as success - this is useful if the caller
already performed the default permission checks which determined
that the caller would perform the operation if the mode is default.
This way there is a record in the app ops history that this op
was performed. This is now used by the window manager service
which starts/finishes ops when an alert window is shown/hidden.
The window manager allows adding the window if the mode is default
but the caller has the fallback permission. In this case the
alert window would be shown and we want that noted in the op
history.
Now the window manager properly starts/finishes alert window op
when an alert window is shown/hidden. This is required to allow
SystemUI to badge notifications from apps showing alert windows
or add a dedicated notification if the app has no notifications.
Test: cts-tradefed run cts-dev -m CtsWindowManagerDeviceTestCases
Added android.server.wm.AppOpAlertWindowAppOpsTest
cts-tradefed run cts-dev -m CtsPermissionTestCases
-t android.permission.cts.AppOpsTest
bug:64085448
Change-Id: I59658522bb521bb1e08009de046f52fef6f88687
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp
index f3b86ae..62c8987 100644
--- a/libs/binder/AppOpsManager.cpp
+++ b/libs/binder/AppOpsManager.cpp
@@ -100,11 +100,12 @@
: APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
-int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) {
+int32_t AppOpsManager::startOpNoThrow(int32_t op, int32_t uid, const String16& callingPackage,
+ bool startIfModeDefault) {
sp<IAppOpsService> service = getService();
return service != NULL
- ? service->startOperation(getToken(service), op, uid, callingPackage)
- : APP_OPS_MANAGER_UNAVAILABLE_MODE;
+ ? service->startOperation(getToken(service), op, uid, callingPackage,
+ startIfModeDefault) : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) {