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

Commit 661e505b authored by Ling Ma's avatar Ling Ma
Browse files

Delay data switch untill call alerting

For emergency call placed on non-DDS when APM is on, modem expects an order of
commands: first the emergency call, then dds switch. If the order were reversed due to race condition, modem will abort the emergency call.

The change exclude the Dialing call state as the switch trigger, to give
modem time to deal with the EMC first.

Fix: 298291981
Fix: 284412852
Fix: 299585246
Test: Verified at b/298291981#comment82
Test: Daily test verified in b/299355154#comment5
Change-Id: Ia200072a44d6141ab4830d2143ae0483fa653856
parent 9550ecc5
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import static android.telephony.TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATIO
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_NONE;

import static java.util.Arrays.copyOf;

import android.annotation.NonNull;
@@ -73,6 +72,7 @@ import android.util.Log;
import com.android.ims.ImsException;
import com.android.ims.ImsManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.ISetOpportunisticDataCallback;
import com.android.internal.telephony.IccCard;
@@ -1678,8 +1678,14 @@ public class PhoneSwitcher extends Handler {
        }

        // A phone in voice call might trigger data being switched to it.
        // Exclude dialing to give modem time to process an EMC first before dealing with DDS switch
        // Include alerting because modem RLF leads to delay in switch, so carrier required to
        // switch in alerting phase.
        // TODO: check ringing call for vDADA
        return (!phone.getBackgroundCall().isIdle()
                || !phone.getForegroundCall().isIdle());
                && phone.getBackgroundCall().getState() != Call.State.DIALING)
                || (!phone.getForegroundCall().isIdle()
                && phone.getForegroundCall().getState() != Call.State.DIALING);
    }

    private void updateHalCommandToUse() {
+17 −4
Original line number Diff line number Diff line
@@ -26,10 +26,8 @@ import static android.telephony.TelephonyManager.SIM_STATE_LOADED;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_CROSS_SIM;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_IWLAN;
import static android.telephony.ims.stub.ImsRegistrationImplBase.REGISTRATION_TECH_LTE;

import static com.android.internal.telephony.data.AutoDataSwitchController.EVALUATION_REASON_VOICE_CALL_END;
import static com.android.internal.telephony.data.PhoneSwitcher.ECBM_DEFAULT_DATA_SWITCH_BASE_TIME_MS;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -121,6 +119,7 @@ public class PhoneSwitcherTest extends TelephonyTest {
    private GsmCdmaCall mInactiveCall;
    private GsmCdmaCall mDialCall;
    private GsmCdmaCall mIncomingCall;
    private GsmCdmaCall mAlertingCall;
    private ISetOpportunisticDataCallback mSetOpptDataCallback1;
    private ISetOpportunisticDataCallback mSetOpptDataCallback2;
    PhoneSwitcher.ImsRegTechProvider mMockImsRegTechProvider;
@@ -161,6 +160,7 @@ public class PhoneSwitcherTest extends TelephonyTest {
        mInactiveCall = mock(GsmCdmaCall.class);
        mDialCall = mock(GsmCdmaCall.class);
        mIncomingCall = mock(GsmCdmaCall.class);
        mAlertingCall = mock(GsmCdmaCall.class);
        mSetOpptDataCallback1 = mock(ISetOpportunisticDataCallback.class);
        mSetOpptDataCallback2 = mock(ISetOpportunisticDataCallback.class);
        mMockImsRegTechProvider = mock(PhoneSwitcher.ImsRegTechProvider.class);
@@ -176,6 +176,7 @@ public class PhoneSwitcherTest extends TelephonyTest {
        doReturn(Call.State.HOLDING).when(mHoldingCall).getState();
        doReturn(Call.State.DIALING).when(mDialCall).getState();
        doReturn(Call.State.INCOMING).when(mIncomingCall).getState();
        doReturn(Call.State.ALERTING).when(mAlertingCall).getState();

        doReturn(true).when(mInactiveCall).isIdle();
        doReturn(false).when(mActiveCall).isIdle();
@@ -878,13 +879,19 @@ public class PhoneSwitcherTest extends TelephonyTest {
        // Phone 0 should be the default data phoneId.
        assertEquals(0, mPhoneSwitcherUT.getPreferredDataPhoneId());

        // Phone2 has active IMS call on LTE. And data of DEFAULT apn is enabled. This should
        // trigger data switch.
        // Dialing shouldn't trigger switch because we give modem time to deal with the dialing call
        // first. Phone2 has active IMS call on LTE. And data of DEFAULT apn is enabled.
        doReturn(mImsPhone).when(mPhone2).getImsPhone();
        doReturn(true).when(mPhone2).isDataAllowed();
        mockImsRegTech(1, REGISTRATION_TECH_LTE);
        notifyPhoneAsInDial(mImsPhone);

        // Phone1 should remain as the preferred data phone
        assertEquals(0, mPhoneSwitcherUT.getPreferredDataPhoneId());

        // Dialing -> Alert, should trigger phone switch
        notifyPhoneAsAlerting(mImsPhone);

        // Phone2 should be preferred data phone
        assertEquals(1, mPhoneSwitcherUT.getPreferredDataPhoneId());
    }
@@ -1709,6 +1716,12 @@ public class PhoneSwitcherTest extends TelephonyTest {
        processAllMessages();
    }

    private void notifyPhoneAsAlerting(Phone phone) {
        doReturn(mAlertingCall).when(phone).getForegroundCall();
        mPhoneSwitcherUT.sendEmptyMessage(EVENT_PRECISE_CALL_STATE_CHANGED);
        processAllMessages();
    }

    private void notifyPhoneAsInIncomingCall(Phone phone) {
        doReturn(mIncomingCall).when(phone).getForegroundCall();
        mPhoneSwitcherUT.sendEmptyMessage(EVENT_PRECISE_CALL_STATE_CHANGED);