Revert^2 "Implement camera privacy allowlist."
9b2f9306c20d22cf131cc7d9d0eee30579e0d77c
Change-Id: I384077bc05d7685347783adb406f8b29800e3b3b
diff --git a/libs/sensorprivacy/Android.bp b/libs/sensorprivacy/Android.bp
index 00514c4..1e7e707 100644
--- a/libs/sensorprivacy/Android.bp
+++ b/libs/sensorprivacy/Android.bp
@@ -57,6 +57,7 @@
filegroup {
name: "libsensorprivacy_aidl",
srcs: [
+ "aidl/android/hardware/CameraPrivacyAllowlistEntry.aidl",
"aidl/android/hardware/ISensorPrivacyListener.aidl",
"aidl/android/hardware/ISensorPrivacyManager.aidl",
],
diff --git a/libs/sensorprivacy/SensorPrivacyManager.cpp b/libs/sensorprivacy/SensorPrivacyManager.cpp
index 57c74ee..fe93786 100644
--- a/libs/sensorprivacy/SensorPrivacyManager.cpp
+++ b/libs/sensorprivacy/SensorPrivacyManager.cpp
@@ -108,7 +108,7 @@
bool SensorPrivacyManager::isToggleSensorPrivacyEnabled(int sensor)
{
- sp<hardware::ISensorPrivacyManager> service = getService();
+ sp<hardware::ISensorPrivacyManager> service = getService();
if (service != nullptr) {
bool result;
service->isCombinedToggleSensorPrivacyEnabled(sensor, &result);
@@ -143,6 +143,39 @@
return UNKNOWN_ERROR;
}
+int SensorPrivacyManager::getToggleSensorPrivacyState(int toggleType, int sensor)
+{
+ sp<hardware::ISensorPrivacyManager> service = getService();
+ if (service != nullptr) {
+ int result;
+ service->getToggleSensorPrivacyState(toggleType, sensor, &result);
+ return result;
+ }
+ // if the SensorPrivacyManager is not available then assume sensor privacy is disabled
+ return DISABLED;
+}
+
+std::vector<hardware::CameraPrivacyAllowlistEntry>
+ SensorPrivacyManager::getCameraPrivacyAllowlist(){
+ sp<hardware::ISensorPrivacyManager> service = getService();
+ std::vector<hardware::CameraPrivacyAllowlistEntry> result;
+ if (service != nullptr) {
+ service->getCameraPrivacyAllowlist(&result);
+ return result;
+ }
+ return result;
+}
+
+bool SensorPrivacyManager::isCameraPrivacyEnabled(String16 packageName){
+ sp<hardware::ISensorPrivacyManager> service = getService();
+ if (service != nullptr) {
+ bool result;
+ service->isCameraPrivacyEnabled(packageName, &result);
+ return result;
+ }
+ return false;
+}
+
status_t SensorPrivacyManager::linkToDeath(const sp<IBinder::DeathRecipient>& recipient)
{
sp<hardware::ISensorPrivacyManager> service = getService();
diff --git a/libs/sensorprivacy/aidl/android/hardware/CameraPrivacyAllowlistEntry.aidl b/libs/sensorprivacy/aidl/android/hardware/CameraPrivacyAllowlistEntry.aidl
new file mode 100644
index 0000000..03e1537
--- /dev/null
+++ b/libs/sensorprivacy/aidl/android/hardware/CameraPrivacyAllowlistEntry.aidl
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2024, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware;
+
+parcelable CameraPrivacyAllowlistEntry {
+ String packageName;
+ boolean isMandatory;
+}
diff --git a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl
index eccd54c..694af00 100644
--- a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl
+++ b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyListener.aidl
@@ -21,4 +21,5 @@
*/
oneway interface ISensorPrivacyListener {
void onSensorPrivacyChanged(int toggleType, int sensor, boolean enabled);
+ void onSensorPrivacyStateChanged(int toggleType, int sensor, int state);
}
diff --git a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl
index 49a1e1e..b6bd39e 100644
--- a/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl
+++ b/libs/sensorprivacy/aidl/android/hardware/ISensorPrivacyManager.aidl
@@ -16,6 +16,7 @@
package android.hardware;
+import android.hardware.CameraPrivacyAllowlistEntry;
import android.hardware.ISensorPrivacyListener;
/** @hide */
@@ -41,4 +42,15 @@
void setToggleSensorPrivacy(int userId, int source, int sensor, boolean enable);
void setToggleSensorPrivacyForProfileGroup(int userId, int source, int sensor, boolean enable);
+
+ List<CameraPrivacyAllowlistEntry> getCameraPrivacyAllowlist();
+
+ int getToggleSensorPrivacyState(int toggleType, int sensor);
+
+ void setToggleSensorPrivacyState(int userId, int source, int sensor, int state);
+
+ void setToggleSensorPrivacyStateForProfileGroup(int userId, int source, int sensor, int state);
+
+ boolean isCameraPrivacyEnabled(String packageName);
+
}
diff --git a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h
index fc5fdf7..9e97e16 100644
--- a/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h
+++ b/libs/sensorprivacy/include/sensorprivacy/SensorPrivacyManager.h
@@ -32,12 +32,22 @@
public:
enum {
TOGGLE_SENSOR_MICROPHONE = 1,
- TOGGLE_SENSOR_CAMERA = 2
+ TOGGLE_SENSOR_CAMERA = 2,
+ TOGGLE_SENSOR_UNKNOWN = -1
};
enum {
TOGGLE_TYPE_SOFTWARE = 1,
- TOGGLE_TYPE_HARDWARE = 2
+ TOGGLE_TYPE_HARDWARE = 2,
+ TOGGLE_TYPE_UNKNOWN = -1
+ };
+
+ enum {
+ ENABLED = 1,
+ DISABLED = 2,
+ AUTOMOTIVE_DRIVER_ASSISTANCE_HELPFUL_APPS = 3,
+ AUTOMOTIVE_DRIVER_ASSISTANCE_REQUIRED_APPS = 4,
+ AUTOMOTIVE_DRIVER_ASSISTANCE_APPS = 5
};
SensorPrivacyManager();
@@ -51,6 +61,9 @@
bool isToggleSensorPrivacyEnabled(int sensor);
bool isToggleSensorPrivacyEnabled(int toggleType, int sensor);
status_t isToggleSensorPrivacyEnabled(int toggleType, int sensor, bool &result);
+ int getToggleSensorPrivacyState(int toggleType, int sensor);
+ std::vector<hardware::CameraPrivacyAllowlistEntry> getCameraPrivacyAllowlist();
+ bool isCameraPrivacyEnabled(String16 packageName);
status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient);
status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient);