summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothAdapter.java
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2022-03-11 19:27:17 +0000
committerScott Lobdell <slobdell@google.com>2022-03-11 19:57:09 +0000
commitc9218ef1b82430a07d94f74c212a30e7ccc52975 (patch)
tree241b7fdeb6bdf1cf3af925ba8996f18faa8973d9 /framework/java/android/bluetooth/BluetoothAdapter.java
parenta26bda4d37221f2f7ef750b413502091e3bcddd4 (diff)
parent480d2270b269a0e47bf475eb439111f3f966e2a9 (diff)
Merge TP1A.220225.003
Change-Id: Id71ac466dbfe3707fe2e544ce22b1da8f474ec2b
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java39
1 files changed, 31 insertions, 8 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index 05c67f360a..dc7ffa6fd2 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -251,6 +251,8 @@ public final class BluetoothAdapter {
*
* @hide
*/
+ @SystemApi
+ @SuppressLint("ActionValue")
public static final String EXTRA_RFCOMM_LISTENER_ID =
"android.bluetooth.adapter.extra.RFCOMM_LISTENER_ID";
@@ -1137,9 +1139,7 @@ public final class BluetoothAdapter {
try {
final SynchronousResultReceiver<Integer> recv =
new SynchronousResultReceiver();
- if (mService != null) {
- mService.getState(recv);
- }
+ mService.getState(recv);
return recv.awaitResultNoInterrupt(getSyncTimeout())
.getValue(BluetoothAdapter.STATE_OFF);
} catch (TimeoutException e) {
@@ -1183,11 +1183,8 @@ public final class BluetoothAdapter {
mService.getState(recv);
return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(state);
}
- } catch (TimeoutException e) {
+ } catch (RemoteException | TimeoutException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
- } catch (RemoteException e) {
- Log.e(TAG, "", e);
- e.rethrowFromSystemServer();
} finally {
mServiceLock.readLock().unlock();
}
@@ -1289,7 +1286,20 @@ public final class BluetoothAdapter {
* such as Airplane mode, or the adapter is already turned on.
*
* @return true to indicate adapter startup has begun, or false on immediate error
+ *
+ * @deprecated Starting with {@link android.os.Build.VERSION_CODES#TIRAMISU}, applications
+ * are not allowed to enable/disable Bluetooth.
+ * <b>Compatibility Note:</b> For applications targeting
+ * {@link android.os.Build.VERSION_CODES#TIRAMISU} or above, this API will always fail and return
+ * {@code false}. If apps are targeting an older SDK ({@link android.os.Build.VERSION_CODES#S}
+ * or below), they can continue to use this API.
+ * <p>
+ * Deprecation Exemptions:
+ * <ul>
+ * <li>Device Owner (DO), Profile Owner (PO) and system apps.
+ * </ul>
*/
+ @Deprecated
@RequiresLegacyBluetoothAdminPermission
@RequiresBluetoothConnectPermission
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
@@ -1329,7 +1339,20 @@ public final class BluetoothAdapter {
* such as the adapter already being turned off.
*
* @return true to indicate adapter shutdown has begun, or false on immediate error
+ *
+ * @deprecated Starting with {@link android.os.Build.VERSION_CODES#TIRAMISU}, applications
+ * are not allowed to enable/disable Bluetooth.
+ * <b>Compatibility Note:</b> For applications targeting
+ * {@link android.os.Build.VERSION_CODES#TIRAMISU} or above, this API will always fail and return
+ * {@code false}. If apps are targeting an older SDK ({@link android.os.Build.VERSION_CODES#S}
+ * or below), they can continue to use this API.
+ * <p>
+ * Deprecation Exemptions:
+ * <ul>
+ * <li>Device Owner (DO), Profile Owner (PO) and system apps.
+ * </ul>
*/
+ @Deprecated
@RequiresLegacyBluetoothAdminPermission
@RequiresBluetoothConnectPermission
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
@@ -3139,7 +3162,7 @@ public final class BluetoothAdapter {
android.Manifest.permission.BLUETOOTH_PRIVILEGED,
})
@RfcommListenerResult
- public int closeRfcommServer(@NonNull UUID uuid) {
+ public int stopRfcommServer(@NonNull UUID uuid) {
try {
final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver();
mService.stopRfcommListener(new ParcelUuid(uuid), mAttributionSource, recv);