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

Commit 9f26a372 authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

Merge "Stop local ringback on SRVCC." am: 30cdeeae am: 211258d5

am: e4971eab

Change-Id: I8d4f26816f83bd16e28c2567f0237e2f26d08894
parents 30706c16 e4971eab
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() {