From ce594994e8aa1b4bf9a6917e18c4f2f3b68c1ddc Mon Sep 17 00:00:00 2001 From: Rahul Sabnis Date: Wed, 18 Mar 2020 17:46:33 -0700 Subject: 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 --- .../java/android/bluetooth/BluetoothHeadsetClient.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHeadsetClient.java') diff --git a/framework/java/android/bluetooth/BluetoothHeadsetClient.java b/framework/java/android/bluetooth/BluetoothHeadsetClient.java index fbda9e9d6d..85e0e08b19 100644 --- a/framework/java/android/bluetooth/BluetoothHeadsetClient.java +++ b/framework/java/android/bluetooth/BluetoothHeadsetClient.java @@ -17,6 +17,7 @@ package android.bluetooth; import android.Manifest; +import android.annotation.NonNull; import android.annotation.RequiresPermission; import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; @@ -442,6 +443,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * @param device a remote device we want connect to * @return true if command has been issued successfully; false * otherwise; upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} intent. + * + * @hide */ @UnsupportedAppUsage public boolean connect(BluetoothDevice device) { @@ -466,6 +469,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * @param device a remote device we want disconnect * @return true if command has been issued successfully; false * otherwise; upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} intent. + * + * @hide */ @UnsupportedAppUsage public boolean disconnect(BluetoothDevice device) { @@ -564,7 +569,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * @return true if priority is set, false on error * @hide */ - @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setPriority(BluetoothDevice device, int priority) { if (DBG) log("setPriority(" + device + ", " + priority + ")"); return setConnectionPolicy(device, BluetoothAdapter.priorityToConnectionPolicy(priority)); @@ -583,8 +588,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * @hide */ @SystemApi - @RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) - public boolean setConnectionPolicy(BluetoothDevice device, + @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED) + public boolean setConnectionPolicy(@NonNull BluetoothDevice device, @ConnectionPolicy int connectionPolicy) { if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")"); final IBluetoothHeadsetClient service = @@ -634,7 +639,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { */ @SystemApi @RequiresPermission(Manifest.permission.BLUETOOTH) - public @ConnectionPolicy int getConnectionPolicy(BluetoothDevice device) { + public @ConnectionPolicy int getConnectionPolicy(@NonNull BluetoothDevice device) { if (VDBG) log("getConnectionPolicy(" + device + ")"); final IBluetoothHeadsetClient service = getService(); -- cgit v1.2.3