diff options
| author | Rahul Sabnis <rahulsabnis@google.com> | 2020-03-02 16:41:20 -0800 |
|---|---|---|
| committer | Rahul Sabnis <rahulsabnis@google.com> | 2020-03-03 11:29:58 -0800 |
| commit | 6a8b2392a0407704c3885cc299d0bc7267c887c7 (patch) | |
| tree | bc5e0845e464f7a67df08a8018c065ced9025c88 /framework/java/android/bluetooth/BluetoothDevice.java | |
| parent | d012f6a977b63df3bd2e20e3957f4628dab0cc7e (diff) | |
Update BluetoothDevice SystemApi permissions and disallow passing a null
pin to BluetoothDevice#setPin
Bug: 147428695
Test: Manual
Merged-In: I74613d61420babecf5f1976fe33a2e1a729b71a1
Change-Id: I74613d61420babecf5f1976fe33a2e1a729b71a1
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothDevice.java | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java index 838a3b95da..4acc6a5ed5 100644 --- a/framework/java/android/bluetooth/BluetoothDevice.java +++ b/framework/java/android/bluetooth/BluetoothDevice.java @@ -1121,7 +1121,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi - @RequiresPermission(Manifest.permission.BLUETOOTH) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public int getBatteryLevel() { final IBluetooth service = sService; if (service == null) { @@ -1212,7 +1212,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi - @RequiresPermission(Manifest.permission.BLUETOOTH) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean isBondingInitiatedLocally() { final IBluetooth service = sService; if (service == null) { @@ -1250,13 +1250,12 @@ public final class BluetoothDevice implements Parcelable { /** * 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 * @hide */ @SystemApi - @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean cancelBondProcess() { final IBluetooth service = sService; if (service == null) { @@ -1279,13 +1278,12 @@ public final class BluetoothDevice implements Parcelable { * <p>Delete the link key associated with the remote device, and * immediately terminate connections to that device that require * authentication and encryption. - * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}. * * @return true on success, false on error * @hide */ @SystemApi - @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean removeBond() { final IBluetooth service = sService; if (service == null) { @@ -1329,13 +1327,12 @@ public final class BluetoothDevice implements Parcelable { /** * 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. * @hide */ @SystemApi - @RequiresPermission(android.Manifest.permission.BLUETOOTH) + @RequiresPermission(Manifest.permission.BLUETOOTH) public boolean isConnected() { final IBluetooth service = sService; if (service == null) { @@ -1353,13 +1350,12 @@ public final class BluetoothDevice implements Parcelable { /** * Returns whether there is an open connection to this device * that has been encrypted. - * <p>Requires {@link android.Manifest.permission#BLUETOOTH}. * * @return True if there is at least one encrypted connection to this device. * @hide */ @SystemApi - @RequiresPermission(android.Manifest.permission.BLUETOOTH) + @RequiresPermission(Manifest.permission.BLUETOOTH) public boolean isEncrypted() { final IBluetooth service = sService; if (service == null) { @@ -1512,7 +1508,7 @@ public final class BluetoothDevice implements Parcelable { */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) - public boolean setPin(@Nullable String pin) { + public boolean setPin(@NonNull String pin) { byte[] pinBytes = convertPinToBytes(pin); if (pinBytes == null) { return false; @@ -1548,6 +1544,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean cancelPairing() { final IBluetooth service = sService; if (service == null) { @@ -1579,8 +1576,8 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi - @RequiresPermission(Manifest.permission.BLUETOOTH) - public int getPhonebookAccessPermission() { + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) + public @AccessPermission int getPhonebookAccessPermission() { final IBluetooth service = sService; if (service == null) { return ACCESS_UNKNOWN; @@ -1659,7 +1656,6 @@ public final class BluetoothDevice implements Parcelable { /** * 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 * #ACCESS_REJECTED}. @@ -1668,7 +1664,7 @@ public final class BluetoothDevice implements Parcelable { */ @SystemApi @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) - public boolean setPhonebookAccessPermission(int value) { + public boolean setPhonebookAccessPermission(@AccessPermission int value) { final IBluetooth service = sService; if (service == null) { return false; @@ -1688,7 +1684,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi - @RequiresPermission(Manifest.permission.BLUETOOTH) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public @AccessPermission int getMessageAccessPermission() { final IBluetooth service = sService; if (service == null) { @@ -1735,7 +1731,7 @@ public final class BluetoothDevice implements Parcelable { * @hide */ @SystemApi - @RequiresPermission(Manifest.permission.BLUETOOTH) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public @AccessPermission int getSimAccessPermission() { final IBluetooth service = sService; if (service == null) { |
