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

Commit 93e5a07b authored by Amit Mahajan's avatar Amit Mahajan Committed by android-build-merger
Browse files

Merge "Clean up calls gracefully on phone type switch." am: af96f41f

am: 8a5a72a0

Change-Id: I4619ed9c65e2bcbeafb7e07659a164df58add6d9
parents c19462e1 8a5a72a0
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.telephony.gsm.GsmCellLocation;
import android.text.TextUtils;
import android.util.EventLog;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
import com.android.internal.telephony.metrics.TelephonyMetrics;

@@ -68,7 +69,8 @@ public class GsmCdmaCallTracker extends CallTracker {
    private static final int MAX_CONNECTIONS_PER_CALL_CDMA = 1; //only 1 connection allowed per call

    //***** Instance Variables
    private GsmCdmaConnection mConnections[];
    @VisibleForTesting
    public GsmCdmaConnection[] mConnections;
    private RegistrantList mVoiceCallEndedRegistrants = new RegistrantList();
    private RegistrantList mVoiceCallStartedRegistrants = new RegistrantList();

@@ -187,10 +189,9 @@ public class GsmCdmaCallTracker extends CallTracker {
    private void reset() {
        Rlog.d(LOG_TAG, "reset");

        clearDisconnected();

        for (GsmCdmaConnection gsmCdmaConnection : mConnections) {
            if (gsmCdmaConnection != null) {
                gsmCdmaConnection.onDisconnect(DisconnectCause.ERROR_UNSPECIFIED);
                gsmCdmaConnection.dispose();
            }
        }
@@ -201,7 +202,7 @@ public class GsmCdmaCallTracker extends CallTracker {

        mConnections = null;
        mPendingMO = null;
        mState = PhoneConstants.State.IDLE;
        clearDisconnected();
    }

    @Override
+35 −10
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
    private GsmCdmaCallTracker mCTUT;
    private GsmCdmaCTHandlerThread mGsmCdmaCTHandlerThread;
    @Mock
    GsmCdmaCall mCall;
    GsmCdmaConnection mConnection;
    @Mock
    private Handler mHandler;

@@ -166,8 +166,8 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        assertEquals(PhoneConstants.State.OFFHOOK, mCTUT.getState());
        assertEquals(1, mCTUT.mForegroundCall.getConnections().size());
         /* get the reference of the connection before reject */
        Connection mConnection = mCTUT.mForegroundCall.getConnections().get(0);
        assertEquals(DisconnectCause.NOT_DISCONNECTED, mConnection.getDisconnectCause());
        Connection connection = mCTUT.mForegroundCall.getConnections().get(0);
        assertEquals(DisconnectCause.NOT_DISCONNECTED, connection.getDisconnectCause());
        logd("hang up MO call after pickup");
        try {
            mCTUT.hangup(mCTUT.mForegroundCall);
@@ -180,7 +180,7 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        assertEquals(GsmCdmaCall.State.IDLE, mCTUT.mForegroundCall.getState());
        assertEquals(0, mCTUT.mForegroundCall.getConnections().size());
        assertEquals(PhoneConstants.State.IDLE, mCTUT.getState());
        assertEquals(DisconnectCause.LOCAL, mConnection.getDisconnectCause());
        assertEquals(DisconnectCause.LOCAL, connection.getDisconnectCause());

    }

@@ -276,9 +276,9 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        testMTCallRinging();
        logd("MT call ringing and rejected ");
        /* get the reference of the connection before reject */
        Connection mConnection = mCTUT.mRingingCall.getConnections().get(0);
        assertNotNull(mConnection);
        assertEquals(DisconnectCause.NOT_DISCONNECTED, mConnection.getDisconnectCause());
        Connection connection = mCTUT.mRingingCall.getConnections().get(0);
        assertNotNull(connection);
        assertEquals(DisconnectCause.NOT_DISCONNECTED, connection.getDisconnectCause());
        try {
            mCTUT.rejectCall();
        } catch(Exception ex) {
@@ -290,7 +290,7 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        assertEquals(GsmCdmaCall.State.IDLE, mCTUT.mForegroundCall.getState());
        assertEquals(0, mCTUT.mForegroundCall.getConnections().size());
        /* ? why rejectCall didnt -> hang up locally to set the cause to LOCAL? */
        assertEquals(DisconnectCause.INCOMING_MISSED, mConnection.getDisconnectCause());
        assertEquals(DisconnectCause.INCOMING_MISSED, connection.getDisconnectCause());

    }

@@ -353,7 +353,8 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        testMOCallPickUp();
        ArgumentCaptor<Message> mCaptorMessage = ArgumentCaptor.forClass(Message.class);
        ArgumentCaptor<Long> mCaptorLong = ArgumentCaptor.forClass(Long.class);
        verify(mHandler,times(1)).sendMessageAtTime(mCaptorMessage.capture(), mCaptorLong.capture());
        verify(mHandler, times(1))
                .sendMessageAtTime(mCaptorMessage.capture(), mCaptorLong.capture());
        assertEquals(VOICE_CALL_STARTED_EVENT, mCaptorMessage.getValue().what);

    }
@@ -367,7 +368,8 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        ArgumentCaptor<Message> mCaptorMessage = ArgumentCaptor.forClass(Message.class);
        ArgumentCaptor<Long> mCaptorLong = ArgumentCaptor.forClass(Long.class);
        testMOCallHangup();
        verify(mHandler,times(1)).sendMessageAtTime(mCaptorMessage.capture(), mCaptorLong.capture());
        verify(mHandler, times(1))
                .sendMessageAtTime(mCaptorMessage.capture(), mCaptorLong.capture());
        assertEquals(VOICE_CALL_ENDED_EVENT, mCaptorMessage.getValue().what);
    }

@@ -407,5 +409,28 @@ public class GsmCdmaCallTrackerTest extends TelephonyTest {
        assertEquals(GsmCdmaCall.State.IDLE, mCTUT.mBackgroundCall.getState());
        assertEquals(GsmCdmaCall.State.IDLE, mCTUT.mRingingCall.getState());
    }

    @Test
    @SmallTest
    public void testUpdatePhoneTypeWithActiveCall() {
        // verify getCurrentCalls is called on init
        verify(mSimulatedCommandsVerifier).getCurrentCalls(any(Message.class));

        // fake connection
        mCTUT.mConnections[0] = mConnection;

        // update phone type (call the function on same thread as the call tracker)
        Handler updatePhoneTypeHandler = new Handler(mCTUT.getLooper()) {
            @Override
            public void handleMessage(Message msg) {
                mCTUT.updatePhoneType();
            }
        };
        updatePhoneTypeHandler.sendEmptyMessage(0);
        waitForMs(100);

        // verify that the active call is disconnected
        verify(mConnection).onDisconnect(DisconnectCause.ERROR_UNSPECIFIED);
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import com.android.internal.util.StateMachine;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -225,6 +226,8 @@ public class GsmInboundSmsHandlerTest extends TelephonyTest {
        assertEquals("IdleState", getCurrentState().getName());
    }

    @FlakyTest
    @Ignore
    @Test
    @MediumTest
    public void testNewSms() {