Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +27 −14 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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()); } } Loading @@ -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(); Loading @@ -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()); } } Loading @@ -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"); Loading @@ -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()); } } Loading @@ -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) { Loading @@ -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 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 @@ -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; Loading @@ -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()); } } Loading @@ -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(); Loading @@ -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()); } } Loading @@ -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"); Loading @@ -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()); } } Loading @@ -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) { Loading @@ -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 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