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

Commit bd51ab74 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update PCM to ignore invalid modem updates and add UT." into main

parents caace341 a9ba8cb2
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -391,9 +391,12 @@ public class PhoneConfigurationManager {
                            }
                            mSlotsSupportingSimultaneousCellularCalls.add(i);
                        }
                        // Ensure the slots supporting cellular DSDA does not exceed the phone count
                        if (mSlotsSupportingSimultaneousCellularCalls.size() > getPhoneCount()) {
                            loge("Invalid size of DSDA slots. Disabling cellular DSDA.");
                        // Ensure the number of slots supporting cellular DSDA is valid:
                        if (mSlotsSupportingSimultaneousCellularCalls.size() > getPhoneCount() ||
                                mSlotsSupportingSimultaneousCellularCalls.size() < 2) {
                            loge("Invalid size of DSDA slots. Disabling cellular DSDA. Size of "
                                    + "mSlotsSupportingSimultaneousCellularCalls=" +
                                    mSlotsSupportingSimultaneousCellularCalls.size());
                            mSlotsSupportingSimultaneousCellularCalls.clear();
                        }
                    } else {
+53 −15
Original line number Diff line number Diff line
@@ -203,26 +203,40 @@ public class PhoneConfigurationManagerTest extends TelephonyTest {
        for (int i : enabledLogicalSlots) { expectedSlots.add(i); }
        assertEquals(expectedSlots, mPcm.getSlotsSupportingSimultaneousCellularCalls());
    }
    @Test
    @SmallTest
    public void testUpdateSimultaneousCallingSupportBothInvalidSlotIds() throws Exception {
        // Test case where both slot IDs are invalid (-1 and 5).
        testUpdateSimultaneousCallingSupportWithInvalidSlots(Arrays.asList(-1, 5));
    }

    @Test
    @SmallTest
    public void testUpdateSimultaneousCallingSupport_invalidResponse_shouldFail() throws Exception {
        doReturn(false).when(mFeatureFlags).simultaneousCallingIndications();
        init(2);
        mPcm.updateSimultaneousCallingSupport();
    public void testUpdateSimultaneousCallingSupportOneInvalidSlotId() throws Exception {
        // Test case where one slot ID is valid (1) and the other is invalid (2).
        testUpdateSimultaneousCallingSupportWithInvalidSlots(Arrays.asList(1, 2));
    }

        // Have the modem send invalid phone slots -1 and 5:
        List<Integer> invalidEnabledLogicalSlots = Arrays.asList(-1, 5);
        ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class);
        verify(mMockRadioConfig).updateSimultaneousCallingSupport(captor.capture());
        Message msg = captor.getValue();
        AsyncResult.forMessage(msg, invalidEnabledLogicalSlots, null);
        msg.sendToTarget();
        processAllMessages();
    @Test
    @SmallTest
    public void testUpdateSimultaneousCallingSupportInvalidExtraSlotId() throws Exception {
        // Test case where the number of slot IDs exceeds the phone count (2) and one slot ID is
        // invalid (2).
        testUpdateSimultaneousCallingSupportWithInvalidSlots(Arrays.asList(0, 1, 2));
    }

        // We would expect to DSDA to be disabled and mSlotsSupportingSimultaneousCellularCalls to
        // have been cleared:
        assertTrue(mPcm.getSlotsSupportingSimultaneousCellularCalls().isEmpty());
    @Test
    @SmallTest
    public void testUpdateSimultaneousCallingSupportInvalidSingularSlotId() throws Exception {
        // Test case where only a single, invalid slot ID (0) is provided.
        testUpdateSimultaneousCallingSupportWithInvalidSlots(List.of(0));
    }

    @Test
    @SmallTest
    public void testUpdateSimultaneousCallingSupportInvalidEmptySlotIds() throws Exception {
        // Test case where an empty list of slot IDs is provided.
        testUpdateSimultaneousCallingSupportWithInvalidSlots(List.of());
    }

    /**
@@ -576,4 +590,28 @@ public class PhoneConfigurationManagerTest extends TelephonyTest {

        assertEquals(capability, mPcm.getStaticPhoneCapability());
    }

    private void testUpdateSimultaneousCallingSupportWithInvalidSlots(List<Integer> invalidSlots)
            throws Exception {
        doReturn(false).when(mFeatureFlags).simultaneousCallingIndications();
        init(2);
        mPcm.updateSimultaneousCallingSupport();

        sendInvalidSlotsToModem(invalidSlots);
        processAllMessages();

        assertDsdaDisabledAndSlotsCleared();
    }

    private void sendInvalidSlotsToModem(List<Integer> invalidSlots) {
        ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class);
        verify(mMockRadioConfig).updateSimultaneousCallingSupport(captor.capture());
        Message msg = captor.getValue();
        AsyncResult.forMessage(msg, invalidSlots, null);
        msg.sendToTarget();
    }

    private void assertDsdaDisabledAndSlotsCleared() {
        assertTrue(mPcm.getSlotsSupportingSimultaneousCellularCalls().isEmpty());
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ public class SimultaneousCallingTrackerTest extends TelephonyTest {

    /**
     * Test that simultaneous calling is not supported when IMS is not registered and cellular
     * simultaneous calling is only supported for one SIM subscription.
     * simultaneous calling is not supported for any SIM subscriptions.
     */
    @Test
    @SmallTest
@@ -264,8 +264,8 @@ public class SimultaneousCallingTrackerTest extends TelephonyTest {
        init(2);
        setAndVerifyStaticCapability(STATIC_DSDA_CAPABILITY);

        // Have the modem inform telephony that only phone slot 0 supports DSDA:
        List<Integer> enabledLogicalSlots = List.of(0);
        // Have the modem inform telephony that no phone slots currently support DSDA:
        List<Integer> enabledLogicalSlots = List.of();
        setAndVerifySlotsSupportingSimultaneousCellularCalling(enabledLogicalSlots);

        // Trigger onSubscriptionsChanged by updating the subscription ID of a phone slot: