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

Commit 2f4df2ca authored by Hall Liu's avatar Hall Liu
Browse files

Fix mmi command for holding calls on IMS

Adjust the call to ImsPhoneCallTracker depending on what the call state
is instead of just calling holdActiveCall.

Fixes: 145606581
Test: manual, unit
Change-Id: I190a9f0806d6368758bc0d49e237e5c3834fa503
parent f32ebb8b
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
@@ -681,8 +681,18 @@ public class ImsPhone extends ImsPhoneBase {
                if (getRingingCall().getState() != ImsPhoneCall.State.IDLE) {
                if (getRingingCall().getState() != ImsPhoneCall.State.IDLE) {
                    if (DBG) logd("MmiCode 2: accept ringing call");
                    if (DBG) logd("MmiCode 2: accept ringing call");
                    mCT.acceptCall(ImsCallProfile.CALL_TYPE_VOICE);
                    mCT.acceptCall(ImsCallProfile.CALL_TYPE_VOICE);
                } else if (getBackgroundCall().getState() == ImsPhoneCall.State.HOLDING) {
                    // If there's an active ongoing call as well, hold it and the background one
                    // should automatically unhold. Otherwise just unhold the background call.
                    if (getForegroundCall().getState() != ImsPhoneCall.State.IDLE) {
                        if (DBG) logd("MmiCode 2: switch holding and active");
                        mCT.holdActiveCall();
                    } else {
                    } else {
                    if (DBG) logd("MmiCode 2: holdActiveCall");
                        if (DBG) logd("MmiCode 2: unhold held call");
                        mCT.unholdHeldCall();
                    }
                } else if (getForegroundCall().getState() != ImsPhoneCall.State.IDLE) {
                    if (DBG) logd("MmiCode 2: hold active call");
                    mCT.holdActiveCall();
                    mCT.holdActiveCall();
                }
                }
            } catch (CallStateException e) {
            } catch (CallStateException e) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -1345,7 +1345,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    /**
    /**
     * Unhold the currently held call.
     * Unhold the currently held call.
     */
     */
    void unholdHeldCall() throws CallStateException {
    public void unholdHeldCall() throws CallStateException {
        ImsCall imsCall = mBackgroundCall.getImsCall();
        ImsCall imsCall = mBackgroundCall.getImsCall();
        if (mHoldSwitchingState == HoldSwapState.PENDING_SINGLE_CALL_UNHOLD
        if (mHoldSwitchingState == HoldSwapState.PENDING_SINGLE_CALL_UNHOLD
                || mHoldSwitchingState == HoldSwapState.SWAPPING_ACTIVE_AND_HELD) {
                || mHoldSwitchingState == HoldSwapState.SWAPPING_ACTIVE_AND_HELD) {
+15 −1
Original line number Original line Diff line number Diff line
@@ -223,11 +223,25 @@ public class ImsPhoneTest extends TelephonyTest {
        assertEquals(Phone.SuppService.SEPARATE,
        assertEquals(Phone.SuppService.SEPARATE,
                ((AsyncResult) messageArgumentCaptor.getValue().obj).result);
                ((AsyncResult) messageArgumentCaptor.getValue().obj).result);


        // ringing call is idle
        // ringing call is idle, only an active call present
        doReturn(Call.State.ACTIVE).when(mForegroundCall).getState();
        assertEquals(true, mImsPhoneUT.handleInCallMmiCommands("2"));
        assertEquals(true, mImsPhoneUT.handleInCallMmiCommands("2"));
        verify(mImsCT).holdActiveCall();
        verify(mImsCT).holdActiveCall();


        // background call is holding
        doReturn(Call.State.HOLDING).when(mBackgroundCall).getState();
        doReturn(Call.State.IDLE).when(mForegroundCall).getState();
        assertEquals(true, mImsPhoneUT.handleInCallMmiCommands("2"));
        verify(mImsCT).unholdHeldCall();

        // background call is holding and there's an active foreground call
        doReturn(Call.State.ACTIVE).when(mForegroundCall).getState();
        assertEquals(true, mImsPhoneUT.handleInCallMmiCommands("2"));
        verify(mImsCT, times(2)).holdActiveCall();

        // ringing call is not idle
        // ringing call is not idle
        doReturn(Call.State.IDLE).when(mForegroundCall).getState();
        doReturn(Call.State.IDLE).when(mBackgroundCall).getState();
        doReturn(Call.State.INCOMING).when(mRingingCall).getState();
        doReturn(Call.State.INCOMING).when(mRingingCall).getState();
        assertEquals(true, mImsPhoneUT.handleInCallMmiCommands("2"));
        assertEquals(true, mImsPhoneUT.handleInCallMmiCommands("2"));
        verify(mImsCT).acceptCall(ImsCallProfile.CALL_TYPE_VOICE);
        verify(mImsCT).acceptCall(ImsCallProfile.CALL_TYPE_VOICE);