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

Commit 90925537 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Reset the hold/swap state when catching exception"

parents fe6b2a07 5be91c6b
Loading
Loading
Loading
Loading
+27 −14
Original line number Diff line number Diff line
@@ -1206,6 +1206,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            logi("Ignoring hold request while already holding or swapping");
            return;
        }
        HoldSwapState oldHoldState = mHoldSwitchingState;
        ImsCall callToHold = mForegroundCall.getImsCall();

        mHoldSwitchingState = HoldSwapState.HOLDING_TO_DIAL_OUTGOING;
@@ -1218,6 +1219,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                    ImsCommand.IMS_CMD_HOLD);
        } catch (ImsException e) {
            mForegroundCall.switchWith(mBackgroundCall);
            mHoldSwitchingState = oldHoldState;
            logHoldSwapState("holdActiveCallForPendingMo - fail");
            throw new CallStateException(e.getMessage());
        }
    }
@@ -1232,6 +1235,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                logi("Ignoring hold request while already holding or swapping");
                return;
            }
            HoldSwapState oldHoldState = mHoldSwitchingState;
            ImsCall callToHold = mForegroundCall.getImsCall();
            if (mBackgroundCall.getState().isAlive()) {
                mCallExpectedToResume = mBackgroundCall.getImsCall();
@@ -1247,6 +1251,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                        ImsCommand.IMS_CMD_HOLD);
            } catch (ImsException e) {
                mForegroundCall.switchWith(mBackgroundCall);
                mHoldSwitchingState = oldHoldState;
                logHoldSwapState("holdActiveCall - fail");
                throw new CallStateException(e.getMessage());
            }
        }
@@ -1260,6 +1266,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                && mRingingCall.getState() == ImsPhoneCall.State.WAITING;
        if (switchingWithWaitingCall) {
            ImsCall callToHold = mForegroundCall.getImsCall();
            HoldSwapState oldHoldState = mHoldSwitchingState;
            mHoldSwitchingState = HoldSwapState.HOLDING_TO_ANSWER_INCOMING;
            mForegroundCall.switchWith(mBackgroundCall);
            logHoldSwapState("holdActiveCallForWaitingCall");
@@ -1269,6 +1276,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                        ImsCommand.IMS_CMD_HOLD);
            } catch (ImsException e) {
                mForegroundCall.switchWith(mBackgroundCall);
                mHoldSwitchingState = oldHoldState;
                logHoldSwapState("holdActiveCallForWaitingCall - fail");
                throw new CallStateException(e.getMessage());
            }
        }
@@ -1278,7 +1287,6 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
     * Unhold the currently held call.
     */
    void unholdHeldCall() throws CallStateException {
        try {
        ImsCall imsCall = mBackgroundCall.getImsCall();
        if (mHoldSwitchingState == HoldSwapState.PENDING_SINGLE_CALL_UNHOLD
                || mHoldSwitchingState == HoldSwapState.SWAPPING_ACTIVE_AND_HELD) {
@@ -1287,17 +1295,22 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        }
        if (imsCall != null) {
            mCallExpectedToResume = imsCall;
            HoldSwapState oldHoldState = mHoldSwitchingState;
            mHoldSwitchingState = HoldSwapState.PENDING_SINGLE_CALL_UNHOLD;
            mForegroundCall.switchWith(mBackgroundCall);
            logHoldSwapState("unholdCurrentCall");
            try {
                imsCall.resume();
                mMetrics.writeOnImsCommand(mPhone.getPhoneId(), imsCall.getSession(),
                        ImsCommand.IMS_CMD_RESUME);
            }
            } catch (ImsException e) {
                mForegroundCall.switchWith(mBackgroundCall);
                mHoldSwitchingState = oldHoldState;
                logHoldSwapState("unholdCurrentCall - fail");
                throw new CallStateException(e.getMessage());
            }
        }
    }

    private void resumeForegroundCall() throws ImsException {
        //resume foreground call after holding background call
+25 −0
Original line number Diff line number Diff line
@@ -383,6 +383,31 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        assertEquals(1, mCTUT.mForegroundCall.getConnections().size());
    }

    @Test
    @SmallTest
    public void testImsHoldException() throws Exception {
        testImsMTCallAccept();
        doThrow(new ImsException()).when(mImsCall).hold();
        try {
            mCTUT.holdActiveCall();
            Assert.fail("No exception thrown");
        } catch (Exception e) {
            // expected
            verify(mImsCall).hold();
        }

        // After the first hold exception, try holding (successfully) again to make sure that it
        // goes through
        doNothing().when(mImsCall).hold();
        try {
            mCTUT.holdActiveCall();
            verify(mImsCall, times(2)).hold();
        } catch (Exception ex) {
            ex.printStackTrace();
            Assert.fail("unexpected exception thrown" + ex.getMessage());
        }
    }

    @Test
    @SmallTest
    public void testImsMTCallReject() {