diff options
-rw-r--r-- | libs/binder/AppOpsManager.cpp | 6 | ||||
-rw-r--r-- | libs/binder/IAppOpsService.cpp | 25 | ||||
-rw-r--r-- | libs/binder/include/binder/IAppOpsService.h | 5 |
3 files changed, 22 insertions, 14 deletions
diff --git a/libs/binder/AppOpsManager.cpp b/libs/binder/AppOpsManager.cpp index 1c6b49135d..de42f36d74 100644 --- a/libs/binder/AppOpsManager.cpp +++ b/libs/binder/AppOpsManager.cpp @@ -22,6 +22,7 @@ #include <utils/SystemClock.h> #include <sys/types.h> +#include <private/android_filesystem_config.h> #ifdef LOG_TAG #undef LOG_TAG @@ -100,7 +101,7 @@ int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPa sp<IAppOpsService> service = getService(); int32_t mode = service != nullptr ? service->noteOperation(op, uid, callingPackage, attributionTag, - shouldCollectNotes(op), message) + shouldCollectNotes(op), message, uid == AID_SYSTEM) : AppOpsManager::MODE_IGNORED; return mode; @@ -118,7 +119,8 @@ int32_t AppOpsManager::startOpNoThrow(int32_t op, int32_t uid, const String16& c sp<IAppOpsService> service = getService(); int32_t mode = service != nullptr ? service->startOperation(getClientId(), op, uid, callingPackage, - attributionTag, startIfModeDefault, shouldCollectNotes(op), message) + attributionTag, startIfModeDefault, shouldCollectNotes(op), message, + uid == AID_SYSTEM) : AppOpsManager::MODE_IGNORED; return mode; diff --git a/libs/binder/IAppOpsService.cpp b/libs/binder/IAppOpsService.cpp index cd78866624..ee0cd6206e 100644 --- a/libs/binder/IAppOpsService.cpp +++ b/libs/binder/IAppOpsService.cpp @@ -50,15 +50,16 @@ public: virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName, const std::optional<String16>& attributionTag, bool shouldCollectAsyncNotedOp, - const String16& message) { + const String16& message, bool shouldCollectMessage) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeInt32(code); data.writeInt32(uid); data.writeString16(packageName); data.writeString16(attributionTag); - data.writeInt32(shouldCollectAsyncNotedOp ? 1 : 0); + data.writeBool(shouldCollectAsyncNotedOp); data.writeString16(message); + data.writeBool(shouldCollectMessage); remote()->transact(NOTE_OPERATION_TRANSACTION, data, &reply); // fail on exception if (reply.readExceptionCode() != 0) return MODE_ERRORED; @@ -67,7 +68,8 @@ public: virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid, const String16& packageName, const std::optional<String16>& attributionTag, - bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message) { + bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message, + bool shouldCollectMessage) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeStrongBinder(token); @@ -75,9 +77,10 @@ public: data.writeInt32(uid); data.writeString16(packageName); data.writeString16(attributionTag); - data.writeInt32(startIfModeDefault ? 1 : 0); - data.writeInt32(shouldCollectAsyncNotedOp ? 1 : 0); + data.writeBool(startIfModeDefault); + data.writeBool(shouldCollectAsyncNotedOp); data.writeString16(message); + data.writeBool(shouldCollectMessage); remote()->transact(START_OPERATION_TRANSACTION, data, &reply); // fail on exception if (reply.readExceptionCode() != 0) return MODE_ERRORED; @@ -186,10 +189,11 @@ status_t BnAppOpsService::onTransact( String16 packageName = data.readString16(); std::optional<String16> attributionTag; data.readString16(&attributionTag); - bool shouldCollectAsyncNotedOp = data.readInt32() == 1; + bool shouldCollectAsyncNotedOp = data.readBool(); String16 message = data.readString16(); + bool shouldCollectMessage = data.readBool(); int32_t res = noteOperation(code, uid, packageName, attributionTag, - shouldCollectAsyncNotedOp, message); + shouldCollectAsyncNotedOp, message, shouldCollectMessage); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; @@ -202,11 +206,12 @@ status_t BnAppOpsService::onTransact( String16 packageName = data.readString16(); std::optional<String16> attributionTag; data.readString16(&attributionTag); - bool startIfModeDefault = data.readInt32() == 1; - bool shouldCollectAsyncNotedOp = data.readInt32() == 1; + bool startIfModeDefault = data.readBool(); + bool shouldCollectAsyncNotedOp = data.readBool(); String16 message = data.readString16(); + bool shouldCollectMessage = data.readBool(); int32_t res = startOperation(token, code, uid, packageName, attributionTag, - startIfModeDefault, shouldCollectAsyncNotedOp, message); + startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; diff --git a/libs/binder/include/binder/IAppOpsService.h b/libs/binder/include/binder/IAppOpsService.h index a4a20c8b10..de7d12f210 100644 --- a/libs/binder/include/binder/IAppOpsService.h +++ b/libs/binder/include/binder/IAppOpsService.h @@ -39,10 +39,11 @@ public: virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0; virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName, const std::optional<String16>& attributionTag, bool shouldCollectAsyncNotedOp, - const String16& message) = 0; + const String16& message, bool shouldCollectMessage) = 0; virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid, const String16& packageName, const std::optional<String16>& attributionTag, - bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message) = 0; + bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message, + bool shouldCollectMessage) = 0; virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid, const String16& packageName, const std::optional<String16>& attributionTag) = 0; virtual void startWatchingMode(int32_t op, const String16& packageName, |