diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2022-03-23 02:33:25 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-23 02:33:25 +0000 |
commit | 417226527d5c32b5bd6567edac67e8e4aa5d06be (patch) | |
tree | 65119f69c7d17ed32d2ccb1fd0519f3b735059fd /framework/java/android/bluetooth/BluetoothHeadset.java | |
parent | b019a3d9eefddfe3b154a3fa27b593529b85edd3 (diff) | |
parent | 2b53c2037374639be994988d44314cf6a61c66d1 (diff) |
Merge changes I2861d51d,Ifcc6971f am: 2b53c20373
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2037666
Change-Id: Ibf2dfb1ad3479c6a5007cf48425aafe8920cf64a
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothHeadset.java | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java index 8fe759ee25..146ae6f8ca 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -969,7 +969,6 @@ public final class BluetoothHeadset implements BluetoothProfile { @Retention(RetentionPolicy.SOURCE) @IntDef(value = { BluetoothStatusCodes.SUCCESS, - BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED, BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND, BluetoothStatusCodes.ERROR_TIMEOUT, BluetoothStatusCodes.ERROR_UNKNOWN, @@ -981,7 +980,6 @@ public final class BluetoothHeadset implements BluetoothProfile { @IntDef(value = { BluetoothStatusCodes.ALLOWED, BluetoothStatusCodes.NOT_ALLOWED, - BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED, BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND, BluetoothStatusCodes.ERROR_TIMEOUT, BluetoothStatusCodes.ERROR_UNKNOWN, @@ -1014,21 +1012,22 @@ public final class BluetoothHeadset implements BluetoothProfile { Log.w(TAG, "Proxy not attached to service"); if (DBG) log(Log.getStackTraceString(new Throwable())); return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND; - } else if (!isEnabled()) { - return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; - } - try { - final SynchronousResultReceiver recv = new SynchronousResultReceiver(); - service.setAudioRouteAllowed(allowed, mAttributionSource, recv); - recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); - return BluetoothStatusCodes.SUCCESS; - } catch (TimeoutException e) { - Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); - return BluetoothStatusCodes.ERROR_TIMEOUT; - } catch (RemoteException e) { - Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); - e.rethrowFromSystemServer(); + } else if (isEnabled()) { + try { + final SynchronousResultReceiver recv = new SynchronousResultReceiver(); + service.setAudioRouteAllowed(allowed, mAttributionSource, recv); + recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); + return BluetoothStatusCodes.SUCCESS; + } catch (TimeoutException e) { + Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); + return BluetoothStatusCodes.ERROR_TIMEOUT; + } catch (RemoteException e) { + Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); + e.rethrowFromSystemServer(); + } } + + Log.e(TAG, "setAudioRouteAllowed: Bluetooth disabled, but profile service still bound"); return BluetoothStatusCodes.ERROR_UNKNOWN; } @@ -1053,21 +1052,22 @@ public final class BluetoothHeadset implements BluetoothProfile { Log.w(TAG, "Proxy not attached to service"); if (DBG) log(Log.getStackTraceString(new Throwable())); return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND; - } else if (!isEnabled()) { - return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; - } - try { - final SynchronousResultReceiver<Boolean> recv = new SynchronousResultReceiver(); - service.getAudioRouteAllowed(mAttributionSource, recv); - return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(false) - ? BluetoothStatusCodes.ALLOWED : BluetoothStatusCodes.NOT_ALLOWED; - } catch (TimeoutException e) { - Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); - return BluetoothStatusCodes.ERROR_TIMEOUT; - } catch (RemoteException e) { - Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); - e.rethrowFromSystemServer(); + } else if (isEnabled()) { + try { + final SynchronousResultReceiver<Boolean> recv = new SynchronousResultReceiver(); + service.getAudioRouteAllowed(mAttributionSource, recv); + return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(false) + ? BluetoothStatusCodes.ALLOWED : BluetoothStatusCodes.NOT_ALLOWED; + } catch (TimeoutException e) { + Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); + return BluetoothStatusCodes.ERROR_TIMEOUT; + } catch (RemoteException e) { + Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); + e.rethrowFromSystemServer(); + } } + + Log.e(TAG, "getAudioRouteAllowed: Bluetooth disabled, but profile service still bound"); return BluetoothStatusCodes.ERROR_UNKNOWN; } @@ -1104,7 +1104,6 @@ public final class BluetoothHeadset implements BluetoothProfile { BluetoothStatusCodes.ERROR_UNKNOWN, BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND, BluetoothStatusCodes.ERROR_TIMEOUT, - BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED, BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_CONNECTED, BluetoothStatusCodes.ERROR_NO_ACTIVE_DEVICES, BluetoothStatusCodes.ERROR_NOT_ACTIVE_DEVICE, @@ -1154,9 +1153,10 @@ public final class BluetoothHeadset implements BluetoothProfile { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); return BluetoothStatusCodes.ERROR_TIMEOUT; } - } else { - return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; } + + Log.e(TAG, "connectAudio: Bluetooth disabled, but profile service still bound"); + return defaultValue; } /** @hide */ @@ -1166,7 +1166,6 @@ public final class BluetoothHeadset implements BluetoothProfile { BluetoothStatusCodes.ERROR_UNKNOWN, BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND, BluetoothStatusCodes.ERROR_TIMEOUT, - BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED, BluetoothStatusCodes.ERROR_PROFILE_NOT_CONNECTED, BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_DISCONNECTED }) @@ -1209,9 +1208,10 @@ public final class BluetoothHeadset implements BluetoothProfile { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); return BluetoothStatusCodes.ERROR_TIMEOUT; } - } else { - return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; } + + Log.e(TAG, "disconnectAudio: Bluetooth disabled, but profile service still bound"); + return defaultValue; } /** |