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

Commit 6bb40635 authored by Ling Ma's avatar Ling Ma
Browse files

Always switch if default is OOS

When RAT+SignalStrength is enabled, it uses tolerence to decide whether a switch can be justified. But if the default is OOS, we can ignore the tolerance and switch to the secondary as long as it has service.

Test: basic call + data browsing
Bug: 304835724
Change-Id: I7618a289fb7f867ae86c0d9ac716971f8aa6f95d
parent 4c36ab91
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -638,8 +638,10 @@ public class AutoDataSwitchController extends Handler {
                Phone secondaryDataPhone = null;
                debugMessage.append(", found phone ").append(phoneId).append(" in HOME reg");

                if (isInService(mPhonesSignalStatus[defaultPhoneId].mDataRegState)) {
                    // Use score if RAT/signal strength based switch is enabled and both phone are
                    // in service.
                    if (isRatSignalStrengthBasedSwitchEnabled()) {
                    // Use score if RAT/signal strength based switch is enabled.
                        int defaultScore = mPhonesSignalStatus[defaultPhoneId].getRatSignalScore();
                        int candidateScore = mPhonesSignalStatus[phoneId].getRatSignalScore();
                        if ((candidateScore - defaultScore) > mScoreTolerance) {
@@ -651,6 +653,7 @@ public class AutoDataSwitchController extends Handler {
                                    .append(" doesn't meet the bar to switch given the current ")
                                    .append(defaultScore);
                        }
                    }
                } else {
                    // Only OOS/in service switch is enabled.
                    secondaryDataPhone = PhoneFactory.getPhone(phoneId);
+27 −2
Original line number Diff line number Diff line
@@ -170,12 +170,24 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {
        // Verify attempting to switch
        verify(mMockedPhoneSwitcherCallback).onRequireValidation(PHONE_2, true/*needValidation*/);

        // 1. Service state becomes not ideal - secondary lost its advantage score
        // 1.1 Service state becomes not ideal - secondary lost its advantage score,
        // but primary is OOS, so continue to switch.
        clearInvocations(mMockedPhoneSwitcherCallback);
        displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo);
        signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_POOR);
        processAllFutureMessages();

        verify(mMockedPhoneSwitcherCallback, never())
                .onRequireCancelAnyPendingAutoSwitchValidation();

        // 1.2 Service state becomes not ideal - secondary lost its advantage score,
        // since primary is in service, no need to switch.
        clearInvocations(mMockedPhoneSwitcherCallback);
        serviceStateChanged(PHONE_1, NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
        displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo);
        signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_POOR);
        processAllFutureMessages();

        verify(mMockedPhoneSwitcherCallback).onRequireCancelAnyPendingAutoSwitchValidation();

        // 2.1 User data disabled on primary SIM
@@ -211,13 +223,26 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {

    @Test
    public void testCancelSwitch_onPrimary_rat_signalStrength() {
        // 4.1 Display info and signal strength on secondary phone became bad
        // 4.1.1 Display info and signal strength on secondary phone became bad,
        // but primary is still OOS, so still switch to the secondary.
        prepareIdealUsesNonDdsCondition();
        processAllFutureMessages();
        clearInvocations(mMockedPhoneSwitcherCallback);
        displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo);
        signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_MODERATE);
        processAllFutureMessages();
        verify(mMockedPhoneSwitcherCallback, never())
                .onRequireCancelAnyPendingAutoSwitchValidation();

        // 4.1.2 Display info and signal strength on secondary phone became bad,
        // but primary become service, then don't switch.
        prepareIdealUsesNonDdsCondition();
        processAllFutureMessages();
        clearInvocations(mMockedPhoneSwitcherCallback);
        serviceStateChanged(PHONE_1, NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
        displayInfoChanged(PHONE_2, mBadTelephonyDisplayInfo);
        signalStrengthChanged(PHONE_2, SignalStrength.SIGNAL_STRENGTH_MODERATE);
        processAllFutureMessages();
        verify(mMockedPhoneSwitcherCallback).onRequireCancelAnyPendingAutoSwitchValidation();

        // 4.2 Display info on default phone became good just as the secondary