diff options
| author | 2021-04-22 16:38:37 +0000 | |
|---|---|---|
| committer | 2021-04-22 16:38:37 +0000 | |
| commit | bb483014610193308e66e67c421db19a8f1533b8 (patch) | |
| tree | a8bdb70b3dc7174ba6bdea9dee92c41bc5a83794 | |
| parent | 89d123463d51bc002f06051c80ffbed3ad994dfc (diff) | |
| parent | 24ef7b15eae72c6d575de4144ecf8bb04fa27327 (diff) | |
Merge "Update mic/camera toggles api" into sc-dev
3 files changed, 23 insertions, 0 deletions
diff --git a/libs/sensorprivacy/SensorPrivacyManager.cpp b/libs/sensorprivacy/SensorPrivacyManager.cpp index 47144696f2..b3537ce444 100644 --- a/libs/sensorprivacy/SensorPrivacyManager.cpp +++ b/libs/sensorprivacy/SensorPrivacyManager.cpp @@ -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) { diff --git a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl index 629b8c2093..c8ceeb89af 100644 --- a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl +++ b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl @@ -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); diff --git a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h index 12778e16b6..fb4cbe9d55 100644 --- a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h +++ b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h @@ -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; }; |