From 3879cf6939e5fb177ff08328a000dd1ec4c6ffc8 Mon Sep 17 00:00:00 2001 From: "Philip P. Moltmann" Date: Fri, 20 Dec 2019 11:22:37 -0800 Subject: Collect AsyncNotedAppOp in same call as native noteOp This reduces the overhead of collecting noted app-ops Exempt-From-Owner-Approval: minor change Bug: 136505050 Test: atest CtsAppOpsTestCases Change-Id: I05a186b772b337219f9e70123a89a15f1e88dd15 --- libs/binder/IAppOpsService.cpp | 46 +++++++++++++----------------------------- 1 file changed, 14 insertions(+), 32 deletions(-) (limited to 'libs/binder/IAppOpsService.cpp') diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp index 7384466b55..a5555a304f 100644 --- a/libs/binder/IAppOpsService.cpp +++ b/libs/binder/IAppOpsService.cpp @@ -47,13 +47,16 @@ public: } virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName, - const std::unique_ptr& featureId) { + const std::unique_ptr& featureId, bool shouldCollectAsyncNotedOp, + const String16& message) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeInt32(code); data.writeInt32(uid); data.writeString16(packageName); data.writeString16(featureId); + data.writeInt32(shouldCollectAsyncNotedOp ? 1 : 0); + data.writeString16(message); remote()->transact(NOTE_OPERATION_TRANSACTION, data, &reply); // fail on exception if (reply.readExceptionCode() != 0) return MODE_ERRORED; @@ -62,7 +65,7 @@ public: virtual int32_t startOperation(const sp& token, int32_t code, int32_t uid, const String16& packageName, const std::unique_ptr& featureId, - bool startIfModeDefault) { + bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeStrongBinder(token); @@ -71,6 +74,8 @@ public: data.writeString16(packageName); data.writeString16(featureId); data.writeInt32(startIfModeDefault ? 1 : 0); + data.writeInt32(shouldCollectAsyncNotedOp ? 1 : 0); + data.writeString16(message); remote()->transact(START_OPERATION_TRANSACTION, data, &reply); // fail on exception if (reply.readExceptionCode() != 0) return MODE_ERRORED; @@ -139,20 +144,6 @@ public: remote()->transact(SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION, data, &reply); } - virtual void noteAsyncOp(const std::unique_ptr& callingPackageName, int32_t uid, - const String16& packageName, int32_t opCode, const std::unique_ptr& featureId, - const String16& message) { - Parcel data, reply; - data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); - data.writeString16(callingPackageName); - data.writeInt32(uid); - data.writeString16(packageName); - data.writeInt32(opCode); - data.writeString16(featureId); - data.writeString16(message); - remote()->transact(NOTE_ASYNC_OP_TRANSACTION, data, &reply); - } - virtual bool shouldCollectNotes(int32_t opCode) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); @@ -193,7 +184,10 @@ status_t BnAppOpsService::onTransact( String16 packageName = data.readString16(); std::unique_ptr featureId; data.readString16(&featureId); - int32_t res = noteOperation(code, uid, packageName, featureId); + bool shouldCollectAsyncNotedOp = data.readInt32() == 1; + String16 message = data.readString16(); + int32_t res = noteOperation(code, uid, packageName, featureId, + shouldCollectAsyncNotedOp, message); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; @@ -207,8 +201,10 @@ status_t BnAppOpsService::onTransact( std::unique_ptr featureId; data.readString16(&featureId); bool startIfModeDefault = data.readInt32() == 1; + bool shouldCollectAsyncNotedOp = data.readInt32() == 1; + String16 message = data.readString16(); int32_t res = startOperation(token, code, uid, packageName, featureId, - startIfModeDefault); + startIfModeDefault, shouldCollectAsyncNotedOp, message); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; @@ -267,20 +263,6 @@ status_t BnAppOpsService::onTransact( reply->writeNoException(); return NO_ERROR; } break; - case NOTE_ASYNC_OP_TRANSACTION: { - CHECK_INTERFACE(IAppOpsService, data, reply); - std::unique_ptr callingPackageName; - data.readString16(&callingPackageName); - int32_t uid = data.readInt32(); - String16 packageName = data.readString16(); - int32_t opCode = data.readInt32(); - std::unique_ptr featureId; - data.readString16(&featureId); - String16 message = data.readString16(); - noteAsyncOp(callingPackageName, uid, packageName, opCode, featureId, message); - reply->writeNoException(); - return NO_ERROR; - } break; case SHOULD_COLLECT_NOTES_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); int32_t opCode = data.readInt32(); -- cgit v1.2.3-59-g8ed1b