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

Commit 1a81ba7d authored by Hunsuk Choi's avatar Hunsuk Choi Committed by Android (Google) Code Review
Browse files

Merge "Fix handling of CODE_SIP_ALTERNATE_EMERGENCY_CALL and CODE_LOCAL_CALL_CS_RETRY_REQUIRED"

parents 502bb1c2 bc374488
Loading
Loading
Loading
Loading
+33 −7
Original line number Diff line number Diff line
@@ -3503,13 +3503,6 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                eccCategory = imsCall.getCallProfile().getEmergencyServiceCategories();
            }

            if (reasonInfo.getCode() == ImsReasonInfo.CODE_SIP_ALTERNATE_EMERGENCY_CALL) {
                ImsPhoneConnection conn = findConnection(imsCall);
                if (conn != null) {
                    conn.setNonDetectableEmergencyCallInfo(eccCategory);
                }
            }

            if (mHoldSwitchingState == HoldSwapState.HOLDING_TO_ANSWER_INCOMING) {
                // If we put a call on hold to answer an incoming call, we should reset the
                // variables that keep track of the switch here.
@@ -3529,6 +3522,27 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                                    reasonInfo.mExtraCode,
                                    reasonInfo.mExtraMessage));

            if (DomainSelectionResolver.getInstance().isDomainSelectionSupported()) {
                ImsPhoneConnection conn = findConnection(imsCall);
                // Since onCallInitiating and onCallProgressing reset mPendingMO,
                // we can't depend on mPendingMO.
                if ((reasonInfo.getCode() == ImsReasonInfo.CODE_SIP_ALTERNATE_EMERGENCY_CALL
                        || reasonInfo.getCode() == ImsReasonInfo.CODE_LOCAL_CALL_CS_RETRY_REQUIRED)
                        && conn != null) {
                    logi("onCallStartFailed eccCategory=" + eccCategory);
                    if (reasonInfo.getCode() == ImsReasonInfo.CODE_SIP_ALTERNATE_EMERGENCY_CALL
                            || reasonInfo.getExtraCode()
                                    == ImsReasonInfo.EXTRA_CODE_CALL_RETRY_EMERGENCY) {
                        conn.setNonDetectableEmergencyCallInfo(eccCategory);
                    }
                    conn.setImsReasonInfo(reasonInfo);
                    sendCallStartFailedDisconnect(imsCall, reasonInfo);
                    mMetrics.writeOnImsCallStartFailed(mPhone.getPhoneId(),
                            imsCall.getCallSession(), reasonInfo);
                    return;
                }
            }

            if (mPendingMO != null) {
                // To initiate dialing circuit-switched call
                if (reasonInfo.getCode() == ImsReasonInfo.CODE_LOCAL_CALL_CS_RETRY_REQUIRED
@@ -3688,6 +3702,18 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
            }

            if (reasonInfo.getCode() == ImsReasonInfo.CODE_SIP_ALTERNATE_EMERGENCY_CALL
                    && DomainSelectionResolver.getInstance().isDomainSelectionSupported()) {
                if (conn != null) {
                    int eccCategory = EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED;
                    if (imsCall != null && imsCall.getCallProfile() != null) {
                        eccCategory = imsCall.getCallProfile().getEmergencyServiceCategories();
                        logi("onCallTerminated eccCategory=" + eccCategory);
                    }
                    conn.setNonDetectableEmergencyCallInfo(eccCategory);
                }
                processCallStateChange(imsCall, ImsPhoneCall.State.DISCONNECTED, cause);
                return;
            } else if (reasonInfo.getCode() == ImsReasonInfo.CODE_SIP_ALTERNATE_EMERGENCY_CALL
                    && mAutoRetryFailedWifiEmergencyCall) {
                Pair<ImsCall, ImsReasonInfo> callInfo = new Pair<>(imsCall, reasonInfo);
                mPhone.getDefaultPhone().mCi.registerForOn(ImsPhoneCallTracker.this,
+43 −1
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.SrvccConnection;
import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.d2d.RtpTransport;
import com.android.internal.telephony.domainselection.DomainSelectionResolver;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker.VtDataUsageProvider;

import org.junit.After;
@@ -171,6 +172,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
    private INetworkStatsProviderCallback mVtDataUsageProviderCb;
    private ImsPhoneCallTracker.ConnectorFactory mConnectorFactory;
    private CommandsInterface mMockCi;
    private DomainSelectionResolver mDomainSelectionResolver;

    private final Executor mExecutor = Runnable::run;

@@ -237,6 +239,7 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        doReturn(ImsFeature.STATE_READY).when(mImsManager).getImsServiceState();
        doReturn(mImsCallProfile).when(mImsManager).createCallProfile(anyInt(), anyInt());
        mContextFixture.addSystemFeature(PackageManager.FEATURE_TELEPHONY_IMS);
        mDomainSelectionResolver = mock(DomainSelectionResolver.class);

        doAnswer(invocation -> {
            mMmTelListener = (MmTelFeature.Listener) invocation.getArguments()[0];
@@ -272,6 +275,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
            return mMockConnector;
        }).when(mConnectorFactory).create(any(), anyInt(), anyString(), any(), any());

        DomainSelectionResolver.setDomainSelectionResolver(mDomainSelectionResolver);
        doReturn(false).when(mDomainSelectionResolver).isDomainSelectionSupported();

        mCTUT = new ImsPhoneCallTracker(mImsPhone, mConnectorFactory, Runnable::run);
        mCTUT.setDataEnabled(true);

@@ -2399,7 +2405,8 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {

    @Test
    @SmallTest
    public void testDomainSelectionAlternateService() {
    public void testDomainSelectionAlternateServiceStartFailed() {
        doReturn(true).when(mDomainSelectionResolver).isDomainSelectionSupported();
        startOutgoingCall();
        ImsPhoneConnection c = mCTUT.mForegroundCall.getFirstConnection();
        mImsCallProfile.setEmergencyServiceCategories(EMERGENCY_SERVICE_CATEGORY_AMBULANCE);
@@ -2412,6 +2419,41 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
                emergencyNumber.getEmergencyServiceCategoryBitmask());
    }

    @Test
    @SmallTest
    public void testDomainSelectionAlternateServiceStartFailedNullPendingMO() {
        doReturn(true).when(mDomainSelectionResolver).isDomainSelectionSupported();
        startOutgoingCall();
        ImsPhoneConnection c = mCTUT.mForegroundCall.getFirstConnection();
        mImsCallListener.onCallProgressing(mSecondImsCall);
        processAllMessages();
        mImsCallProfile.setEmergencyServiceCategories(EMERGENCY_SERVICE_CATEGORY_AMBULANCE);
        mImsCallListener.onCallStartFailed(mSecondImsCall,
                new ImsReasonInfo(ImsReasonInfo.CODE_LOCAL_CALL_CS_RETRY_REQUIRED,
                        ImsReasonInfo.EXTRA_CODE_CALL_RETRY_EMERGENCY));
        processAllMessages();
        EmergencyNumber emergencyNumber = c.getEmergencyNumberInfo();
        assertNotNull(emergencyNumber);
        assertEquals(EMERGENCY_SERVICE_CATEGORY_AMBULANCE,
                emergencyNumber.getEmergencyServiceCategoryBitmask());
    }

    @Test
    @SmallTest
    public void testDomainSelectionAlternateServiceTerminated() {
        doReturn(true).when(mDomainSelectionResolver).isDomainSelectionSupported();
        startOutgoingCall();
        ImsPhoneConnection c = mCTUT.mForegroundCall.getFirstConnection();
        mImsCallProfile.setEmergencyServiceCategories(EMERGENCY_SERVICE_CATEGORY_AMBULANCE);
        mImsCallListener.onCallTerminated(mSecondImsCall,
                new ImsReasonInfo(ImsReasonInfo.CODE_SIP_ALTERNATE_EMERGENCY_CALL, -1));
        processAllMessages();
        EmergencyNumber emergencyNumber = c.getEmergencyNumberInfo();
        assertNotNull(emergencyNumber);
        assertEquals(EMERGENCY_SERVICE_CATEGORY_AMBULANCE,
                emergencyNumber.getEmergencyServiceCategoryBitmask());
    }

    @Test
    public void testUpdateImsCallStatusIncoming() throws Exception {
        // Incoming call