diff options
author | 2021-02-02 13:24:55 -0800 | |
---|---|---|
committer | 2021-02-02 14:47:39 -0800 | |
commit | 9287c50155a699e5048b87f8a62579636c442fab (patch) | |
tree | 9c2be79312232b62c6d444f46a742df2c2863206 | |
parent | dd5bfa93b0c6633b7372c87fc8d7a83a73a5cd1c (diff) |
Expose errors for some of the SensorPrivacyManager calls
TODO: remove the overload when the call from AudioPolicyService is
removed.
Test: Build
Bug: 162549680
Change-Id: Idfc5079b9fe7802e492d8ed82c0514f2b36875f8
-rw-r--r-- | libs/sensorprivacy/SensorPrivacyManager.cpp | 19 | ||||
-rw-r--r-- | libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/libs/sensorprivacy/SensorPrivacyManager.cpp b/libs/sensorprivacy/SensorPrivacyManager.cpp index 7bddee60a5..47144696f2 100644 --- a/libs/sensorprivacy/SensorPrivacyManager.cpp +++ b/libs/sensorprivacy/SensorPrivacyManager.cpp @@ -64,13 +64,15 @@ void SensorPrivacyManager::addSensorPrivacyListener( } } -void SensorPrivacyManager::addIndividualSensorPrivacyListener(int userId, int sensor, +status_t SensorPrivacyManager::addIndividualSensorPrivacyListener(int userId, int sensor, const sp<hardware::ISensorPrivacyListener>& listener) { sp<hardware::ISensorPrivacyManager> service = getService(); if (service != nullptr) { - service->addIndividualSensorPrivacyListener(userId, sensor, listener); + return service->addIndividualSensorPrivacyListener(userId, sensor, listener) + .transactionError(); } + return UNEXPECTED_NULL; } void SensorPrivacyManager::removeSensorPrivacyListener( @@ -106,6 +108,19 @@ bool SensorPrivacyManager::isIndividualSensorPrivacyEnabled(int userId, int sens return false; } +status_t SensorPrivacyManager::isIndividualSensorPrivacyEnabled(int userId, int sensor, + bool &returnVal) +{ + sp<hardware::ISensorPrivacyManager> service = getService(); + if (service != nullptr) { + binder::Status res = service->isIndividualSensorPrivacyEnabled(userId, sensor, &returnVal); + return res.transactionError(); + } + // if the SensorPrivacyManager is not available then assume sensor privacy is disabled + returnVal = false; + return UNKNOWN_ERROR; +} + status_t SensorPrivacyManager::linkToDeath(const sp<IBinder::DeathRecipient>& recipient) { sp<hardware::ISensorPrivacyManager> service = getService(); diff --git a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h index bd7c726c69..12778e16b6 100644 --- a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h +++ b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h @@ -36,11 +36,12 @@ public: SensorPrivacyManager(); void addSensorPrivacyListener(const sp<hardware::ISensorPrivacyListener>& listener); - void addIndividualSensorPrivacyListener(int userId, int sensor, + status_t addIndividualSensorPrivacyListener(int userId, int sensor, const sp<hardware::ISensorPrivacyListener>& listener); void removeSensorPrivacyListener(const sp<hardware::ISensorPrivacyListener>& listener); bool isSensorPrivacyEnabled(); bool isIndividualSensorPrivacyEnabled(int userId, int sensor); + status_t isIndividualSensorPrivacyEnabled(int userId, int sensor, bool &result); status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient); status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient); |