aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothAdapter.java
diff options
context:
space:
mode:
authorWilliam Escande <wescande@google.com>2022-01-27 13:42:05 +0100
committerWilliam Escande <wescande@google.com>2022-02-14 14:55:17 +0100
commit3f38e428430389fdfdf2475e62168aa72194ba8e (patch)
tree3498eb73a5cc49e5fed4396ff80da07759b07342 /framework/java/android/bluetooth/BluetoothAdapter.java
parent61713020f5182615992661b1d18758a23b2639f9 (diff)
API Changes needed for apex to build
internal cherry-pick Bug: 216476895 Test: Compile Tag: #refactor Change-Id: I09108622038b174104457ca18ac6ec7949978f66 Merged-In: I09108622038b174104457ca18ac6ec7949978f66 CTS-Coverage-Bug: 217352944
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java40
1 files changed, 30 insertions, 10 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index 2c4f28e27f..068e6140ca 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -222,6 +222,7 @@ public final class BluetoothAdapter {
*
* @hide
*/
+ @SystemApi
public static final int STATE_BLE_ON = 15;
/**
@@ -271,6 +272,9 @@ public final class BluetoothAdapter {
*
* @hide
*/
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @NonNull
public static String nameForState(@AdapterState int state) {
switch (state) {
case STATE_OFF:
@@ -367,10 +371,13 @@ public final class BluetoothAdapter {
*
* @hide
*/
+ @SystemApi
@RequiresLegacyBluetoothPermission
@RequiresBluetoothConnectPermission
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
- @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION) public static final String
+ @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
+ @SuppressLint("ActionValue")
+ public static final String
ACTION_REQUEST_DISABLE = "android.bluetooth.adapter.action.REQUEST_DISABLE";
/**
@@ -1395,7 +1402,7 @@ public final class BluetoothAdapter {
* @return true to indicate that the config file was successfully cleared
* @hide
*/
- @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
+ @SystemApi
@RequiresBluetoothConnectPermission
@RequiresPermission(allOf = {
android.Manifest.permission.BLUETOOTH_CONNECT,
@@ -1429,10 +1436,12 @@ public final class BluetoothAdapter {
* @return the UUIDs supported by the local Bluetooth Adapter.
* @hide
*/
- @UnsupportedAppUsage
+ @SystemApi
@RequiresLegacyBluetoothPermission
@RequiresBluetoothConnectPermission
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
+ @NonNull
+ @SuppressLint(value = {"ArrayReturn", "NullableCollection"})
public @Nullable ParcelUuid[] getUuids() {
if (getState() != STATE_ON) {
return null;
@@ -2643,12 +2652,14 @@ public final class BluetoothAdapter {
* @param result The callback to which to send the activity info.
* @hide
*/
+ @SystemApi
@RequiresBluetoothConnectPermission
@RequiresPermission(allOf = {
android.Manifest.permission.BLUETOOTH_CONNECT,
android.Manifest.permission.BLUETOOTH_PRIVILEGED,
})
- public void requestControllerActivityEnergyInfo(ResultReceiver result) {
+ public void requestControllerActivityEnergyInfo(@NonNull ResultReceiver result) {
+ requireNonNull(result, "ResultReceiver cannot be null");
try {
mServiceLock.readLock().lock();
if (mService != null) {
@@ -2675,9 +2686,13 @@ public final class BluetoothAdapter {
*
* @hide
*/
+ @SystemApi
@RequiresLegacyBluetoothAdminPermission
@RequiresBluetoothConnectPermission
- @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED,
+ })
public @NonNull List<BluetoothDevice> getMostRecentlyConnectedDevices() {
if (getState() != STATE_ON) {
return new ArrayList<>();
@@ -2835,8 +2850,7 @@ public final class BluetoothAdapter {
* #STATE_CONNECTING} or {@link #STATE_DISCONNECTED}
* @hide
*/
- @UnsupportedAppUsage
- @RequiresLegacyBluetoothPermission
+ @SystemApi
@RequiresNoPermission
public int getConnectionState() {
if (getState() != STATE_ON) {
@@ -4129,7 +4143,8 @@ public final class BluetoothAdapter {
*
* @hide
*/
- public boolean registerServiceLifecycleCallback(ServiceLifecycleCallback callback) {
+ @SystemApi
+ public boolean registerServiceLifecycleCallback(@NonNull ServiceLifecycleCallback callback) {
return getBluetoothService(callback.mRemote) != null;
}
@@ -4147,6 +4162,7 @@ public final class BluetoothAdapter {
*
* @hide
*/
+ @SystemApi
public abstract static class ServiceLifecycleCallback {
/** Called when the bluetooth stack is up */
@@ -4622,6 +4638,7 @@ public final class BluetoothAdapter {
* @throws IllegalArgumentException if the callback is already registered
* @hide
*/
+ @SystemApi
@RequiresBluetoothConnectPermission
@RequiresPermission(allOf = {
android.Manifest.permission.BLUETOOTH_CONNECT,
@@ -4719,19 +4736,21 @@ public final class BluetoothAdapter {
*
* @hide
*/
+ @SystemApi
public abstract static class BluetoothConnectionCallback {
/**
* Callback triggered when a bluetooth device (classic or BLE) is connected
* @param device is the connected bluetooth device
*/
- public void onDeviceConnected(BluetoothDevice device) {}
+ public void onDeviceConnected(@NonNull BluetoothDevice device) {}
/**
* Callback triggered when a bluetooth device (classic or BLE) is disconnected
* @param device is the disconnected bluetooth device
* @param reason is the disconnect reason
*/
- public void onDeviceDisconnected(BluetoothDevice device, @DisconnectReason int reason) {}
+ public void onDeviceDisconnected(@NonNull BluetoothDevice device,
+ @DisconnectReason int reason) {}
/**
* @hide
@@ -4754,6 +4773,7 @@ public final class BluetoothAdapter {
/**
* Returns human-readable strings corresponding to {@link DisconnectReason}.
*/
+ @NonNull
public static String disconnectReasonText(@DisconnectReason int reason) {
switch (reason) {
case BluetoothStatusCodes.ERROR_UNKNOWN: