summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorEvan Severson <evanseverson@google.com>2021-10-06 08:28:51 -0700
committerEvan Severson <evanseverson@google.com>2022-01-26 20:06:41 -0800
commit0cefec2d4f766082a653bd45bfb1e64b2ed8ffb1 (patch)
treed44d6ca16edaa26b0d6f52e24286650617f5764c /core/java/android
parentb628834dc38e71f477d2bd0fa9710635e3b71e0b (diff)
Refactor SensorPrivacyService to separate state from service
This refactoring will let us have alternative implementations for the state of microphone/camera. It also seperates the storage of the other feature that is known as the "Sensor mute" so that the reuse of this service doesn't get too convoluted. Also extract the persitable state from the state implementation so that alternative implementations can resuse the persistence code. Some smaller changes: * Start the sensor use dailog as user 0 always since system UI requires user 0 * Use SystemClock.elapsedRealTime() instead of network time since it's guaranteed to my monotonic. This will also change that intervals used in telemetry aren't going to measure time the device is powered off. Ignore-AOSP-First: New OWNERS file Test: atest CtsSensorPrivacyTestCases SensorPrivacyServiceMockingTest Bug: 200649586 Change-Id: I4c23c2509d7d1bdf49360fc9bbadb79ccd451dcc
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/hardware/SensorPrivacyManager.java71
1 files changed, 66 insertions, 5 deletions
diff --git a/core/java/android/hardware/SensorPrivacyManager.java b/core/java/android/hardware/SensorPrivacyManager.java
index 7074a2c8a60d..79153d77a85b 100644
--- a/core/java/android/hardware/SensorPrivacyManager.java
+++ b/core/java/android/hardware/SensorPrivacyManager.java
@@ -31,6 +31,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.service.SensorPrivacyIndividualEnabledSensorProto;
+import android.service.SensorPrivacySensorProto;
import android.service.SensorPrivacyToggleSourceProto;
import android.util.ArrayMap;
import android.util.Log;
@@ -75,7 +76,7 @@ public final class SensorPrivacyManager {
private final SparseArray<Boolean> mToggleSupportCache = new SparseArray<>();
/**
- * Individual sensors not listed in {@link Sensors}
+ * Sensor constants which are used in {@link SensorPrivacyManager}
*/
public static class Sensors {
@@ -84,12 +85,12 @@ public final class SensorPrivacyManager {
/**
* Constant for the microphone
*/
- public static final int MICROPHONE = SensorPrivacyIndividualEnabledSensorProto.MICROPHONE;
+ public static final int MICROPHONE = SensorPrivacySensorProto.MICROPHONE;
/**
* Constant for the camera
*/
- public static final int CAMERA = SensorPrivacyIndividualEnabledSensorProto.CAMERA;
+ public static final int CAMERA = SensorPrivacySensorProto.CAMERA;
/**
* Individual sensors not listed in {@link Sensors}
@@ -161,6 +162,68 @@ public final class SensorPrivacyManager {
}
/**
+ * Types of toggles which can exist for sensor privacy
+ * @hide
+ */
+ public static class ToggleTypes {
+ private ToggleTypes() {}
+
+ /**
+ * Constant for software toggle.
+ */
+ public static final int SOFTWARE = SensorPrivacyIndividualEnabledSensorProto.SOFTWARE;
+
+ /**
+ * Constant for hardware toggle.
+ */
+ public static final int HARDWARE = SensorPrivacyIndividualEnabledSensorProto.HARDWARE;
+
+ /**
+ * Types of toggles which can exist for sensor privacy
+ *
+ * @hide
+ */
+ @IntDef(value = {
+ SOFTWARE,
+ HARDWARE
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ToggleType {}
+
+ }
+
+ /**
+ * Types of state which can exist for the sensor privacy toggle
+ * @hide
+ */
+ public static class StateTypes {
+ private StateTypes() {}
+
+ /**
+ * Constant indicating privacy is enabled.
+ */
+ public static final int ENABLED = SensorPrivacyIndividualEnabledSensorProto.ENABLED;
+
+ /**
+ * Constant indicating privacy is disabled.
+ */
+ public static final int DISABLED = SensorPrivacyIndividualEnabledSensorProto.DISABLED;
+
+ /**
+ * Types of state which can exist for a sensor privacy toggle
+ *
+ * @hide
+ */
+ @IntDef(value = {
+ ENABLED,
+ DISABLED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface StateType {}
+
+ }
+
+ /**
* A class implementing this interface can register with the {@link
* android.hardware.SensorPrivacyManager} to receive notification when the sensor privacy
* state changes.
@@ -507,7 +570,6 @@ public final class SensorPrivacyManager {
/**
* Don't show dialogs to turn off sensor privacy for this package.
*
- * @param packageName Package name not to show dialogs for
* @param suppress Whether to suppress or re-enable.
*
* @hide
@@ -521,7 +583,6 @@ public final class SensorPrivacyManager {
/**
* Don't show dialogs to turn off sensor privacy for this package.
*
- * @param packageName Package name not to show dialogs for
* @param suppress Whether to suppress or re-enable.
* @param userId the user's id
*