Merge "Update BluetoothDevice SystemApi permissions and disallow passing a null pin to BluetoothDevice#setPin" am: 5f1daae19f

Change-Id: I4204ee9c10101d99fc8e4bad4ee44fc431f2cb9f
This commit is contained in:
Automerger Merge Worker
2020-03-04 19:28:11 +00:00
2 changed files with 22 additions and 26 deletions

View File

@@ -1389,23 +1389,23 @@ package android.bluetooth {
} }
public final class BluetoothDevice implements android.os.Parcelable { public final class BluetoothDevice implements android.os.Parcelable {
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean cancelBondProcess(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean cancelBondProcess();
method public boolean cancelPairing(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean cancelPairing();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getBatteryLevel(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public int getBatteryLevel();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getMessageAccessPermission(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public int getMessageAccessPermission();
method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public byte[] getMetadata(int); method @Nullable @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public byte[] getMetadata(int);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getPhonebookAccessPermission(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public int getPhonebookAccessPermission();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public int getSimAccessPermission(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public int getSimAccessPermission();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isBondingInitiatedLocally(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isBondingInitiatedLocally();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isConnected(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isConnected();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isEncrypted(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH) public boolean isEncrypted();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isInSilenceMode(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isInSilenceMode();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean removeBond(); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean removeBond();
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setAlias(@NonNull String); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setAlias(@NonNull String);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setMessageAccessPermission(int); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setMessageAccessPermission(int);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setMetadata(int, @NonNull byte[]); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setMetadata(int, @NonNull byte[]);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPhonebookAccessPermission(int); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPhonebookAccessPermission(int);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPin(@Nullable String); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setPin(@NonNull String);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setSilenceMode(boolean); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setSilenceMode(boolean);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setSimAccessPermission(int); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setSimAccessPermission(int);
field public static final int ACCESS_ALLOWED = 1; // 0x1 field public static final int ACCESS_ALLOWED = 1; // 0x1

View File

@@ -1139,7 +1139,7 @@ public final class BluetoothDevice implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public int getBatteryLevel() { public int getBatteryLevel() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1230,7 +1230,7 @@ public final class BluetoothDevice implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean isBondingInitiatedLocally() { public boolean isBondingInitiatedLocally() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1268,13 +1268,12 @@ public final class BluetoothDevice implements Parcelable {
/** /**
* Cancel an in-progress bonding request started with {@link #createBond}. * Cancel an in-progress bonding request started with {@link #createBond}.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
* *
* @return true on success, false on error * @return true on success, false on error
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean cancelBondProcess() { public boolean cancelBondProcess() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1297,13 +1296,12 @@ public final class BluetoothDevice implements Parcelable {
* <p>Delete the link key associated with the remote device, and * <p>Delete the link key associated with the remote device, and
* immediately terminate connections to that device that require * immediately terminate connections to that device that require
* authentication and encryption. * authentication and encryption.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
* *
* @return true on success, false on error * @return true on success, false on error
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean removeBond() { public boolean removeBond() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1347,13 +1345,12 @@ public final class BluetoothDevice implements Parcelable {
/** /**
* Returns whether there is an open connection to this device. * Returns whether there is an open connection to this device.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
* *
* @return True if there is at least one open connection to this device. * @return True if there is at least one open connection to this device.
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.BLUETOOTH) @RequiresPermission(Manifest.permission.BLUETOOTH)
public boolean isConnected() { public boolean isConnected() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1371,13 +1368,12 @@ public final class BluetoothDevice implements Parcelable {
/** /**
* Returns whether there is an open connection to this device * Returns whether there is an open connection to this device
* that has been encrypted. * that has been encrypted.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
* *
* @return True if there is at least one encrypted connection to this device. * @return True if there is at least one encrypted connection to this device.
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.BLUETOOTH) @RequiresPermission(Manifest.permission.BLUETOOTH)
public boolean isEncrypted() { public boolean isEncrypted() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1530,7 +1526,7 @@ public final class BluetoothDevice implements Parcelable {
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean setPin(@Nullable String pin) { public boolean setPin(@NonNull String pin) {
byte[] pinBytes = convertPinToBytes(pin); byte[] pinBytes = convertPinToBytes(pin);
if (pinBytes == null) { if (pinBytes == null) {
return false; return false;
@@ -1566,6 +1562,7 @@ public final class BluetoothDevice implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean cancelPairing() { public boolean cancelPairing() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1597,8 +1594,8 @@ public final class BluetoothDevice implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public int getPhonebookAccessPermission() { public @AccessPermission int getPhonebookAccessPermission() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
return ACCESS_UNKNOWN; return ACCESS_UNKNOWN;
@@ -1677,7 +1674,6 @@ public final class BluetoothDevice implements Parcelable {
/** /**
* Sets whether the phonebook access is allowed to this device. * Sets whether the phonebook access is allowed to this device.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
* *
* @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link
* #ACCESS_REJECTED}. * #ACCESS_REJECTED}.
@@ -1686,7 +1682,7 @@ public final class BluetoothDevice implements Parcelable {
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean setPhonebookAccessPermission(int value) { public boolean setPhonebookAccessPermission(@AccessPermission int value) {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
return false; return false;
@@ -1706,7 +1702,7 @@ public final class BluetoothDevice implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public @AccessPermission int getMessageAccessPermission() { public @AccessPermission int getMessageAccessPermission() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {
@@ -1753,7 +1749,7 @@ public final class BluetoothDevice implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public @AccessPermission int getSimAccessPermission() { public @AccessPermission int getSimAccessPermission() {
final IBluetooth service = sService; final IBluetooth service = sService;
if (service == null) { if (service == null) {