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

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

Merge "Ensure IMS calls are disconnected when WPS call is forced over CS."

parents 960fe339 a157e5d9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import com.android.internal.telephony.dataconnection.TransportManager;
import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.imsphone.ImsPhoneMmiCode;
import com.android.internal.telephony.metrics.VoiceCallSessionStats;
import com.android.internal.telephony.test.SimulatedRadioControl;
@@ -1330,6 +1331,12 @@ public class GsmCdmaPhone extends Phone {
        }

        Phone.checkWfcWifiOnlyModeBeforeDial(mImsPhone, mPhoneId, mContext);
        if (imsPhone != null && !allowWpsOverIms && !useImsForCall && isWpsCall
                && imsPhone.getCallTracker() instanceof ImsPhoneCallTracker) {
            logi("WPS call placed over CS; disconnecting all IMS calls..");
            ImsPhoneCallTracker tracker = (ImsPhoneCallTracker) imsPhone.getCallTracker();
            tracker.hangupAllConnections();
        }

        if ((useImsForCall && (!isMmiCode || isPotentialUssdCode))
                || (isMmiCode && useImsForUt)
+14 −0
Original line number Diff line number Diff line
@@ -1041,6 +1041,20 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        updatePhoneState();
    }

    /**
     * Requests modem to hang up all connections.
     */
    public void hangupAllConnections() {
        getConnections().stream().forEach(c -> {
            logi("Disconnecting callId = " + c.getTelecomCallId());
            try {
                c.hangup();
            } catch (CallStateException e) {
                loge("Failed to disconnet call...");
            }
        });
    }

    private void sendImsServiceStateIntent(String intentAction) {
        Intent intent = new Intent(intentAction);
        intent.putExtra(ImsManager.EXTRA_PHONE_ID, mPhone.getPhoneId());
+48 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.Intent;
import android.content.SharedPreferences;
@@ -492,6 +493,42 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        }
    }

    @Test
    @SmallTest
    public void testWpsDialOverCs() throws Exception {
        try {
            setupForWpsCallTest();

            mContextFixture.getCarrierConfigBundle().putBoolean(
                    CarrierConfigManager.KEY_SUPPORT_WPS_OVER_IMS_BOOL, false);

            Connection connection = mPhoneUT.dial("*27216505551212",
                    new PhoneInternalInterface.DialArgs.Builder().build());
            verify(mCT).dialGsm("*27216505551212", null, null);
            verify(mImsCT).hangupAllConnections();
        } catch (CallStateException e) {
            fail();
        }
    }

    @Test
    @SmallTest
    public void testWpsDialOverIms() throws Exception {
        try {
            setupForWpsCallTest();

            mContextFixture.getCarrierConfigBundle().putBoolean(
                    CarrierConfigManager.KEY_SUPPORT_WPS_OVER_IMS_BOOL, true);

            Connection connection = mPhoneUT.dial("*27216505551212",
                    new PhoneInternalInterface.DialArgs.Builder().build());
            verify(mCT).dialGsm("*27216505551212", null, null);
            verify(mImsCT, never()).hangupAllConnections();
        } catch (CallStateException e) {
            fail();
        }
    }

    @Test
    @SmallTest
    public void testHandlePinMmi() {
@@ -1386,4 +1423,15 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        verify(mMockCi).getRadioCapability(captor.capture());
        assertEquals(captor.getValue().what, Phone.EVENT_GET_RADIO_CAPABILITY);
    }

    private void setupForWpsCallTest() throws Exception {
        mSST.mSS = mServiceState;
        doReturn(ServiceState.STATE_IN_SERVICE).when(mServiceState).getState();
        when(mImsPhone.getCallTracker()).thenReturn(mImsCT);
        mCT.mForegroundCall = mGsmCdmaCall;
        mCT.mBackgroundCall = mGsmCdmaCall;
        mCT.mRingingCall = mGsmCdmaCall;
        doReturn(GsmCdmaCall.State.IDLE).when(mGsmCdmaCall).getState();
        replaceInstance(Phone.class, "mImsPhone", mPhoneUT, mImsPhone);
    }
}