Loading libs/sensorprivacy/SensorPrivacyManager.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); Loading libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h +5 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <utils/threads.h> #include <unordered_map> // --------------------------------------------------------------------------- namespace android { Loading @@ -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); Loading @@ -50,6 +53,8 @@ private: Mutex mLock; sp<hardware::ISensorPrivacyManager> mService; sp<hardware::ISensorPrivacyManager> getService(); std::unordered_map<int, bool> mSupportedCache; }; Loading Loading
libs/sensorprivacy/SensorPrivacyManager.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading
libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h +5 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ #include <utils/threads.h> #include <unordered_map> // --------------------------------------------------------------------------- namespace android { Loading @@ -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); Loading @@ -50,6 +53,8 @@ private: Mutex mLock; sp<hardware::ISensorPrivacyManager> mService; sp<hardware::ISensorPrivacyManager> getService(); std::unordered_map<int, bool> mSupportedCache; }; Loading