Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +27 −14 Original line number Diff line number Diff line Loading @@ -1213,6 +1213,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; Loading @@ -1225,6 +1226,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()); } } Loading @@ -1239,6 +1242,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(); Loading @@ -1254,6 +1258,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()); } } Loading @@ -1267,6 +1273,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"); Loading @@ -1276,6 +1283,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()); } } Loading @@ -1285,7 +1294,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) { Loading @@ -1294,17 +1302,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 Loading tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +27 −14 Original line number Diff line number Diff line Loading @@ -1213,6 +1213,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; Loading @@ -1225,6 +1226,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()); } } Loading @@ -1239,6 +1242,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(); Loading @@ -1254,6 +1258,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()); } } Loading @@ -1267,6 +1273,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"); Loading @@ -1276,6 +1283,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()); } } Loading @@ -1285,7 +1294,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) { Loading @@ -1294,17 +1302,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 Loading
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -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() { Loading