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

Commit fa69e321 authored by Sangyun Yun's avatar Sangyun Yun Committed by Android (Google) Code Review
Browse files

Merge "Modified to validate number of phones in scheduled retry" into udc-dev

parents e69071bf f956a710
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() {