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

Commit 4d9bf369 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "Native impl for ApOpManager.checkAudioOperation"

parents 6d69f91a 94a566d4
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -93,6 +93,14 @@ int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingP
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}

int32_t AppOpsManager::checkAudioOpNoThrow(int32_t op, int32_t usage, int32_t uid,
        const String16& callingPackage) {
    sp<IAppOpsService> service = getService();
    return service != nullptr
           ? service->checkAudioOperation(op, usage, uid, callingPackage)
           : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}

int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
    sp<IAppOpsService> service = getService();
    return service != nullptr
+27 −0
Original line number Diff line number Diff line
@@ -123,6 +123,22 @@ public:
        if (reply.readExceptionCode() != 0) return -1;
        return reply.readInt32();
    }

    virtual int32_t checkAudioOperation(int32_t code, int32_t usage,
            int32_t uid, const String16& packageName) {
        Parcel data, reply;
        data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor());
        data.writeInt32(code);
        data.writeInt32(usage);
        data.writeInt32(uid);
        data.writeString16(packageName);
        remote()->transact(CHECK_AUDIO_OPERATION_TRANSACTION, data, &reply);
        // fail on exception
        if (reply.readExceptionCode() != 0) {
            return MODE_ERRORED;
        }
        return reply.readInt32();
    }
};

IMPLEMENT_META_INTERFACE(AppOpsService, "com.android.internal.app.IAppOpsService");
@@ -209,6 +225,17 @@ status_t BnAppOpsService::onTransact(
            reply->writeInt32(opCode);
            return NO_ERROR;
        } break;
        case CHECK_AUDIO_OPERATION_TRANSACTION: {
            CHECK_INTERFACE(IAppOpsService, data, reply);
            const int32_t code = data.readInt32();
            const int32_t usage = data.readInt32();
            const int32_t uid = data.readInt32();
            const String16 packageName = data.readString16();
            const int32_t res = checkAudioOperation(code, usage, uid, packageName);
            reply->writeNoException();
            reply->writeInt32(res);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ public:
    AppOpsManager();

    int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage);
    int32_t checkAudioOpNoThrow(int32_t op, int32_t usage, int32_t uid,
            const String16& callingPackage);
    int32_t noteOp(int32_t op, int32_t uid, const String16& callingPackage);
    int32_t startOpNoThrow(int32_t op, int32_t uid, const String16& callingPackage,
            bool startIfModeDefault);
+3 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ public:
    virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
    virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0;
    virtual int32_t permissionToOpCode(const String16& permission) = 0;
    virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid,
            const String16& packageName) = 0;

    enum {
        CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
@@ -53,6 +55,7 @@ public:
        STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
        GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
        PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
        CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
    };

    enum {