Merge "Update BluetoothPbap class description to indicate how to create an instance of the class, add intdef to return value of BluetoothPbap#getConnectionState, and move all SystemApis to require the BLUETOOTH_PRIVILEGED permission"

This commit is contained in:
Treehugger Robot
2020-02-10 22:39:57 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 8 deletions

View File

@@ -1472,9 +1472,9 @@ package android.bluetooth {
} }
public class BluetoothPbap implements android.bluetooth.BluetoothProfile { public class BluetoothPbap implements android.bluetooth.BluetoothProfile {
method public int getConnectionState(@Nullable android.bluetooth.BluetoothDevice); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public int getConnectionState(@Nullable android.bluetooth.BluetoothDevice);
method @RequiresPermission(android.Manifest.permission.BLUETOOTH_ADMIN) public boolean setConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice, int); method @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public boolean setConnectionPolicy(@NonNull android.bluetooth.BluetoothDevice, int);
field public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED"; field @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED";
} }
public interface BluetoothProfile { public interface BluetoothProfile {

View File

@@ -38,9 +38,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
* The Android Bluetooth API is not finalized, and *will* change. Use at your
* own risk.
*
* Public API for controlling the Bluetooth Pbap Service. This includes * Public API for controlling the Bluetooth Pbap Service. This includes
* Bluetooth Phone book Access profile. * Bluetooth Phone book Access profile.
* BluetoothPbap is a proxy object for controlling the Bluetooth Pbap * BluetoothPbap is a proxy object for controlling the Bluetooth Pbap
@@ -56,6 +53,11 @@ import java.util.List;
* notification when it is bound, this is especially important if you wish to * notification when it is bound, this is especially important if you wish to
* immediately call methods on BluetoothPbap after construction. * immediately call methods on BluetoothPbap after construction.
* *
* To get an instance of the BluetoothPbap class, you can call
* {@link BluetoothAdapter#getProfileProxy(Context, ServiceListener, int)} with the final param
* being {@link BluetoothProfile#PBAP}. The ServiceListener should be able to get the instance of
* BluetoothPbap in {@link android.bluetooth.BluetoothProfile.ServiceListener#onServiceConnected}.
*
* Android only supports one connected Bluetooth Pce at a time. * Android only supports one connected Bluetooth Pce at a time.
* *
* @hide * @hide
@@ -87,6 +89,7 @@ public class BluetoothPbap implements BluetoothProfile {
*/ */
@SuppressLint("ActionValue") @SuppressLint("ActionValue")
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
@SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION) @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED = public static final String ACTION_CONNECTION_STATE_CHANGED =
"android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED"; "android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED";
@@ -235,7 +238,8 @@ public class BluetoothPbap implements BluetoothProfile {
*/ */
@SystemApi @SystemApi
@Override @Override
public int getConnectionState(@Nullable BluetoothDevice device) { @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public @BtProfileState int getConnectionState(@Nullable BluetoothDevice device) {
log("getConnectionState: device=" + device); log("getConnectionState: device=" + device);
try { try {
final IBluetoothPbap service = mService; final IBluetoothPbap service = mService;
@@ -287,7 +291,7 @@ public class BluetoothPbap implements BluetoothProfile {
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN) @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean setConnectionPolicy(@NonNull BluetoothDevice device, public boolean setConnectionPolicy(@NonNull BluetoothDevice device,
@ConnectionPolicy int connectionPolicy) { @ConnectionPolicy int connectionPolicy) {
if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")"); if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")");