diff options
author | Evan Severson <evanseverson@google.com> | 2021-04-20 16:43:03 -0700 |
---|---|---|
committer | Evan Severson <evanseverson@google.com> | 2021-04-20 16:47:11 -0700 |
commit | 24ef7b15eae72c6d575de4144ecf8bb04fa27327 (patch) | |
tree | 790520f9b9c72838fd5d675b9ee9097bd48ef6b5 /libs/sensorprivacy/SensorPrivacyManager.cpp | |
parent | e4d7d43dd2a079e6ac89264c417fa58ce6ae8d7b (diff) |
Update mic/camera toggles api
Also put caching of the toggle support in the SensorPrivacyManager.
Test: Use the camera toggle
Bug: 181681375
Change-Id: I6f9a7fca500465b297ea87df47c5fdce7fc9d364
Diffstat (limited to 'libs/sensorprivacy/SensorPrivacyManager.cpp')
-rw-r--r-- | libs/sensorprivacy/SensorPrivacyManager.cpp | 16 |
1 files changed, 16 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) { |