diff options
| author | 2024-11-06 06:28:15 +0000 | |
|---|---|---|
| committer | 2024-11-06 06:28:15 +0000 | |
| commit | 4af2e065ad45ffdabe127935e637d33142647bd0 (patch) | |
| tree | 88f7a598abe1824400ad3611d3f01771ba3f2241 | |
| parent | 08d21f2789968d934a41eea326ce88b583ce1ac2 (diff) | |
| parent | 4f6cb65db6262f5b09853703fbcb06c888dd2fc5 (diff) | |
Merge "[Ranging] Add new permission for Android generic ranging feature" into main
| -rw-r--r-- | core/api/current.txt | 3 | ||||
| -rw-r--r-- | core/api/system-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/app/AppOpsManager.java | 20 | ||||
| -rw-r--r-- | core/java/android/app/ForegroundServiceTypePolicy.java | 1 | ||||
| -rw-r--r-- | core/java/android/content/pm/ServiceInfo.java | 2 | ||||
| -rw-r--r-- | core/java/android/permission/flags.aconfig | 9 | ||||
| -rw-r--r-- | core/res/Android.bp | 1 | ||||
| -rw-r--r-- | core/res/AndroidManifest.xml | 10 | ||||
| -rw-r--r-- | core/res/res/values/strings.xml | 5 | ||||
| -rw-r--r-- | packages/Shell/AndroidManifest.xml | 3 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java | 1 |
11 files changed, 54 insertions, 2 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 1e147cfb9131..faecbf1990b5 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -241,6 +241,7 @@ package android { field public static final String PROVIDE_REMOTE_CREDENTIALS = "android.permission.PROVIDE_REMOTE_CREDENTIALS"; field @FlaggedApi("android.security.aapm_api") public static final String QUERY_ADVANCED_PROTECTION_MODE = "android.permission.QUERY_ADVANCED_PROTECTION_MODE"; field public static final String QUERY_ALL_PACKAGES = "android.permission.QUERY_ALL_PACKAGES"; + field @FlaggedApi("android.permission.flags.ranging_permission_enabled") public static final String RANGING = "android.permission.RANGING"; field public static final String READ_ASSISTANT_APP_SEARCH_DATA = "android.permission.READ_ASSISTANT_APP_SEARCH_DATA"; field public static final String READ_BASIC_PHONE_STATE = "android.permission.READ_BASIC_PHONE_STATE"; field public static final String READ_CALENDAR = "android.permission.READ_CALENDAR"; @@ -13703,7 +13704,7 @@ package android.content.pm { field public static final int FLAG_STOP_WITH_TASK = 1; // 0x1 field public static final int FLAG_USE_APP_ZYGOTE = 8; // 0x8 field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_CAMERA}, anyOf={android.Manifest.permission.CAMERA}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_CAMERA = 64; // 0x40 - field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE}, anyOf={android.Manifest.permission.BLUETOOTH_ADVERTISE, android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.CHANGE_NETWORK_STATE, android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.CHANGE_WIFI_MULTICAST_STATE, android.Manifest.permission.NFC, android.Manifest.permission.TRANSMIT_IR, android.Manifest.permission.UWB_RANGING}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE = 16; // 0x10 + field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE}, anyOf={android.Manifest.permission.BLUETOOTH_ADVERTISE, android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.CHANGE_NETWORK_STATE, android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.CHANGE_WIFI_MULTICAST_STATE, android.Manifest.permission.NFC, android.Manifest.permission.TRANSMIT_IR, android.Manifest.permission.UWB_RANGING, android.Manifest.permission.RANGING}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE = 16; // 0x10 field @RequiresPermission(value=android.Manifest.permission.FOREGROUND_SERVICE_DATA_SYNC, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_DATA_SYNC = 1; // 0x1 field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_HEALTH}, anyOf={android.Manifest.permission.ACTIVITY_RECOGNITION, android.Manifest.permission.BODY_SENSORS, android.Manifest.permission.HIGH_SAMPLING_RATE_SENSORS}) public static final int FOREGROUND_SERVICE_TYPE_HEALTH = 256; // 0x100 field @RequiresPermission(allOf={android.Manifest.permission.FOREGROUND_SERVICE_LOCATION}, anyOf={android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION}, conditional=true) public static final int FOREGROUND_SERVICE_TYPE_LOCATION = 8; // 0x8 diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 26cb5621bab0..2a01ca082832 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -696,6 +696,7 @@ package android.app { field public static final String OPSTR_PLAY_AUDIO = "android:play_audio"; field public static final String OPSTR_POST_NOTIFICATION = "android:post_notification"; field public static final String OPSTR_PROJECT_MEDIA = "android:project_media"; + field @FlaggedApi("android.permission.flags.ranging_permission_enabled") public static final String OPSTR_RANGING = "android:ranging"; field @FlaggedApi("android.view.contentprotection.flags.rapid_clear_notifications_by_listener_app_op_enabled") public static final String OPSTR_RAPID_CLEAR_NOTIFICATIONS_BY_LISTENER = "android:rapid_clear_notifications_by_listener"; field public static final String OPSTR_READ_CLIPBOARD = "android:read_clipboard"; field @FlaggedApi("android.permission.flags.replace_body_sensor_permission_enabled") public static final String OPSTR_READ_HEART_RATE = "android:read_heart_rate"; diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 4c860fac9871..38c8583dd024 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -1614,9 +1614,16 @@ public class AppOpsManager { /** @hide Access to read skin temperature. */ public static final int OP_READ_SKIN_TEMPERATURE = AppOpEnums.APP_OP_READ_SKIN_TEMPERATURE; + /** + * Allows an app to range with nearby devices using any ranging technology available. + * + * @hide + */ + public static final int OP_RANGING = AppOpEnums.APP_OP_RANGING; + /** @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) - public static final int _NUM_OP = 151; + public static final int _NUM_OP = 152; /** * All app ops represented as strings. @@ -1771,6 +1778,7 @@ public class AppOpsManager { OPSTR_RECEIVE_SENSITIVE_NOTIFICATIONS, OPSTR_READ_HEART_RATE, OPSTR_READ_SKIN_TEMPERATURE, + OPSTR_RANGING, }) public @interface AppOpString {} @@ -2518,6 +2526,11 @@ public class AppOpsManager { @FlaggedApi(Flags.FLAG_PLATFORM_SKIN_TEMPERATURE_ENABLED) public static final String OPSTR_READ_SKIN_TEMPERATURE = "android:read_skin_temperature"; + /** @hide Access to ranging */ + @SystemApi + @FlaggedApi(Flags.FLAG_RANGING_PERMISSION_ENABLED) + public static final String OPSTR_RANGING = "android:ranging"; + /** {@link #sAppOpsToNote} not initialized yet for this op */ private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0; /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */ @@ -2589,6 +2602,7 @@ public class AppOpsManager { OP_BLUETOOTH_ADVERTISE, OP_UWB_RANGING, OP_NEARBY_WIFI_DEVICES, + Flags.rangingPermissionEnabled() ? OP_RANGING : OP_NONE, // Notifications OP_POST_NOTIFICATION, // Health @@ -3111,6 +3125,10 @@ public class AppOpsManager { Flags.platformSkinTemperatureEnabled() ? HealthPermissions.READ_SKIN_TEMPERATURE : null) .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(), + new AppOpInfo.Builder(OP_RANGING, OPSTR_RANGING, "RANGING") + .setPermission(Flags.rangingPermissionEnabled()? + Manifest.permission.RANGING : null) + .setDefaultMode(AppOpsManager.MODE_ALLOWED).build(), }; // The number of longs needed to form a full bitmask of app ops diff --git a/core/java/android/app/ForegroundServiceTypePolicy.java b/core/java/android/app/ForegroundServiceTypePolicy.java index d1e517bbd03c..16444dc5adde 100644 --- a/core/java/android/app/ForegroundServiceTypePolicy.java +++ b/core/java/android/app/ForegroundServiceTypePolicy.java @@ -398,6 +398,7 @@ public abstract class ForegroundServiceTypePolicy { new RegularPermission(Manifest.permission.NFC), new RegularPermission(Manifest.permission.TRANSMIT_IR), new RegularPermission(Manifest.permission.UWB_RANGING), + new RegularPermission(Manifest.permission.RANGING), new UsbDevicePermission(), new UsbAccessoryPermission(), }, false), diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java index 5b0cee75e591..4285b0a2b91a 100644 --- a/core/java/android/content/pm/ServiceInfo.java +++ b/core/java/android/content/pm/ServiceInfo.java @@ -251,6 +251,7 @@ public class ServiceInfo extends ComponentInfo * {@link android.Manifest.permission#NFC}, * {@link android.Manifest.permission#TRANSMIT_IR}, * {@link android.Manifest.permission#UWB_RANGING}, + * {@link android.Manifest.permission#RANGING}, * or has been granted the access to one of the attached USB devices/accessories. */ @RequiresPermission( @@ -267,6 +268,7 @@ public class ServiceInfo extends ComponentInfo Manifest.permission.NFC, Manifest.permission.TRANSMIT_IR, Manifest.permission.UWB_RANGING, + Manifest.permission.RANGING, }, conditional = true ) diff --git a/core/java/android/permission/flags.aconfig b/core/java/android/permission/flags.aconfig index bd6915d95b28..9e0d0e195a96 100644 --- a/core/java/android/permission/flags.aconfig +++ b/core/java/android/permission/flags.aconfig @@ -376,3 +376,12 @@ flag { description: "Enables SQlite for recording discrete and historical AppOp accesses" bug: "377584611" } + +flag { + name: "ranging_permission_enabled" + is_fixed_read_only: true + is_exported: true + namespace: "uwb" + description: "This fixed read-only flag is used to enable new ranging permission for all ranging use cases." + bug: "370977414" +} diff --git a/core/res/Android.bp b/core/res/Android.bp index f6ca8218926c..66c2e12f7cdf 100644 --- a/core/res/Android.bp +++ b/core/res/Android.bp @@ -171,6 +171,7 @@ android_app { "android.security.flags-aconfig", "com.android.hardware.input.input-aconfig", "aconfig_trade_in_mode_flags", + "ranging_aconfig_flags", ], } diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 0479318ad9ed..5913992004b8 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -2412,6 +2412,16 @@ android:label="@string/permlab_nearby_wifi_devices" android:protectionLevel="dangerous" /> + <!-- Required to be able to range to devices using generic ranging module. + @FlaggedApi("android.permission.flags.ranging_permission_enabled") + <p>Protection level: dangerous --> + <permission android:name="android.permission.RANGING" + android:permissionGroup="android.permission-group.UNDEFINED" + android:description="@string/permdesc_ranging" + android:label="@string/permlab_ranging" + android:protectionLevel="dangerous" + android:featureFlag="android.permission.flags.ranging_permission_enabled"/> + <!-- @SystemApi @TestApi Allows an application to suspend other apps, which will prevent the user from using them until they are unsuspended. @hide diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index e23e665e7335..c13fdb17dfe3 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1766,6 +1766,11 @@ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=140]--> <string name="permdesc_nearby_wifi_devices">Allows the app to advertise, connect, and determine the relative position of nearby Wi\u2011Fi devices</string> + <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=50]--> + <string name="permlab_ranging">determine relative position between nearby devices</string> + <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=120]--> + <string name="permdesc_ranging">Allow the app to determine relative position between nearby devices</string> + <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permlab_preferredPaymentInfo">Preferred NFC Payment Service Information</string> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml index 1919572ff571..2c8c261fa8f8 100644 --- a/packages/Shell/AndroidManifest.xml +++ b/packages/Shell/AndroidManifest.xml @@ -715,6 +715,9 @@ <uses-permission android:name="android.permission.UWB_PRIVILEGED" /> <uses-permission android:name="android.permission.UWB_RANGING" /> + <!-- Permission required for CTS test - CtsRangingTestCases --> + <uses-permission android:name="android.permission.RANGING" /> + <!-- Permission required for CTS test - CtsAlarmManagerTestCases --> <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" /> diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java index 07fd1cb544f6..acf62dcdd1ce 100644 --- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java +++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java @@ -235,6 +235,7 @@ final class DefaultPermissionGrantPolicy { NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_SCAN); NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.UWB_RANGING); NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.NEARBY_WIFI_DEVICES); + NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.RANGING); } private static final Set<String> NOTIFICATION_PERMISSIONS = new ArraySet<>(); |