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

Commit 001bb2fb authored by Atneya Nair's avatar Atneya Nair Committed by Android (Google) Code Review
Browse files

Merge "Add AppOps overload to be able to watch foreground changes." into sc-dev

parents 24a7874b 130ff33d
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -146,6 +146,14 @@ void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName,
    }
    }
}
}


void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName, int32_t flags,
        const sp<IAppOpsCallback>& callback) {
    sp<IAppOpsService> service = getService();
    if (service != nullptr) {
        service->startWatchingModeWithFlags(op, packageName, flags, callback);
    }
}

void AppOpsManager::stopWatchingMode(const sp<IAppOpsCallback>& callback) {
void AppOpsManager::stopWatchingMode(const sp<IAppOpsCallback>& callback) {
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    if (service != nullptr) {
    if (service != nullptr) {
+11 −0
Original line number Original line Diff line number Diff line
@@ -166,6 +166,17 @@ public:
        }
        }
        return reply.readBool();
        return reply.readBool();
    }
    }

    virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName,
        int32_t flags, const sp<IAppOpsCallback>& callback) {
        Parcel data, reply;
        data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
        data.writeInt32(op);
        data.writeString16(packageName);
        data.writeInt32(flags);
        data.writeStrongBinder(IInterface::asBinder(callback));
        remote()->transact(START_WATCHING_MODE_WITH_FLAGS_TRANSACTION, data, &reply);
    }
};
};


IMPLEMENT_META_INTERFACE(AppOpsService, "com.android.internal.app.IAppOpsService")
IMPLEMENT_META_INTERFACE(AppOpsService, "com.android.internal.app.IAppOpsService")
+6 −0
Original line number Original line Diff line number Diff line
@@ -150,6 +150,10 @@ public:
        _NUM_OP = 116
        _NUM_OP = 116
    };
    };


    enum {
        WATCH_FOREGROUND_CHANGES = 1 << 0
    };

    AppOpsManager();
    AppOpsManager();


    int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage);
    int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage);
@@ -173,6 +177,8 @@ public:
            const std::optional<String16>& attributionTag);
            const std::optional<String16>& attributionTag);
    void startWatchingMode(int32_t op, const String16& packageName,
    void startWatchingMode(int32_t op, const String16& packageName,
            const sp<IAppOpsCallback>& callback);
            const sp<IAppOpsCallback>& callback);
    void startWatchingMode(int32_t op, const String16& packageName, int32_t flags,
            const sp<IAppOpsCallback>& callback);
    void stopWatchingMode(const sp<IAppOpsCallback>& callback);
    void stopWatchingMode(const sp<IAppOpsCallback>& callback);
    int32_t permissionToOpCode(const String16& permission);
    int32_t permissionToOpCode(const String16& permission);
    void setCameraAudioRestriction(int32_t mode);
    void setCameraAudioRestriction(int32_t mode);
+3 −0
Original line number Original line Diff line number Diff line
@@ -52,6 +52,8 @@ public:
            const String16& packageName) = 0;
            const String16& packageName) = 0;
    virtual void setCameraAudioRestriction(int32_t mode) = 0;
    virtual void setCameraAudioRestriction(int32_t mode) = 0;
    virtual bool shouldCollectNotes(int32_t opCode) = 0;
    virtual bool shouldCollectNotes(int32_t opCode) = 0;
    virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName,
            int32_t flags, const sp<IAppOpsCallback>& callback) = 0;


    enum {
    enum {
        CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
        CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
@@ -64,6 +66,7 @@ public:
        CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
        CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
        SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
        SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
        SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9,
        SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9,
        START_WATCHING_MODE_WITH_FLAGS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+10,
    };
    };


    enum {
    enum {