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

Commit 503d2820 authored by Tyler Gunn's avatar Tyler Gunn Committed by Automerger Merge Worker
Browse files

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

Merge "Ensure IMS calls are disconnected when WPS call is forced over CS." am: da81de26 am: 27206718 am: affa0ec4 am: 28f10799

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/1492301

Change-Id: Ie9508f8568fd76cf60adb8f2cbe7c7dc9a3b5b7c
parents e0f7d925 28f10799
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;
@@ -1334,6 +1335,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
@@ -1050,6 +1050,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);
    }
}