Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c84335f5 authored by Stanislav Zholnin's avatar Stanislav Zholnin Committed by Android (Google) Code Review
Browse files

Merge "Add shouldCollectMessage parameter to AppOpsManager calls from native code."

parents e80116fe fce9ccce
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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;
+15 −10
Original line number Diff line number Diff line
@@ -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;
+3 −2
Original line number Diff line number Diff line
@@ -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,