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

Commit fdde2593 authored by Jack He's avatar Jack He Committed by Andre Eisenbach
Browse files

HFP: Check for service level connection when connecting SCO

* A service level connection (SLC) should be established before a SCO
  connection could be created
* This CL creates a flag within HeadsetStateMachine to track the status
  of service level connections
* BluetoothHeadset.connectAudio() will return false when an SLC is not
  established

Bug: 36100309
Test: make, HFP regression, testplans/82424
Change-Id: Ibb52674ef6be75eeac66eb228e8b75d9bba1ddc6
(cherry picked from commit 7a895040f9654546a3ea6f5aca904a533a112dbd)
parent 4d584ae3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -475,6 +475,9 @@ public class HeadsetService extends ProfileService {
        if (!mStateMachine.isConnected()) {
            return false;
        }
        if (!mStateMachine.isSlcConnected()) {
            return false;
        }
        if (mStateMachine.isAudioOn()) {
            return false;
        }
+11 −0
Original line number Diff line number Diff line
@@ -164,6 +164,9 @@ final class HeadsetStateMachine extends StateMachine {
    // Indicates whether audio can be routed to the device.
    private boolean mAudioRouteAllowed = true;

    // Indicate whether service level connection has been established for this device
    private boolean mSlcConnected = false;

    // mCurrentDevice is the device connected before the state changes
    // mTargetDevice is the device to be connected
    // mIncomingDevice is the device connecting to us, valid only in Pending state
@@ -324,6 +327,7 @@ final class HeadsetStateMachine extends StateMachine {
            mPhoneState.listenForPhoneState(false);
            mVoiceRecognitionStarted = false;
            mWaitingForVoiceRecognition = false;
            mSlcConnected = false;
        }

        @Override
@@ -1092,6 +1096,7 @@ final class HeadsetStateMachine extends StateMachine {
        }

        private void processSlcConnected() {
            mSlcConnected = true;
            if (mPhoneProxy != null) {
                try {
                    mPhoneProxy.queryPhoneState();
@@ -1501,6 +1506,7 @@ final class HeadsetStateMachine extends StateMachine {
        }

        private void processSlcConnected() {
            mSlcConnected = true;
            if (mPhoneProxy != null) {
                try {
                    mPhoneProxy.queryPhoneState();
@@ -1954,6 +1960,7 @@ final class HeadsetStateMachine extends StateMachine {
        }

        private void processSlcConnected() {
            mSlcConnected = true;
            if (mPhoneProxy != null) {
                try {
                    mPhoneProxy.queryPhoneState();
@@ -2094,6 +2101,10 @@ final class HeadsetStateMachine extends StateMachine {
        return false;
    }

    boolean isSlcConnected() {
        return mSlcConnected;
    }

    public void setAudioRouteAllowed(boolean allowed) {
        mAudioRouteAllowed = allowed;
    }