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

Commit f956a710 authored by sangyun's avatar sangyun
Browse files

Modified to validate number of phones in scheduled retry

The scheduled retry has the target phone ID in the message. If the
number of phones decreases before the schedule is fired, validating
the phone ID in the message is required before run retry.

Bug: 273755617
Test: atest FrameworksTelephonyTests
Change-Id: Ib429fdbd691b8dd80f04726cad7feebd914bc810
parent d638c8c8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -846,6 +846,9 @@ public class PhoneSwitcher extends Handler {
            }
            case EVENT_MODEM_COMMAND_RETRY: {
                int phoneId = (int) msg.obj;
                if (mActiveModemCount <= phoneId) {
                    break;
                }
                if (isPhoneIdValidForRetry(phoneId)) {
                    logl("EVENT_MODEM_COMMAND_RETRY: resend modem command on phone " + phoneId);
                    sendRilCommands(phoneId);
+30 −0
Original line number Diff line number Diff line
@@ -1831,6 +1831,36 @@ public class PhoneSwitcherTest extends TelephonyTest {
        verify(mMockRadioConfig, times(1)).setPreferredDataModem(eq(0), any());
    }

    @Test
    public void testScheduledRetryWhileMultiSimConfigChange() throws Exception {
        doReturn(true).when(mMockRadioConfig).isSetPreferredDataCommandSupported();
        initialize();

        // Phone 0 has sub 1, phone 1 has sub 2.
        // Sub 1 is default data sub.
        setSlotIndexToSubId(0, 1);
        setSlotIndexToSubId(1, 2);

        // for EVENT_MODEM_COMMAND_RETRY
        AsyncResult res = new AsyncResult(
                1, null,  new CommandException(CommandException.Error.GENERIC_FAILURE));
        Message.obtain(mPhoneSwitcherUT, EVENT_MODEM_COMMAND_DONE, res).sendToTarget();
        processAllMessages();

        // reduce count of phone
        setNumPhones(1, 1);
        AsyncResult result = new AsyncResult(null, 1, null);
        Message.obtain(mPhoneSwitcherUT, EVENT_MULTI_SIM_CONFIG_CHANGED, result).sendToTarget();
        processAllMessages();

        // fire retries
        moveTimeForward(5000);
        processAllMessages();

        verify(mCommandsInterface0, never()).setDataAllowed(anyBoolean(), any());
        verify(mCommandsInterface1, never()).setDataAllowed(anyBoolean(), any());
    }

    /* Private utility methods start here */

    private void prepareIdealAutoSwitchCondition() {