diff options
author | Ajay Panicker <apanicke@google.com> | 2015-08-26 13:58:38 -0700 |
---|---|---|
committer | Andre Eisenbach <eisenbach@google.com> | 2015-08-26 18:52:02 -0700 |
commit | 9135d866b12ff019a4eae37e7a8c0df56a4383f2 (patch) | |
tree | d259d1a1b3af0de897219d2707d1d1d12efc5053 /src/com/android/bluetooth | |
parent | 72ecb4caa630b63f66505ccb202a807b1af4e294 (diff) | |
download | android_packages_apps_Bluetooth-9135d866b12ff019a4eae37e7a8c0df56a4383f2.tar.gz android_packages_apps_Bluetooth-9135d866b12ff019a4eae37e7a8c0df56a4383f2.tar.bz2 android_packages_apps_Bluetooth-9135d866b12ff019a4eae37e7a8c0df56a4383f2.zip |
HFP/A2DP: Remove pending auto-connect messages when connected
Fixes a bug in which being paired with multiple headsets causes
previously connected headsets to disconnect. This fix removes
pending connect attemps once one device is successfully connected.
Bug: 23111466
Change-Id: Id471189d92643b9626e63197c00e76defd0a72bf
Diffstat (limited to 'src/com/android/bluetooth')
-rwxr-xr-x | src/com/android/bluetooth/a2dp/A2dpStateMachine.java | 6 | ||||
-rw-r--r-- | src/com/android/bluetooth/hfp/HeadsetStateMachine.java | 14 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java index 3e48eae90..7ad4a5948 100755 --- a/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +++ b/src/com/android/bluetooth/a2dp/A2dpStateMachine.java @@ -479,6 +479,12 @@ final class A2dpStateMachine extends StateMachine { private class Connected extends State { @Override public void enter() { + // Remove pending connection attempts that were deferred during the pending + // state. This is to prevent auto connect attempts from disconnecting + // devices that previously successfully connected. + // TODO: This needs to check for multiple A2DP connections, once supported... + removeDeferredMessages(CONNECT); + log("Enter Connected: " + getCurrentMessage().what); // Upon connected, the audio starts out as stopped broadcastAudioState(mCurrentDevice, BluetoothA2dp.STATE_NOT_PLAYING, diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index 972239b07..d226e7cfe 100644 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -741,6 +741,12 @@ final class HeadsetStateMachine extends StateMachine { private class Connected extends State { @Override public void enter() { + // Remove pending connection attempts that were deferred during the pending + // state. This is to prevent auto connect attempts from disconnecting + // devices that previously successfully connected. + // TODO: This needs to check for multiple HFP connections, once supported... + removeDeferredMessages(CONNECT); + log("Enter Connected: " + getCurrentMessage().what + ", size: " + mConnectedDevicesList.size()); // start phone state listener here so that the CIND response as part of SLC can be @@ -2216,7 +2222,7 @@ final class HeadsetStateMachine extends StateMachine { boolean needAudio = true; if (mVoiceRecognitionStarted || isInCall()) { - Log.e(TAG, "Voice recognition started when call is active. isInCall:" + isInCall() + + Log.e(TAG, "Voice recognition started when call is active. isInCall:" + isInCall() + " mVoiceRecognitionStarted: " + mVoiceRecognitionStarted); return; } @@ -2695,9 +2701,9 @@ final class HeadsetStateMachine extends StateMachine { removeMessages(DIALING_OUT_TIMEOUT); } else if (callState.mCallState == HeadsetHalConstants.CALL_STATE_ACTIVE || callState.mCallState - == HeadsetHalConstants.CALL_STATE_IDLE) { + == HeadsetHalConstants.CALL_STATE_IDLE) { mDialingOut = false; - } + } } /* Set ActiveScoDevice to null when call ends */ @@ -2867,7 +2873,7 @@ final class HeadsetStateMachine extends StateMachine { String operatorName = mPhoneProxy.getNetworkOperator(); if (operatorName == null) { operatorName = ""; - } + } copsResponseNative(operatorName, getByteAddress(device)); } catch (RemoteException e) { Log.e(TAG, Log.getStackTraceString(new Throwable())); |