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

Commit 30cdeeae authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Stop local ringback on SRVCC."

parents d7c264c1 a4114d3b
Loading
Loading
Loading
Loading
+21 −11
Original line number Diff line number Diff line
@@ -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
@@ -96,7 +96,7 @@ public class ImsPhoneCall extends Call {
    @Override
    public Phone
    getPhone() {
        return mOwner.mPhone;
        return mOwner.getPhone();
    }

    @Override
@@ -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;
            }
        }

@@ -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;
+10 −0
Original line number Diff line number Diff line
@@ -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);
@@ -4071,4 +4077,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    public void setAlwaysPlayRemoteHoldTone(boolean shouldPlayRemoteHoldTone) {
        mAlwaysPlayRemoteHoldTone = shouldPlayRemoteHoldTone;
    }

    public ImsPhone getPhone() {
        return mPhone;
    }
}
+18 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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();
    }

@@ -119,8 +121,6 @@ public class ImsPhoneCallTest extends TelephonyTest {
        }
    }

    @FlakyTest
    @Ignore
    @Test
    @SmallTest
    public void testUpdateRingBackTone() {
@@ -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() {