diff options
author | Gaurav Asati <gasati@codeaurora.org> | 2014-11-12 15:54:17 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-11-14 05:41:39 -0800 |
commit | 340ad66da66792a84a47684489ea0c1c6bee53ce (patch) | |
tree | f6f60f8ba43992bd800154804022fe02af9380eb | |
parent | ec1ee663663a1b8cec0a2a03da3124295dc5578c (diff) | |
download | android_packages_apps_Bluetooth-340ad66da66792a84a47684489ea0c1c6bee53ce.tar.gz android_packages_apps_Bluetooth-340ad66da66792a84a47684489ea0c1c6bee53ce.tar.bz2 android_packages_apps_Bluetooth-340ad66da66792a84a47684489ea0c1c6bee53ce.zip |
Bluetooth: Do not accept SCO without any active listener.
- Some HS re-connect SCO after call disconnect.
do not accept such incoming connection SCO connection
requests.
- Check for valid SCO listener before accepting incoming
SCO connection requests.
Change-Id: Iab5853382413467dfc7514587f50894fe11c9633
CRs-Fixed: 754738
-rw-r--r-- | src/com/android/bluetooth/hfp/HeadsetStateMachine.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index f3bcea996..798aa1e58 100644 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -1218,6 +1218,12 @@ final class HeadsetStateMachine extends StateMachine { switch (state) { case HeadsetHalConstants.AUDIO_STATE_CONNECTED: + if (!isScoAcceptable()) { + Log.e(TAG,"Audio Connected without any listener"); + disconnectAudioNative(getByteAddress(device)); + break; + } + // TODO(BT) should I save the state for next broadcast as the prevState? mAudioState = BluetoothHeadset.STATE_AUDIO_CONNECTED; setAudioParameters(device); /*Set proper Audio Paramters.*/ @@ -2191,6 +2197,11 @@ final class HeadsetStateMachine extends StateMachine { switch (state) { case HeadsetHalConstants.AUDIO_STATE_CONNECTED: + if (!isScoAcceptable()) { + Log.e(TAG,"Audio Connected without any listener"); + disconnectAudioNative(getByteAddress(device)); + break; + } mAudioState = BluetoothHeadset.STATE_AUDIO_CONNECTED; setAudioParameters(device); /* Set proper Audio Parameters. */ mAudioManager.setBluetoothScoOn(true); @@ -3047,7 +3058,7 @@ 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; } } @@ -3657,6 +3668,14 @@ final class HeadsetStateMachine extends StateMachine { (mPhoneState.getCallState() != HeadsetHalConstants.CALL_STATE_IDLE)); } + // Accept incoming SCO only when there is active call, VR activated, + // active VOIP call and Incoming call with inband ringtone supported + private boolean isScoAcceptable() { + return (((mPhoneState.getCallState() == HeadsetHalConstants.CALL_STATE_INCOMING) && + ((mLocalBrsf & BRSF_AG_IN_BAND_RING) != 0)) || mVoiceRecognitionStarted || + isInCall()); + } + boolean isConnected() { IState currentState = getCurrentState(); return (currentState == mConnected || currentState == mAudioOn); |