New BLUETOOTH_ADVERTISE manifest permission.
This change is part of defining a distinct BLUETOOTH_ADVERTISE
permission to guard the BluetoothLeAdvertiser APIs, since that's a
distinct enough of an operation from SCAN and CONNECT. It'll
continue to be covered under the general "Nearby devices" runtime
permission group.
Bug: 181813006
Test: atest CtsPermission2TestCases
Test: atest CtsPermission3TestCases
Change-Id: I8b62e4d625df1e201f12a73025cd29c431feea79
diff --git a/core/api/current.txt b/core/api/current.txt
index 8a642e6..6844a90 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -55,6 +55,7 @@
field public static final String BIND_WALLPAPER = "android.permission.BIND_WALLPAPER";
field public static final String BLUETOOTH = "android.permission.BLUETOOTH";
field public static final String BLUETOOTH_ADMIN = "android.permission.BLUETOOTH_ADMIN";
+ field public static final String BLUETOOTH_ADVERTISE = "android.permission.BLUETOOTH_ADVERTISE";
field public static final String BLUETOOTH_CONNECT = "android.permission.BLUETOOTH_CONNECT";
field public static final String BLUETOOTH_PRIVILEGED = "android.permission.BLUETOOTH_PRIVILEGED";
field public static final String BLUETOOTH_SCAN = "android.permission.BLUETOOTH_SCAN";
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 8e2626a..df9530f 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -1076,6 +1076,8 @@
public static final int OP_BLUETOOTH_SCAN = AppProtoEnums.APP_OP_BLUETOOTH_SCAN;
/** @hide */
public static final int OP_BLUETOOTH_CONNECT = AppProtoEnums.APP_OP_BLUETOOTH_CONNECT;
+ /** @hide */
+ public static final int OP_BLUETOOTH_ADVERTISE = AppProtoEnums.APP_OP_BLUETOOTH_ADVERTISE;
/** @hide Use the BiometricPrompt/BiometricManager APIs. */
public static final int OP_USE_BIOMETRIC = AppProtoEnums.APP_OP_USE_BIOMETRIC;
/** @hide Physical activity recognition. */
@@ -1237,7 +1239,7 @@
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- public static final int _NUM_OP = 114;
+ public static final int _NUM_OP = 115;
/** Access to coarse location information. */
public static final String OPSTR_COARSE_LOCATION = "android:coarse_location";
@@ -1483,6 +1485,8 @@
public static final String OPSTR_BLUETOOTH_SCAN = "android:bluetooth_scan";
/** @hide */
public static final String OPSTR_BLUETOOTH_CONNECT = "android:bluetooth_connect";
+ /** @hide */
+ public static final String OPSTR_BLUETOOTH_ADVERTISE = "android:bluetooth_advertise";
/** @hide Use the BiometricPrompt/BiometricManager APIs. */
public static final String OPSTR_USE_BIOMETRIC = "android:use_biometric";
@@ -1733,6 +1737,7 @@
// Nearby devices
OP_BLUETOOTH_SCAN,
OP_BLUETOOTH_CONNECT,
+ OP_BLUETOOTH_ADVERTISE,
OP_UWB_RANGING,
// APPOP PERMISSIONS
@@ -1875,7 +1880,8 @@
OP_MANAGE_MEDIA, // MANAGE_MEDIA
OP_BLUETOOTH_CONNECT, // OP_BLUETOOTH_CONNECT
OP_UWB_RANGING, // OP_UWB_RANGING
- OP_ACTIVITY_RECOGNITION_SOURCE // OP_ACTIVITY_RECOGNITION_SOURCE
+ OP_ACTIVITY_RECOGNITION_SOURCE, // OP_ACTIVITY_RECOGNITION_SOURCE
+ OP_BLUETOOTH_ADVERTISE, // OP_BLUETOOTH_ADVERTISE
};
/**
@@ -1995,7 +2001,8 @@
OPSTR_MANAGE_MEDIA,
OPSTR_BLUETOOTH_CONNECT,
OPSTR_UWB_RANGING,
- OPSTR_ACTIVITY_RECOGNITION_SOURCE
+ OPSTR_ACTIVITY_RECOGNITION_SOURCE,
+ OPSTR_BLUETOOTH_ADVERTISE,
};
/**
@@ -2116,7 +2123,8 @@
"MANAGE_MEDIA",
"BLUETOOTH_CONNECT",
"UWB_RANGING",
- "ACTIVITY_RECOGNITION_SOURCE"
+ "ACTIVITY_RECOGNITION_SOURCE",
+ "BLUETOOTH_ADVERTISE",
};
/**
@@ -2239,6 +2247,7 @@
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.UWB_RANGING,
null, // no permission for OP_ACTIVITY_RECOGNITION_SOURCE,
+ Manifest.permission.BLUETOOTH_ADVERTISE,
};
/**
@@ -2361,6 +2370,7 @@
null, // BLUETOOTH_CONNECT
null, // UWB_RANGING
null, // ACTIVITY_RECOGNITION_SOURCE
+ null, // BLUETOOTH_ADVERTISE
};
/**
@@ -2481,7 +2491,8 @@
null, // MANAGE_MEDIA
null, // BLUETOOTH_CONNECT
null, // UWB_RANGING
- null // ACTIVITY_RECOGNITION_SOURCE
+ null, // ACTIVITY_RECOGNITION_SOURCE
+ null, // BLUETOOTH_ADVERTISE
};
/**
@@ -2602,6 +2613,7 @@
AppOpsManager.MODE_ALLOWED, // BLUETOOTH_CONNECT
AppOpsManager.MODE_ALLOWED, // UWB_RANGING
AppOpsManager.MODE_ALLOWED, // ACTIVITY_RECOGNITION_SOURCE
+ AppOpsManager.MODE_ALLOWED, // BLUETOOTH_ADVERTISE
};
/**
@@ -2726,6 +2738,7 @@
false, // BLUETOOTH_CONNECT
false, // UWB_RANGING
false, // ACTIVITY_RECOGNITION_SOURCE
+ false, // BLUETOOTH_ADVERTISE
};
/**
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 58abfeb..7d1ac95 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1953,7 +1953,15 @@
android:label="@string/permlab_bluetooth_connect"
android:protectionLevel="dangerous" />
- <!-- Required to be able to range to devices using uwb.
+ <!-- Required to be able to advertise to nearby Bluetooth devices.
+ <p>Protection level: dangerous -->
+ <permission android:name="android.permission.BLUETOOTH_ADVERTISE"
+ android:permissionGroup="android.permission-group.UNDEFINED"
+ android:description="@string/permdesc_bluetooth_advertise"
+ android:label="@string/permlab_bluetooth_advertise"
+ android:protectionLevel="dangerous" />
+
+ <!-- Required to be able to range to devices using ultra-wideband.
<p>Protection level: dangerous -->
<permission android:name="android.permission.UWB_RANGING"
android:permissionGroup="android.permission-group.UNDEFINED"
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 90e9c09..5521798 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1484,6 +1484,10 @@
<string name="permlab_bluetooth_connect">connect to paired Bluetooth 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_bluetooth_connect" product="default">Allows the app to connect to paired Bluetooth 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_bluetooth_advertise">advertise to nearby Bluetooth 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_bluetooth_advertise" product="default">Allows the app to advertise to nearby Bluetooth 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_uwb_ranging">determine relative position between nearby Ultra-Wideband devices</string>
diff --git a/core/tests/bluetoothtests/AndroidManifest.xml b/core/tests/bluetoothtests/AndroidManifest.xml
index f8c69ac..75583d5 100644
--- a/core/tests/bluetoothtests/AndroidManifest.xml
+++ b/core/tests/bluetoothtests/AndroidManifest.xml
@@ -20,6 +20,7 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
diff --git a/core/tests/coretests/AndroidManifest.xml b/core/tests/coretests/AndroidManifest.xml
index 408624a..520d2f1 100644
--- a/core/tests/coretests/AndroidManifest.xml
+++ b/core/tests/coretests/AndroidManifest.xml
@@ -44,6 +44,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
diff --git a/core/tests/hosttests/test-apps/ExternalLocAllPermsTestApp/AndroidManifest.xml b/core/tests/hosttests/test-apps/ExternalLocAllPermsTestApp/AndroidManifest.xml
index b3b34ef..79beca76 100644
--- a/core/tests/hosttests/test-apps/ExternalLocAllPermsTestApp/AndroidManifest.xml
+++ b/core/tests/hosttests/test-apps/ExternalLocAllPermsTestApp/AndroidManifest.xml
@@ -32,6 +32,7 @@
<uses-permission android:name="android.permission.BIND_INPUT_METHOD" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BRICK" />
diff --git a/core/tests/hosttests/test-apps/ExternalSharedPermsBT/AndroidManifest.xml b/core/tests/hosttests/test-apps/ExternalSharedPermsBT/AndroidManifest.xml
index 42d9407..6d14001 100644
--- a/core/tests/hosttests/test-apps/ExternalSharedPermsBT/AndroidManifest.xml
+++ b/core/tests/hosttests/test-apps/ExternalSharedPermsBT/AndroidManifest.xml
@@ -22,6 +22,7 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index 3213390..1c11f95 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -236,6 +236,10 @@
targetSdk="31">
<new-permission name="android.permission.BLUETOOTH_CONNECT" />
</split-permission>
+ <split-permission name="android.permission.BLUETOOTH"
+ targetSdk="31">
+ <new-permission name="android.permission.BLUETOOTH_ADVERTISE" />
+ </split-permission>
<split-permission name="android.permission.BLUETOOTH_ADMIN"
targetSdk="31">
<new-permission name="android.permission.BLUETOOTH_SCAN" />
@@ -244,6 +248,10 @@
targetSdk="31">
<new-permission name="android.permission.BLUETOOTH_CONNECT" />
</split-permission>
+ <split-permission name="android.permission.BLUETOOTH_ADMIN"
+ targetSdk="31">
+ <new-permission name="android.permission.BLUETOOTH_ADVERTISE" />
+ </split-permission>
<!-- This is a list of all the libraries available for application
code to link against. -->
diff --git a/media/packages/BluetoothMidiService/AndroidManifest.xml b/media/packages/BluetoothMidiService/AndroidManifest.xml
index 3794ccd..03606ba 100644
--- a/media/packages/BluetoothMidiService/AndroidManifest.xml
+++ b/media/packages/BluetoothMidiService/AndroidManifest.xml
@@ -28,6 +28,7 @@
android:required="true"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
diff --git a/media/tests/ScoAudioTest/AndroidManifest.xml b/media/tests/ScoAudioTest/AndroidManifest.xml
index 5af77ee..ea836e0 100644
--- a/media/tests/ScoAudioTest/AndroidManifest.xml
+++ b/media/tests/ScoAudioTest/AndroidManifest.xml
@@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.BROADCAST_STICKY"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
diff --git a/packages/CompanionDeviceManager/AndroidManifest.xml b/packages/CompanionDeviceManager/AndroidManifest.xml
index d36836c..c5926a5 100644
--- a/packages/CompanionDeviceManager/AndroidManifest.xml
+++ b/packages/CompanionDeviceManager/AndroidManifest.xml
@@ -25,6 +25,7 @@
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
diff --git a/packages/Shell/AndroidManifest.xml b/packages/Shell/AndroidManifest.xml
index 16937b7..820b180 100644
--- a/packages/Shell/AndroidManifest.xml
+++ b/packages/Shell/AndroidManifest.xml
@@ -49,6 +49,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 88d7710..dc359a7 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -62,6 +62,7 @@
<!-- Networking and telephony -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
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 9bc9d9f..34003c7 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -208,6 +208,7 @@
private static final Set<String> NEARBY_DEVICES_PERMISSIONS = new ArraySet<>();
static {
+ NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_ADVERTISE);
NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_CONNECT);
NEARBY_DEVICES_PERMISSIONS.add(Manifest.permission.BLUETOOTH_SCAN);
}
diff --git a/services/tests/servicestests/AndroidManifest.xml b/services/tests/servicestests/AndroidManifest.xml
index d1cd7cd..bcb2cf8 100644
--- a/services/tests/servicestests/AndroidManifest.xml
+++ b/services/tests/servicestests/AndroidManifest.xml
@@ -76,6 +76,7 @@
<uses-permission android:name="android.permission.HARDWARE_TEST"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>
diff --git a/tests/UsesFeature2Test/AndroidManifest.xml b/tests/UsesFeature2Test/AndroidManifest.xml
index 1f1a909..a0ea45a 100644
--- a/tests/UsesFeature2Test/AndroidManifest.xml
+++ b/tests/UsesFeature2Test/AndroidManifest.xml
@@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+ <uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />