summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Evan Severson <evanseverson@google.com> 2022-01-27 10:43:40 -0800
committer Evan Severson <evanseverson@google.com> 2022-02-08 16:17:45 -0800
commit6f3e1c008cb4d6e061e611bc862a90ca1a3e9b44 (patch)
tree562658d99e590372c86d0090298403a793b69e27
parent4604a16639c8c49cd27e4287338a73186715078f (diff)
Sync native sensor privacy aidl with frameworks/base
The new calls no longer require user ids since that is managed internally in the sensor privacy service and calling services will receive updates when the state is changed or user is changed who has a different setting. Calling services should treat the state as a global setting. Also the new calls add support for hardware and software versions of controls. Test: Build Bug: 191745272 Change-Id: I08c8fa729b478773dc7f1fe7c2a5c22dcd5f0d4c
-rw-r--r--libs/sensorprivacy/SensorPrivacyManager.cpp32
-rw-r--r--libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl2
-rw-r--r--libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl14
-rw-r--r--libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h22
4 files changed, 44 insertions, 26 deletions
diff --git a/libs/sensorprivacy/SensorPrivacyManager.cpp b/libs/sensorprivacy/SensorPrivacyManager.cpp
index ef3ceda07c..2be98e7281 100644
--- a/libs/sensorprivacy/SensorPrivacyManager.cpp
+++ b/libs/sensorprivacy/SensorPrivacyManager.cpp
@@ -55,12 +55,12 @@ sp<hardware::ISensorPrivacyManager> SensorPrivacyManager::getService()
return service;
}
-bool SensorPrivacyManager::supportsSensorToggle(int sensor) {
+bool SensorPrivacyManager::supportsSensorToggle(int toggleType, int sensor) {
if (mSupportedCache.find(sensor) == mSupportedCache.end()) {
sp<hardware::ISensorPrivacyManager> service = getService();
if (service != nullptr) {
bool result;
- service->supportsSensorToggle(sensor, &result);
+ service->supportsSensorToggle(toggleType, sensor, &result);
mSupportedCache[sensor] = result;
return result;
}
@@ -80,12 +80,12 @@ void SensorPrivacyManager::addSensorPrivacyListener(
}
}
-status_t SensorPrivacyManager::addIndividualSensorPrivacyListener(int userId, int sensor,
+status_t SensorPrivacyManager::addToggleSensorPrivacyListener(
const sp<hardware::ISensorPrivacyListener>& listener)
{
sp<hardware::ISensorPrivacyManager> service = getService();
if (service != nullptr) {
- return service->addIndividualSensorPrivacyListener(userId, sensor, listener)
+ return service->addToggleSensorPrivacyListener(listener)
.transactionError();
}
return UNEXPECTED_NULL;
@@ -100,12 +100,12 @@ void SensorPrivacyManager::removeSensorPrivacyListener(
}
}
-void SensorPrivacyManager::removeIndividualSensorPrivacyListener(int sensor,
+void SensorPrivacyManager::removeToggleSensorPrivacyListener(
const sp<hardware::ISensorPrivacyListener>& listener)
{
sp<hardware::ISensorPrivacyManager> service = getService();
if (service != nullptr) {
- service->removeIndividualSensorPrivacyListener(sensor, listener);
+ service->removeToggleSensorPrivacyListener(listener);
}
}
@@ -121,24 +121,36 @@ bool SensorPrivacyManager::isSensorPrivacyEnabled()
return false;
}
-bool SensorPrivacyManager::isIndividualSensorPrivacyEnabled(int userId, int sensor)
+bool SensorPrivacyManager::isToggleSensorPrivacyEnabled(int sensor)
+{
+ sp<hardware::ISensorPrivacyManager> service = getService();
+ if (service != nullptr) {
+ bool result;
+ service->isCombinedToggleSensorPrivacyEnabled(sensor, &result);
+ return result;
+ }
+ // if the SensorPrivacyManager is not available then assume sensor privacy is disabled
+ return false;
+}
+
+bool SensorPrivacyManager::isToggleSensorPrivacyEnabled(int toggleType, int sensor)
{
sp<hardware::ISensorPrivacyManager> service = getService();
if (service != nullptr) {
bool result;
- service->isIndividualSensorPrivacyEnabled(userId, sensor, &result);
+ service->isToggleSensorPrivacyEnabled(toggleType, sensor, &result);
return result;
}
// if the SensorPrivacyManager is not available then assume sensor privacy is disabled
return false;
}
-status_t SensorPrivacyManager::isIndividualSensorPrivacyEnabled(int userId, int sensor,
+status_t SensorPrivacyManager::isToggleSensorPrivacyEnabled(int toggleType, int sensor,
bool &returnVal)
{
sp<hardware::ISensorPrivacyManager> service = getService();
if (service != nullptr) {
- binder::Status res = service->isIndividualSensorPrivacyEnabled(userId, sensor, &returnVal);
+ binder::Status res = service->isToggleSensorPrivacyEnabled(toggleType, sensor, &returnVal);
return res.transactionError();
}
// if the SensorPrivacyManager is not available then assume sensor privacy is disabled
diff --git a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl
index 58177d837f..eccd54c3eb 100644
--- a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl
+++ b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl
@@ -20,5 +20,5 @@ package android.hardware;
* @hide
*/
oneway interface ISensorPrivacyListener {
- void onSensorPrivacyChanged(boolean enabled);
+ void onSensorPrivacyChanged(int toggleType, int sensor, boolean enabled);
}
diff --git a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl
index 9564cba60d..49a1e1ea05 100644
--- a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl
+++ b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl
@@ -20,23 +20,25 @@ import android.hardware.ISensorPrivacyListener;
/** @hide */
interface ISensorPrivacyManager {
- boolean supportsSensorToggle(int sensor);
+ boolean supportsSensorToggle(int toggleType, int sensor);
void addSensorPrivacyListener(in ISensorPrivacyListener listener);
- void addIndividualSensorPrivacyListener(int userId, int sensor, in ISensorPrivacyListener listener);
+ void addToggleSensorPrivacyListener(in ISensorPrivacyListener listener);
void removeSensorPrivacyListener(in ISensorPrivacyListener listener);
- void removeIndividualSensorPrivacyListener(int sensor, in ISensorPrivacyListener listener);
+ void removeToggleSensorPrivacyListener(in ISensorPrivacyListener listener);
boolean isSensorPrivacyEnabled();
- boolean isIndividualSensorPrivacyEnabled(int userId, int sensor);
+ boolean isCombinedToggleSensorPrivacyEnabled(int sensor);
+
+ boolean isToggleSensorPrivacyEnabled(int toggleType, int sensor);
void setSensorPrivacy(boolean enable);
- void setIndividualSensorPrivacy(int userId, int source, int sensor, boolean enable);
+ void setToggleSensorPrivacy(int userId, int source, int sensor, boolean enable);
- void setIndividualSensorPrivacyForProfileGroup(int userId, int source, int sensor, boolean enable);
+ void setToggleSensorPrivacyForProfileGroup(int userId, int source, int sensor, boolean enable);
}
diff --git a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h
index af699d0b31..fc5fdf7900 100644
--- a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h
+++ b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h
@@ -31,22 +31,26 @@ class SensorPrivacyManager
{
public:
enum {
- INDIVIDUAL_SENSOR_MICROPHONE = 1,
- INDIVIDUAL_SENSOR_CAMERA = 2
+ TOGGLE_SENSOR_MICROPHONE = 1,
+ TOGGLE_SENSOR_CAMERA = 2
+ };
+
+ enum {
+ TOGGLE_TYPE_SOFTWARE = 1,
+ TOGGLE_TYPE_HARDWARE = 2
};
SensorPrivacyManager();
- bool supportsSensorToggle(int sensor);
+ bool supportsSensorToggle(int toggleType, int sensor);
void addSensorPrivacyListener(const sp<hardware::ISensorPrivacyListener>& listener);
- status_t addIndividualSensorPrivacyListener(int userId, int sensor,
- const sp<hardware::ISensorPrivacyListener>& listener);
+ status_t addToggleSensorPrivacyListener(const sp<hardware::ISensorPrivacyListener>& listener);
void removeSensorPrivacyListener(const sp<hardware::ISensorPrivacyListener>& listener);
- void removeIndividualSensorPrivacyListener(int sensor,
- const sp<hardware::ISensorPrivacyListener>& listener);
+ void removeToggleSensorPrivacyListener(const sp<hardware::ISensorPrivacyListener>& listener);
bool isSensorPrivacyEnabled();
- bool isIndividualSensorPrivacyEnabled(int userId, int sensor);
- status_t isIndividualSensorPrivacyEnabled(int userId, int sensor, bool &result);
+ bool isToggleSensorPrivacyEnabled(int sensor);
+ bool isToggleSensorPrivacyEnabled(int toggleType, int sensor);
+ status_t isToggleSensorPrivacyEnabled(int toggleType, int sensor, bool &result);
status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient);
status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient);