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

Commit a9ba8cb2 authored by Grant Menke's avatar Grant Menke
Browse files

Update PCM to ignore invalid modem updates and add UT.

This CL updates the logic in PhoneConfigurationManager to ignore the invalid DSDA support modem update of a singular phone slot. This CL also adds UT to reflect this change and additional scenarios that did not have test cases.

Fixes: 316918991
Test: atest PhoneConfigurationManagerTest
Flag: com.android.internal.telephony.flags.simultaneous_calling_indications
Change-Id: I7472b9b1b2a26a7c17a2358717dc5dc28b91dd92
parent 88c9f84c
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: