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

Commit 8df8ace3 authored by Eric Shih's avatar Eric Shih
Browse files

For virtual call, Reject SCO connection for HFP if HFPC is connected

- To prevent HFP and HFPC try to establish SCO at the same time.
- A property is added to enable this behavior

Bug: 284104022
Test: atest BluetoothInstrumentationTests
Change-Id: Idd72fc586dc72e03b17305ed210bb0c1ec3790d8
parent e83cfa05
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1174,6 +1174,11 @@ public class HeadsetService extends ProfileService {
                Log.w(TAG, "startVoiceRecognition: " + device + " is not connected or connecting");
                return false;
            }
            if (SystemProperties.getBoolean(REJECT_SCO_IF_HFPC_CONNECTED_PROPERTY, false)
                    && isHeadsetClientConnected()) {
                Log.w(TAG, "startVoiceRecognition: rejected SCO since HFPC is connected!");
                return false;
            }
            mVoiceRecognitionStarted = true;
            if (pendingRequestByHeadset) {
                stateMachine.sendMessage(HeadsetStateMachine.VOICE_RECOGNITION_RESULT,
@@ -1586,6 +1591,11 @@ public class HeadsetService extends ProfileService {
                Log.w(TAG, "startScoUsingVirtualVoiceCall: no active device");
                return false;
            }
            if (SystemProperties.getBoolean(REJECT_SCO_IF_HFPC_CONNECTED_PROPERTY, false)
                    && isHeadsetClientConnected()) {
                Log.w(TAG, "startScoUsingVirtualVoiceCall: rejected SCO since HFPC is connected!");
                return false;
            }
            mVirtualCallStarted = true;
            // Send virtual phone state changed to initialize SCO
            phoneStateChanged(0, 0, HeadsetHalConstants.CALL_STATE_DIALING, "", 0, "", true);
@@ -1759,6 +1769,11 @@ public class HeadsetService extends ProfileService {
                Log.w(TAG, "startVoiceRecognitionByHeadset: failed request from " + fromDevice);
                return false;
            }
            if (SystemProperties.getBoolean(REJECT_SCO_IF_HFPC_CONNECTED_PROPERTY, false)
                    && isHeadsetClientConnected()) {
                Log.w(TAG, "startVoiceRecognitionByHeadset: rejected SCO since HFPC is connected!");
                return false;
            }
            mVoiceRecognitionTimeoutEvent = new VoiceRecognitionTimeoutEvent(fromDevice);
            getStateMachinesThreadHandler()
                    .postDelayed(mVoiceRecognitionTimeoutEvent, sStartVrTimeoutMs);