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

Commit 4dde184c authored by Atneya Nair's avatar Atneya Nair
Browse files

[appops] Callsite fixup for AIDL IAppOpsCallback

Migrate IAppOpsCallback to the AIDL defined version, which is packaged
differently. Additionally, fix up incorrect call-site params.

Test: compiles
Test: atest CtsMediaAudioPermissionTestCases
Bug: 322692565
Flag: EXEMPT mechanical
Change-Id: If08e6613ae2e93a91090ab29086c727e4362846b
parent 68955b5f
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -26,14 +26,17 @@ namespace android::media::permission {

// Package name param is unreliable (can be empty), but we should only get valid events based on
// how we register the listener.
void DefaultAppOpsFacade::OpMonitor::opChanged(int32_t op, const String16&) {
    if (mOps.attributedOp != op && mOps.additionalOp != op) return;
binder::Status DefaultAppOpsFacade::OpMonitor::opChanged(int32_t op, int32_t, const String16&,
                                                         const String16&) {
    if (mOps.attributedOp != op && mOps.additionalOp != op) return binder::Status::ok();
    DefaultAppOpsFacade x{};
    const auto allowed = x.checkAccess(mAttr, mOps);
    std::lock_guard l_{mLock};
    if (mCb == nullptr) return;
    if (mCb != nullptr) {
        mCb(allowed);
    }
    return binder::Status::ok();
}

bool DefaultAppOpsFacade::startAccess(const ValidatedAttributionSourceState& attr_, Ops ops) {
    const AttributionSourceState& attr = attr_;
+4 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#pragma once

#include <android-base/thread_annotations.h>
#include <binder/IAppOpsCallback.h>
#include <com/android/internal/app/BnAppOpsCallback.h>
#include <cutils/android_filesystem_config.h>
#include <log/log.h>
#include <utils/RefBase.h>
@@ -166,12 +166,13 @@ class DefaultAppOpsFacade {
                                std::function<void(bool)> cb);
    void removeChangeCallback(uintptr_t);

    class OpMonitor : public BnAppOpsCallback {
    class OpMonitor : public com::android::internal::app::BnAppOpsCallback {
      public:
        OpMonitor(ValidatedAttributionSourceState attr, Ops ops, std::function<void(bool)> cb)
            : mAttr(std::move(attr)), mOps(ops), mCb(std::move(cb)) { }

        void opChanged(int32_t op, const String16& packageName) override;
        binder::Status opChanged(int32_t op, int32_t uid, const String16& packageName,
                                 const String16& persistenDeviceId) override;

        void stopListening() {
            std::lock_guard l_{mLock};
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
#pragma once

#include <android-base/thread_annotations.h>
#include <binder/IAppOpsCallback.h>
#include <cutils/android_filesystem_config.h>
#include <log/log.h>
#include <system/audio.h>
+3 −2
Original line number Diff line number Diff line
@@ -48,10 +48,11 @@ private:

    AppOpsManager mAppOpsManager;

    class PlayAudioOpCallback : public BnAppOpsCallback {
    class PlayAudioOpCallback : public com::android::internal::app::BnAppOpsCallback {
    public:
        explicit PlayAudioOpCallback(const wp<OpPlayAudioMonitor>& monitor);
        void opChanged(int32_t op, const String16& packageName) override;
        binder::Status opChanged(int32_t op, int32_t uid, const String16& packageName,
                                 const String16& persistentDeviceId) override;

    private:
        const wp<OpPlayAudioMonitor> mMonitor;
+4 −3
Original line number Diff line number Diff line
@@ -783,10 +783,10 @@ OpPlayAudioMonitor::PlayAudioOpCallback::PlayAudioOpCallback(
        const wp<OpPlayAudioMonitor>& monitor) : mMonitor(monitor)
{ }

void OpPlayAudioMonitor::PlayAudioOpCallback::opChanged(int32_t op,
            const String16& packageName) {
binder::Status OpPlayAudioMonitor::PlayAudioOpCallback::opChanged(int32_t op, int32_t,
            const String16& packageName, const String16&) {
    if (op != AppOpsManager::OP_PLAY_AUDIO) {
        return;
        return binder::Status::ok();
    }

    ALOGI("%s OP_PLAY_AUDIO callback received for %s", __func__, String8(packageName).c_str());
@@ -794,6 +794,7 @@ void OpPlayAudioMonitor::PlayAudioOpCallback::opChanged(int32_t op,
    if (monitor != NULL) {
        monitor->checkPlayAudioForUsage(/*doBroadcast=*/true);
    }
    return binder::Status::ok();
}

// ----------------------------------------------------------------------------
Loading