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

Commit 314cf18e authored by Evan Severson's avatar Evan Severson Committed by Automerger Merge Worker
Browse files

Merge "Update mic/camera toggles api" into sc-dev am: bb483014

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14256431

Change-Id: Id2c2330e68cba6242cc9420ad59ecb8ed44530a8
parents a8bcd5ae bb483014
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -55,6 +55,22 @@ sp<hardware::ISensorPrivacyManager> SensorPrivacyManager::getService()
    return service;
}

bool SensorPrivacyManager::supportsSensorToggle(int sensor) {
    if (mSupportedCache.find(sensor) == mSupportedCache.end()) {
        sp<hardware::ISensorPrivacyManager> service = getService();
        if (service != nullptr) {
            bool result;
            service->supportsSensorToggle(sensor, &result);
            mSupportedCache[sensor] = result;
            return result;
        }
        // if the SensorPrivacyManager is not available then assume sensor privacy feature isn't
        // supported
        return false;
    }
    return mSupportedCache[sensor];
}

void SensorPrivacyManager::addSensorPrivacyListener(
        const sp<hardware::ISensorPrivacyListener>& listener)
{
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.hardware.ISensorPrivacyListener;

/** @hide */
interface ISensorPrivacyManager {
    boolean supportsSensorToggle(int sensor);

    void addSensorPrivacyListener(in ISensorPrivacyListener listener);

    void addIndividualSensorPrivacyListener(int userId, int sensor, in ISensorPrivacyListener listener);
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@

#include <utils/threads.h>

#include <unordered_map>

// ---------------------------------------------------------------------------
namespace android {

@@ -35,6 +37,7 @@ public:

    SensorPrivacyManager();

    bool supportsSensorToggle(int sensor);
    void addSensorPrivacyListener(const sp<hardware::ISensorPrivacyListener>& listener);
    status_t addIndividualSensorPrivacyListener(int userId, int sensor,
            const sp<hardware::ISensorPrivacyListener>& listener);
@@ -50,6 +53,8 @@ private:
    Mutex mLock;
    sp<hardware::ISensorPrivacyManager> mService;
    sp<hardware::ISensorPrivacyManager> getService();

    std::unordered_map<int, bool> mSupportedCache;
};