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
This commit is contained in:
Jeff Sharkey 2021-04-07 19:43:57 -06:00
parent a7e6b9481b
commit 6dcac06a84
17 changed files with 52 additions and 6 deletions

View File

@ -55,6 +55,7 @@ package android {
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";

View File

@ -1076,6 +1076,8 @@ public class AppOpsManager {
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 @@ public class AppOpsManager {
/** @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 class AppOpsManager {
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 @@ public class AppOpsManager {
// Nearby devices
OP_BLUETOOTH_SCAN,
OP_BLUETOOTH_CONNECT,
OP_BLUETOOTH_ADVERTISE,
OP_UWB_RANGING,
// APPOP PERMISSIONS
@ -1875,7 +1880,8 @@ public class AppOpsManager {
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 @@ public class AppOpsManager {
OPSTR_MANAGE_MEDIA,
OPSTR_BLUETOOTH_CONNECT,
OPSTR_UWB_RANGING,
OPSTR_ACTIVITY_RECOGNITION_SOURCE
OPSTR_ACTIVITY_RECOGNITION_SOURCE,
OPSTR_BLUETOOTH_ADVERTISE,
};
/**
@ -2116,7 +2123,8 @@ public class AppOpsManager {
"MANAGE_MEDIA",
"BLUETOOTH_CONNECT",
"UWB_RANGING",
"ACTIVITY_RECOGNITION_SOURCE"
"ACTIVITY_RECOGNITION_SOURCE",
"BLUETOOTH_ADVERTISE",
};
/**
@ -2239,6 +2247,7 @@ public class AppOpsManager {
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.UWB_RANGING,
null, // no permission for OP_ACTIVITY_RECOGNITION_SOURCE,
Manifest.permission.BLUETOOTH_ADVERTISE,
};
/**
@ -2361,6 +2370,7 @@ public class AppOpsManager {
null, // BLUETOOTH_CONNECT
null, // UWB_RANGING
null, // ACTIVITY_RECOGNITION_SOURCE
null, // BLUETOOTH_ADVERTISE
};
/**
@ -2481,7 +2491,8 @@ public class AppOpsManager {
null, // MANAGE_MEDIA
null, // BLUETOOTH_CONNECT
null, // UWB_RANGING
null // ACTIVITY_RECOGNITION_SOURCE
null, // ACTIVITY_RECOGNITION_SOURCE
null, // BLUETOOTH_ADVERTISE
};
/**
@ -2602,6 +2613,7 @@ public class AppOpsManager {
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 @@ public class AppOpsManager {
false, // BLUETOOTH_CONNECT
false, // UWB_RANGING
false, // ACTIVITY_RECOGNITION_SOURCE
false, // BLUETOOTH_ADVERTISE
};
/**

View File

@ -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"

View File

@ -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>

View File

@ -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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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" />

View File

@ -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. -->

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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" />

View File

@ -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" />

View File

@ -208,6 +208,7 @@ final class DefaultPermissionGrantPolicy {
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);
}

View File

@ -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"/>

View File

@ -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" />