summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothDevice.java
diff options
context:
space:
mode:
authorRahul Sabnis <rahulsabnis@google.com>2020-03-18 17:46:33 -0700
committerRahul Sabnis <rahulsabnis@google.com>2020-03-21 04:10:15 +0000
commitce594994e8aa1b4bf9a6917e18c4f2f3b68c1ddc (patch)
tree22ff052ac71fcee0d0c6f6c05f96641fdcb38dac /framework/java/android/bluetooth/BluetoothDevice.java
parent8e78d743cfc4b914b5e9862566acec998f8c3544 (diff)
Add BLUETOOTH_PRIVILEGED permission as a requirement for all new Bluetooth SystemApis and for hidden connect/disconnect APIs.
Hide some APIs that were previously marked as @UnsupportedAppUsage and re-add annotation as changing the permissions for these SystemApis would break the unsupported app contract that was previously there. Therefore, we're choosing to hide them until we have a good story on how to deal with them next release. Bug: 148689314 Test: Manual Change-Id: I33ee2c7ccd3827db3d23d6447cf82d9ffc36836a
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothDevice.java32
1 files changed, 15 insertions, 17 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index eab7a03949..594e5ffa77 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -36,8 +36,6 @@ import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
-import com.android.internal.annotations.VisibleForTesting;
-
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Retention;
@@ -1100,8 +1098,8 @@ public final class BluetoothDevice implements Parcelable {
* @return true on success, false on error
* @hide
*/
- @SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public boolean setAlias(@NonNull String alias) {
final IBluetooth service = sService;
if (service == null) {
@@ -1124,8 +1122,8 @@ public final class BluetoothDevice implements Parcelable {
* not have any battery reporting service, or return value is invalid
* @hide
*/
- @SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public int getBatteryLevel() {
final IBluetooth service = sService;
if (service == null) {
@@ -1215,8 +1213,8 @@ public final class BluetoothDevice implements Parcelable {
*
* @hide
*/
- @SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public boolean isBondingInitiatedLocally() {
final IBluetooth service = sService;
if (service == null) {
@@ -1539,7 +1537,7 @@ public final class BluetoothDevice implements Parcelable {
* @return true pin has been set false for error
* @hide
*/
- @SystemApi
+ @UnsupportedAppUsage
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean setPin(@NonNull String pin) {
byte[] pinBytes = convertPinToBytes(pin);
@@ -1576,8 +1574,8 @@ public final class BluetoothDevice implements Parcelable {
*
* @hide
*/
- @SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean cancelPairing() {
final IBluetooth service = sService;
if (service == null) {
@@ -1608,8 +1606,8 @@ public final class BluetoothDevice implements Parcelable {
* #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
* @hide
*/
- @SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public @AccessPermission int getPhonebookAccessPermission() {
final IBluetooth service = sService;
if (service == null) {
@@ -1716,8 +1714,8 @@ public final class BluetoothDevice implements Parcelable {
* @return Whether the message access is allowed to this device.
* @hide
*/
- @SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @UnsupportedAppUsage
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public @AccessPermission int getMessageAccessPermission() {
final IBluetooth service = sService;
if (service == null) {
@@ -1766,7 +1764,7 @@ public final class BluetoothDevice implements Parcelable {
* @hide
*/
@SystemApi
- @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
public @AccessPermission int getSimAccessPermission() {
final IBluetooth service = sService;
if (service == null) {
@@ -2021,7 +2019,7 @@ public final class BluetoothDevice implements Parcelable {
* @return the pin code as a UTF-8 byte array, or null if it is an invalid Bluetooth pin.
* @hide
*/
- @VisibleForTesting
+ @UnsupportedAppUsage
public static byte[] convertPinToBytes(String pin) {
if (pin == null) {
return null;