Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCall.java +21 −11 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ public class ImsPhoneCall extends Call { /*package*/ ImsPhoneCallTracker mOwner; private boolean mRingbackTonePlayed = false; private boolean mIsRingbackTonePlaying = false; // Determines what type of ImsPhoneCall this is. ImsPhoneCallTracker uses instances of // ImsPhoneCall to for fg, bg, etc calls. This is used as a convenience for logging so that it Loading Loading @@ -96,7 +96,7 @@ public class ImsPhoneCall extends Call { @Override public Phone getPhone() { return mOwner.mPhone; return mOwner.getPhone(); } @Override Loading Loading @@ -314,17 +314,17 @@ public class ImsPhoneCall extends Call { //ImsCall.Listener.onCallProgressing can be invoked several times //and ringback tone mode can be changed during the call setup procedure if (state == State.ALERTING) { if (mRingbackTonePlayed && !isLocalTone(imsCall)) { mOwner.mPhone.stopRingbackTone(); mRingbackTonePlayed = false; } else if (!mRingbackTonePlayed && isLocalTone(imsCall)) { mOwner.mPhone.startRingbackTone(); mRingbackTonePlayed = true; if (mIsRingbackTonePlaying && !isLocalTone(imsCall)) { getPhone().stopRingbackTone(); mIsRingbackTonePlaying = false; } else if (!mIsRingbackTonePlaying && isLocalTone(imsCall)) { getPhone().startRingbackTone(); mIsRingbackTonePlaying = true; } } else { if (mRingbackTonePlayed) { mOwner.mPhone.stopRingbackTone(); mRingbackTonePlayed = false; if (mIsRingbackTonePlaying) { getPhone().stopRingbackTone(); mIsRingbackTonePlaying = false; } } Loading Loading @@ -360,6 +360,16 @@ public class ImsPhoneCall extends Call { mOwner.logState(); } /** * Stops ringback tone playing if it is playing. */ public void maybeStopRingback() { if (mIsRingbackTonePlaying) { getPhone().stopRingbackTone(); mIsRingbackTonePlaying = false; } } private void takeOver(ImsPhoneCall that) { mConnections = that.mConnections; mState = that.mState; Loading src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +10 −0 Original line number Diff line number Diff line Loading @@ -2719,6 +2719,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { ImsPhoneConnection conn = findConnection(imsCall); if (conn != null) { ImsPhoneCall imsPhoneCall = conn.getCall(); if (imsPhoneCall != null) { // We might be playing ringback on the handover connection; we should stop // playing it at this point (otherwise it could play indefinitely). imsPhoneCall.maybeStopRingback(); } if (conn.getDisconnectCause() == DisconnectCause.NOT_DISCONNECTED) { if (isHandoverToWifi) { removeMessages(EVENT_CHECK_FOR_WIFI_HANDOVER); Loading Loading @@ -4071,4 +4077,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { public void setAlwaysPlayRemoteHoldTone(boolean shouldPlayRemoteHoldTone) { mAlwaysPlayRemoteHoldTone = shouldPlayRemoteHoldTone; } public ImsPhone getPhone() { return mPhone; } } tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.telephony.ims.ImsStreamMediaProfile; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -54,6 +55,7 @@ public class ImsPhoneCallTest extends TelephonyTest { replaceInstance(ImsPhoneCallTracker.class, "mPhone", mImsCT, mImsPhone); mImsCallUT = new ImsPhoneCall(mImsCT, ImsPhoneCall.CONTEXT_FOREGROUND); when(mImsCT.getPhone()).thenReturn(mImsPhone); mMediaProfile = new ImsStreamMediaProfile(); } Loading Loading @@ -119,8 +121,6 @@ public class ImsPhoneCallTest extends TelephonyTest { } } @FlakyTest @Ignore @Test @SmallTest public void testUpdateRingBackTone() { Loading @@ -136,6 +136,22 @@ public class ImsPhoneCallTest extends TelephonyTest { assertEquals(Call.State.ACTIVE, mImsCallUT.getState()); } @Test @SmallTest public void testStopRingingOnHandover() { //Mock local tone mMediaProfile.mAudioDirection = ImsStreamMediaProfile.DIRECTION_INACTIVE; mImsCallProfile.mMediaProfile = mMediaProfile; mImsCallUT.update(null, mImsCall, Call.State.ALERTING); verify(mImsPhone, times(1)).startRingbackTone(); assertEquals(Call.State.ALERTING, mImsCallUT.getState()); // Emulate ringback terminate on handover. mImsCallUT.maybeStopRingback(); verify(mImsPhone, times(1)).stopRingbackTone(); } @Test @SmallTest public void testSwitchWith() { Loading Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneCall.java +21 −11 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ public class ImsPhoneCall extends Call { /*package*/ ImsPhoneCallTracker mOwner; private boolean mRingbackTonePlayed = false; private boolean mIsRingbackTonePlaying = false; // Determines what type of ImsPhoneCall this is. ImsPhoneCallTracker uses instances of // ImsPhoneCall to for fg, bg, etc calls. This is used as a convenience for logging so that it Loading Loading @@ -96,7 +96,7 @@ public class ImsPhoneCall extends Call { @Override public Phone getPhone() { return mOwner.mPhone; return mOwner.getPhone(); } @Override Loading Loading @@ -314,17 +314,17 @@ public class ImsPhoneCall extends Call { //ImsCall.Listener.onCallProgressing can be invoked several times //and ringback tone mode can be changed during the call setup procedure if (state == State.ALERTING) { if (mRingbackTonePlayed && !isLocalTone(imsCall)) { mOwner.mPhone.stopRingbackTone(); mRingbackTonePlayed = false; } else if (!mRingbackTonePlayed && isLocalTone(imsCall)) { mOwner.mPhone.startRingbackTone(); mRingbackTonePlayed = true; if (mIsRingbackTonePlaying && !isLocalTone(imsCall)) { getPhone().stopRingbackTone(); mIsRingbackTonePlaying = false; } else if (!mIsRingbackTonePlaying && isLocalTone(imsCall)) { getPhone().startRingbackTone(); mIsRingbackTonePlaying = true; } } else { if (mRingbackTonePlayed) { mOwner.mPhone.stopRingbackTone(); mRingbackTonePlayed = false; if (mIsRingbackTonePlaying) { getPhone().stopRingbackTone(); mIsRingbackTonePlaying = false; } } Loading Loading @@ -360,6 +360,16 @@ public class ImsPhoneCall extends Call { mOwner.logState(); } /** * Stops ringback tone playing if it is playing. */ public void maybeStopRingback() { if (mIsRingbackTonePlaying) { getPhone().stopRingbackTone(); mIsRingbackTonePlaying = false; } } private void takeOver(ImsPhoneCall that) { mConnections = that.mConnections; mState = that.mState; Loading
src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java +10 −0 Original line number Diff line number Diff line Loading @@ -2719,6 +2719,12 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { ImsPhoneConnection conn = findConnection(imsCall); if (conn != null) { ImsPhoneCall imsPhoneCall = conn.getCall(); if (imsPhoneCall != null) { // We might be playing ringback on the handover connection; we should stop // playing it at this point (otherwise it could play indefinitely). imsPhoneCall.maybeStopRingback(); } if (conn.getDisconnectCause() == DisconnectCause.NOT_DISCONNECTED) { if (isHandoverToWifi) { removeMessages(EVENT_CHECK_FOR_WIFI_HANDOVER); Loading Loading @@ -4071,4 +4077,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall { public void setAlwaysPlayRemoteHoldTone(boolean shouldPlayRemoteHoldTone) { mAlwaysPlayRemoteHoldTone = shouldPlayRemoteHoldTone; } public ImsPhone getPhone() { return mPhone; } }
tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.telephony.ims.ImsStreamMediaProfile; import android.test.suitebuilder.annotation.SmallTest; Loading Loading @@ -54,6 +55,7 @@ public class ImsPhoneCallTest extends TelephonyTest { replaceInstance(ImsPhoneCallTracker.class, "mPhone", mImsCT, mImsPhone); mImsCallUT = new ImsPhoneCall(mImsCT, ImsPhoneCall.CONTEXT_FOREGROUND); when(mImsCT.getPhone()).thenReturn(mImsPhone); mMediaProfile = new ImsStreamMediaProfile(); } Loading Loading @@ -119,8 +121,6 @@ public class ImsPhoneCallTest extends TelephonyTest { } } @FlakyTest @Ignore @Test @SmallTest public void testUpdateRingBackTone() { Loading @@ -136,6 +136,22 @@ public class ImsPhoneCallTest extends TelephonyTest { assertEquals(Call.State.ACTIVE, mImsCallUT.getState()); } @Test @SmallTest public void testStopRingingOnHandover() { //Mock local tone mMediaProfile.mAudioDirection = ImsStreamMediaProfile.DIRECTION_INACTIVE; mImsCallProfile.mMediaProfile = mMediaProfile; mImsCallUT.update(null, mImsCall, Call.State.ALERTING); verify(mImsPhone, times(1)).startRingbackTone(); assertEquals(Call.State.ALERTING, mImsCallUT.getState()); // Emulate ringback terminate on handover. mImsCallUT.maybeStopRingback(); verify(mImsPhone, times(1)).stopRingbackTone(); } @Test @SmallTest public void testSwitchWith() { Loading