diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-11-15 03:57:21 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-11-15 03:57:21 -0800 |
commit | 087a6cf7a9bf66d7789c9901cc111451b466d57b (patch) | |
tree | 75f745afd2d06ad4484bbce88fd0962362c2e646 | |
parent | 7acb64298b006f48d9396072fe3682e2eaf401e7 (diff) | |
parent | 340ad66da66792a84a47684489ea0c1c6bee53ce (diff) | |
download | android_packages_apps_Bluetooth-087a6cf7a9bf66d7789c9901cc111451b466d57b.tar.gz android_packages_apps_Bluetooth-087a6cf7a9bf66d7789c9901cc111451b466d57b.tar.bz2 android_packages_apps_Bluetooth-087a6cf7a9bf66d7789c9901cc111451b466d57b.zip |
Merge "Bluetooth: Do not accept SCO without any active listener."
-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); |