From 616554c051842f3700c65197f69b7653883e5794 Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Mon, 26 Feb 2018 13:27:26 -0800 Subject: 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 --- libs/binder/IAppOpsService.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libs/binder/IAppOpsService.cpp') diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp index 638ae5c8ac..9c76350cbd 100644 --- a/libs/binder/IAppOpsService.cpp +++ b/libs/binder/IAppOpsService.cpp @@ -61,13 +61,14 @@ public: } virtual int32_t startOperation(const sp& token, int32_t code, int32_t uid, - const String16& packageName) { + const String16& packageName, bool startIfModeDefault) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeStrongBinder(token); data.writeInt32(code); data.writeInt32(uid); data.writeString16(packageName); + data.writeInt32(startIfModeDefault ? 1 : 0); remote()->transact(START_OPERATION_TRANSACTION, data, &reply); // fail on exception if (reply.readExceptionCode() != 0) return MODE_ERRORED; @@ -159,7 +160,8 @@ status_t BnAppOpsService::onTransact( int32_t code = data.readInt32(); int32_t uid = data.readInt32(); String16 packageName = data.readString16(); - int32_t res = startOperation(token, code, uid, packageName); + bool startIfModeDefault = data.readInt32() == 1; + int32_t res = startOperation(token, code, uid, packageName, startIfModeDefault); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; -- cgit v1.2.3-59-g8ed1b