diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2022-01-24 14:38:40 -0800 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2022-01-24 15:19:36 -0800 |
commit | b83a2fe75a88b4b732b3aab2ff82ea1dbfdaf673 (patch) | |
tree | 2c161a633e860d19c43e8396cfe933d9056931c7 /framework/java/android/bluetooth/BluetoothHeadset.java | |
parent | bf99b66a682dabd7f660e21e9a6abf8457bb73b1 (diff) |
Update BluetoothHeadset#connectAudio and
BluetoothHeadset#disconnectAudio to support additional error codes for
GTS
Bug: 211914959
Test: atest BluetoothHostTest
Ignore-AOSP-First: Depends on change only present in internal
Change-Id: Ifcc6971f4cef6d966cf14fdbfd1f97b34170c0ba
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothHeadset.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java index 2ed1eb40f8..91449df0f4 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -1038,6 +1038,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, @@ -1050,13 +1051,13 @@ public final class BluetoothHeadset implements BluetoothProfile { /** * Initiates a connection of SCO audio to the current active HFP device. The active HFP device * can be identified with {@link BluetoothAdapter#getActiveDevices(int)}. - * <p> + * <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 @@ -1074,6 +1075,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(); @@ -1086,8 +1088,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 */ @@ -1097,6 +1100,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 }) @@ -1126,6 +1130,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(); @@ -1138,8 +1143,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; } /** |