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

Commit a9e9d278 authored by Jack He's avatar Jack He
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
parent 2900a72a
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -475,6 +475,9 @@ public class HeadsetService extends ProfileService {
        if (!mStateMachine.isConnected()) {
        if (!mStateMachine.isConnected()) {
            return false;
            return false;
        }
        }
        if (!mStateMachine.isSlcConnected()) {
            return false;
        }
        if (mStateMachine.isAudioOn()) {
        if (mStateMachine.isAudioOn()) {
            return false;
            return false;
        }
        }
+11 −0
Original line number Original line Diff line number Diff line
@@ -164,6 +164,9 @@ final class HeadsetStateMachine extends StateMachine {
    // Indicates whether audio can be routed to the device.
    // Indicates whether audio can be routed to the device.
    private boolean mAudioRouteAllowed = true;
    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
    // mCurrentDevice is the device connected before the state changes
    // mTargetDevice is the device to be connected
    // mTargetDevice is the device to be connected
    // mIncomingDevice is the device connecting to us, valid only in Pending state
    // mIncomingDevice is the device connecting to us, valid only in Pending state
@@ -324,6 +327,7 @@ final class HeadsetStateMachine extends StateMachine {
            mPhoneState.listenForPhoneState(false);
            mPhoneState.listenForPhoneState(false);
            mVoiceRecognitionStarted = false;
            mVoiceRecognitionStarted = false;
            mWaitingForVoiceRecognition = false;
            mWaitingForVoiceRecognition = false;
            mSlcConnected = false;
        }
        }


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


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


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


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


    boolean isSlcConnected() {
        return mSlcConnected;
    }

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