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

Commit c1375b83 authored by Jack He's avatar Jack He
Browse files

HFP: Suspend A2DP whenever call state is busy

* Suspend A2DP whenever call state is ringing or ongoing
* Resume A2DP when call state becomes idle and no SCO audio is
  established

Bug: 110771727
Test: Receive incoming call when in-band ringing is disabled
Change-Id: I59361384c223e64e7ce73444c4e1cdf25bf18781
parent eed8d08a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1486,13 +1486,13 @@ public class HeadsetService extends ProfileService {
            }
        }
        mStateMachinesThread.getThreadHandler().post(() -> {
            boolean shouldCallAudioBeActiveBefore = shouldCallAudioBeActive();
            boolean isCallIdleBefore = mSystemInterface.isCallIdle();
            mSystemInterface.getHeadsetPhoneState().setNumActiveCall(numActive);
            mSystemInterface.getHeadsetPhoneState().setNumHeldCall(numHeld);
            mSystemInterface.getHeadsetPhoneState().setCallState(callState);
            // Suspend A2DP when call about is about to become active
            if (callState != HeadsetHalConstants.CALL_STATE_DISCONNECTED
                    && shouldCallAudioBeActive() && !shouldCallAudioBeActiveBefore) {
                    && !mSystemInterface.isCallIdle() && isCallIdleBefore) {
                mSystemInterface.getAudioManager().setParameters("A2dpSuspended=true");
            }
        });
@@ -1501,7 +1501,7 @@ public class HeadsetService extends ProfileService {
                        new HeadsetCallState(numActive, numHeld, callState, number, type)));
        mStateMachinesThread.getThreadHandler().post(() -> {
            if (callState == HeadsetHalConstants.CALL_STATE_IDLE
                    && !shouldCallAudioBeActive() && !isAudioOn()) {
                    && mSystemInterface.isCallIdle() && !isAudioOn()) {
                // Resume A2DP when call ended and SCO is not connected
                mSystemInterface.getAudioManager().setParameters("A2dpSuspended=false");
            }