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

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

Merge "[appops] Callsite fixup for AIDL IAppOpsCallback" into main

parents eb9834cd 4dde184c
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line 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
// Package name param is unreliable (can be empty), but we should only get valid events based on
// how we register the listener.
// how we register the listener.
void DefaultAppOpsFacade::OpMonitor::opChanged(int32_t op, const String16&) {
binder::Status DefaultAppOpsFacade::OpMonitor::opChanged(int32_t op, int32_t, const String16&,
    if (mOps.attributedOp != op && mOps.additionalOp != op) return;
                                                         const String16&) {
    if (mOps.attributedOp != op && mOps.additionalOp != op) return binder::Status::ok();
    DefaultAppOpsFacade x{};
    DefaultAppOpsFacade x{};
    const auto allowed = x.checkAccess(mAttr, mOps);
    const auto allowed = x.checkAccess(mAttr, mOps);
    std::lock_guard l_{mLock};
    std::lock_guard l_{mLock};
    if (mCb == nullptr) return;
    if (mCb != nullptr) {
        mCb(allowed);
        mCb(allowed);
    }
    }
    return binder::Status::ok();
}


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


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


    class OpMonitor : public BnAppOpsCallback {
    class OpMonitor : public com::android::internal::app::BnAppOpsCallback {
      public:
      public:
        OpMonitor(ValidatedAttributionSourceState attr, Ops ops, std::function<void(bool)> cb)
        OpMonitor(ValidatedAttributionSourceState attr, Ops ops, std::function<void(bool)> cb)
            : mAttr(std::move(attr)), mOps(ops), mCb(std::move(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() {
        void stopListening() {
            std::lock_guard l_{mLock};
            std::lock_guard l_{mLock};
+0 −1
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
#pragma once
#pragma once


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


    AppOpsManager mAppOpsManager;
    AppOpsManager mAppOpsManager;


    class PlayAudioOpCallback : public BnAppOpsCallback {
    class PlayAudioOpCallback : public com::android::internal::app::BnAppOpsCallback {
    public:
    public:
        explicit PlayAudioOpCallback(const wp<OpPlayAudioMonitor>& monitor);
        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:
    private:
        const wp<OpPlayAudioMonitor> mMonitor;
        const wp<OpPlayAudioMonitor> mMonitor;
+4 −3
Original line number Original line Diff line number Diff line
@@ -783,10 +783,10 @@ OpPlayAudioMonitor::PlayAudioOpCallback::PlayAudioOpCallback(
        const wp<OpPlayAudioMonitor>& monitor) : mMonitor(monitor)
        const wp<OpPlayAudioMonitor>& monitor) : mMonitor(monitor)
{ }
{ }


void OpPlayAudioMonitor::PlayAudioOpCallback::opChanged(int32_t op,
binder::Status OpPlayAudioMonitor::PlayAudioOpCallback::opChanged(int32_t op, int32_t,
            const String16& packageName) {
            const String16& packageName, const String16&) {
    if (op != AppOpsManager::OP_PLAY_AUDIO) {
    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());
    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) {
    if (monitor != NULL) {
        monitor->checkPlayAudioForUsage(/*doBroadcast=*/true);
        monitor->checkPlayAudioForUsage(/*doBroadcast=*/true);
    }
    }
    return binder::Status::ok();
}
}


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