Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29c48a17 authored by Mallikarjuna GB's avatar Mallikarjuna GB Committed by Android Git Automerger
Browse files

am 504e672c: am d7e0723f: am 78097164: Do not accept SCO without any active listener.

* commit '504e672c':
  Do not accept SCO without any active listener.
parents 22225d3f 504e672c
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -1082,6 +1082,12 @@ final class HeadsetStateMachine extends StateMachine {


            switch (state) {
            switch (state) {
                case HeadsetHalConstants.AUDIO_STATE_CONNECTED:
                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?
                    // TODO(BT) should I save the state for next broadcast as the prevState?
                    mAudioState = BluetoothHeadset.STATE_AUDIO_CONNECTED;
                    mAudioState = BluetoothHeadset.STATE_AUDIO_CONNECTED;
                    setAudioParameters(device); /*Set proper Audio Paramters.*/
                    setAudioParameters(device); /*Set proper Audio Paramters.*/
@@ -1947,6 +1953,11 @@ final class HeadsetStateMachine extends StateMachine {


            switch (state) {
            switch (state) {
                case HeadsetHalConstants.AUDIO_STATE_CONNECTED:
                case HeadsetHalConstants.AUDIO_STATE_CONNECTED:
                    if (!isScoAcceptable()) {
                        Log.e(TAG,"Audio Connected without any listener");
                        disconnectAudioNative(getByteAddress(device));
                        break;
                    }
                    mAudioState = BluetoothHeadset.STATE_AUDIO_CONNECTED;
                    mAudioState = BluetoothHeadset.STATE_AUDIO_CONNECTED;
                    setAudioParameters(device); /* Set proper Audio Parameters. */
                    setAudioParameters(device); /* Set proper Audio Parameters. */
                    mAudioManager.setBluetoothScoOn(true);
                    mAudioManager.setBluetoothScoOn(true);
@@ -3207,6 +3218,12 @@ final class HeadsetStateMachine extends StateMachine {
                (mPhoneState.getCallState() != HeadsetHalConstants.CALL_STATE_IDLE));
                (mPhoneState.getCallState() != HeadsetHalConstants.CALL_STATE_IDLE));
    }
    }


    // Accept incoming SCO only when there is active call, VR activated,
    // active VOIP call
    private boolean isScoAcceptable() {
        return (mVoiceRecognitionStarted || isInCall());
    }

    boolean isConnected() {
    boolean isConnected() {
        IState currentState = getCurrentState();
        IState currentState = getCurrentState();
        return (currentState == mConnected || currentState == mAudioOn);
        return (currentState == mConnected || currentState == mAudioOn);