diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2022-01-24 14:38:40 -0800 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2022-03-22 16:10:17 -0700 |
commit | 030a5b1a8d9cc1f41a9a9b6a1543add02ececcd4 (patch) | |
tree | 5c05a0441d330e968d8b6795478409b9f28355df /framework/java/android/bluetooth/BluetoothHeadset.java | |
parent | 0f5c8888ecce584288d3763e245512c54cba6cae (diff) |
Update BluetoothHeadset#connectAudio and
BluetoothHeadset#disconnectAudio to support additional error codes for
GTS
Bug: 211914959
Test: Manual
Merged-In: Ifcc6971f4cef6d966cf14fdbfd1f97b34170c0ba
Change-Id: Ifcc6971f4cef6d966cf14fdbfd1f97b34170c0ba
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothHeadset.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java index 015f0bd6fb..8fe759ee25 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -1104,6 +1104,7 @@ 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, @@ -1118,11 +1119,11 @@ public final class BluetoothHeadset implements BluetoothProfile { * can be identified with {@link BluetoothAdapter#getActiveDevices(int)}. * <p> * If this function returns {@link BluetoothStatusCodes#SUCCESS}, the intent - * {@link #ACTION_AUDIO_STATE_CHANGED} will be broadcasted twice. First with {@link #EXTRA_STATE} - * set to {@link #STATE_AUDIO_CONNECTING}. This will be followed by a broadcast with - * {@link #EXTRA_STATE} set to either {@link #STATE_AUDIO_CONNECTED} if the audio connection is - * established or {@link #STATE_AUDIO_DISCONNECTED} if there was a failure in establishing the - * audio connection. + * {@link #ACTION_AUDIO_STATE_CHANGED} will be broadcasted twice. First with + * {@link #EXTRA_STATE} set to {@link #STATE_AUDIO_CONNECTING}. This will be followed by a + * broadcast with {@link #EXTRA_STATE} set to either {@link #STATE_AUDIO_CONNECTED} if the audio + * connection is established or {@link #STATE_AUDIO_DISCONNECTED} if there was a failure in + * establishing the audio connection. * * @return whether the connection was successfully initiated or an error code on failure * @hide @@ -1140,6 +1141,7 @@ public final class BluetoothHeadset implements BluetoothProfile { if (service == null) { 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()) { try { final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver(); @@ -1152,8 +1154,9 @@ 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; } - return defaultValue; } /** @hide */ @@ -1163,6 +1166,7 @@ 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 }) @@ -1192,6 +1196,7 @@ public final class BluetoothHeadset implements BluetoothProfile { if (service == null) { 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()) { try { final SynchronousResultReceiver<Integer> recv = new SynchronousResultReceiver(); @@ -1204,8 +1209,9 @@ 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; } - return defaultValue; } /** |