From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MSe1969 Date: Fri, 15 Mar 2019 22:05:36 +0100 Subject: [PATCH] AppOps/PrivacyGuard: New Sensor checks [base] Add two AppOps for sensor access: - OP_MOTION_SENSORS (default: allow, strict) - OP_OTHER_SENSORS (default: allow) Change-Id: Id12b91720f1e02ea5ca606ecefb30121d19b92bb --- core/java/android/app/AppOpsManager.java | 35 ++++++++++++++++++++++-- core/res/res/values-de/cm_strings.xml | 2 ++ core/res/res/values-fr/cm_strings.xml | 2 ++ core/res/res/values/cm_strings.xml | 2 ++ core/res/res/values/lineage_arrays.xml | 4 +++ 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 5b763e50c38f..fef17859af8c 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -371,8 +371,12 @@ public class AppOpsManager { public static final int OP_DATA_CONNECT_CHANGE = 81; /** @hide SU access */ public static final int OP_SU = 82; + /** @hide Motion Sensors */ + public static final int OP_MOTION_SENSORS = 83; + /** @hide Other Sensors */ + public static final int OP_OTHER_SENSORS = 84; /** @hide */ - public static final int _NUM_OP = 83; + public static final int _NUM_OP = 85; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = "android:coarse_location"; @@ -628,6 +632,11 @@ public class AppOpsManager { /** @hide */ public static final String OPSTR_SU = "android:su"; + public static final String OPSTR_MOTION_SENSORS = + "android:motion_sensors"; + public static final String OPSTR_OTHER_SENSORS = + "android:other_sensors"; + // Warning: If an permission is added here it also has to be added to // com.android.packageinstaller.permission.utils.EventLogger private static final int[] RUNTIME_AND_APPOP_PERMISSIONS_OPS = { @@ -676,7 +685,9 @@ public class AppOpsManager { OP_WRITE_SETTINGS, OP_REQUEST_INSTALL_PACKAGES, OP_START_FOREGROUND, - OP_SU + OP_SU, + OP_MOTION_SENSORS, + OP_OTHER_SENSORS }; /** @@ -771,6 +782,8 @@ public class AppOpsManager { OP_NFC_CHANGE, // NFC_CHANGE OP_DATA_CONNECT_CHANGE, // DATA_CONNECT_CHANGE OP_SU, // SU + OP_MOTION_SENSORS, // MOTION_SENSORS + OP_OTHER_SENSORS // OTHER_SENSORS }; /** @@ -860,6 +873,8 @@ public class AppOpsManager { OPSTR_NFC_CHANGE, OPSTR_DATA_CONNECT_CHANGE, OPSTR_SU, + OPSTR_MOTION_SENSORS, + OPSTR_OTHER_SENSORS, }; /** @@ -950,6 +965,8 @@ public class AppOpsManager { "NFC_CHANGE", "DATA_CONNECT_CHANGE", "SU", + "MOTION_SENSORS", + "OTHER_SENSORS", }; /** @@ -1040,6 +1057,8 @@ public class AppOpsManager { Manifest.permission.NFC, null, null, // no permission for OP_SU + null, // no permission for OP_MOTION_SENSORS + null, // no permission for OP_OTHER_SENSORS }; /** @@ -1131,6 +1150,8 @@ public class AppOpsManager { null, // NFC_CHANGE null, // DATA_CONNECT_CHANGE UserManager.DISALLOW_SU, // SU TODO: this should really be investigated. + null, //MOTION_SENSORS + null, //OTHER_SENSORS }; /** @@ -1221,6 +1242,8 @@ public class AppOpsManager { true, // NFC_CHANGE true, // DATA_CONNECT_CHANGE false, // SU + false, //MOTION_SENSORS + false, //OTHER_SENSORS }; /** @@ -1310,6 +1333,8 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_NFC_CHANGE AppOpsManager.MODE_ALLOWED, // OP_DATA_CONNECT_CHANGE AppOpsManager.MODE_ASK, // OP_SU + AppOpsManager.MODE_ALLOWED, // OP_MOTION_SENSORS + AppOpsManager.MODE_ALLOWED, // OP_OTHER_SENSORS }; /** @@ -1400,6 +1425,8 @@ public class AppOpsManager { AppOpsManager.MODE_ASK, // OP_NFC_CHANGE AppOpsManager.MODE_ASK, // OP_DATA_CONNECT_CHANGE AppOpsManager.MODE_ASK, // OP_SU + AppOpsManager.MODE_ALLOWED, // OP_MOTION_SENSORS + AppOpsManager.MODE_ALLOWED, // OP_OTHER_SENSORS }; /** @@ -1489,6 +1516,8 @@ public class AppOpsManager { true, // NFC_CHANGE true, // DATA_CONNECT_CHANGE true, // SU + true, // OP_MOTION_SENSORS + false, // OP_OTHER_SENSORS }; /** @@ -1582,6 +1611,8 @@ public class AppOpsManager { false, // OP_NFC_CHANGE false, // OP_DATA_CONNECT_CHANGE false, // OP_SU + false, // OP_MOTION_SENSORS + false, // OP_OTHER_SENSORS }; /** diff --git a/core/res/res/values-de/cm_strings.xml b/core/res/res/values-de/cm_strings.xml index 8248b4d50731..e0f1b79882f7 100644 --- a/core/res/res/values-de/cm_strings.xml +++ b/core/res/res/values-de/cm_strings.xml @@ -51,7 +51,9 @@ die Zwischenablage zu ändern Kontakte zu ändern Einstellungen zu ändern + Bewegungssensoren zu nutzen das Mikrofon zu aktivieren/deaktivieren + sonstige Sensoren zu nutzen Anrufe zu beantworten Bild im Bild zu verwenden Audio wiederzugeben diff --git a/core/res/res/values-fr/cm_strings.xml b/core/res/res/values-fr/cm_strings.xml index 38cfd54ec910..027f79c607c2 100644 --- a/core/res/res/values-fr/cm_strings.xml +++ b/core/res/res/values-fr/cm_strings.xml @@ -51,7 +51,9 @@ modifier le presse-papiers mettre à jour vos contacts mettre à jour les paramètres du système + utiliser les capteurs de mouvement activer/désactiver le microphone + utiliser d\'autres capteurs répondre aux appels téléphoniques utiliser le mode Picture-in-Picture lecture audio diff --git a/core/res/res/values/cm_strings.xml b/core/res/res/values/cm_strings.xml index 301131e2663d..5939cae77b8e 100644 --- a/core/res/res/values/cm_strings.xml +++ b/core/res/res/values/cm_strings.xml @@ -57,7 +57,9 @@ modify the clipboard update your contacts update system settings + use the motion sensors mute/unmute the microphone + use other sensors answer phone calls use picture in picture play audio diff --git a/core/res/res/values/lineage_arrays.xml b/core/res/res/values/lineage_arrays.xml index 58567d1c8bd1..11a7d99b8d48 100644 --- a/core/res/res/values/lineage_arrays.xml +++ b/core/res/res/values/lineage_arrays.xml @@ -184,6 +184,10 @@ @string/app_ops_toggle_mobile_data @string/app_ops_su + + @string/app_ops_motion_sensors + + @string/app_ops_other_sensors