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

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

Merge "Fixed getAccessibleSubscriptionInfoList returns the non-embedded sub" into udc-dev

parents 8eedd452 07f37619
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1919,8 +1919,8 @@ public class SubscriptionManagerService extends ISub.Stub {

        return mSubscriptionDatabaseManager.getAllSubscriptions().stream()
                .map(SubscriptionInfoInternal::toSubscriptionInfo)
                .filter(subInfo -> mSubscriptionManager
                        .canManageSubscription(subInfo, callingPackage))
                .filter(subInfo -> subInfo.isEmbedded()
                        && mSubscriptionManager.canManageSubscription(subInfo, callingPackage))
                .sorted(Comparator.comparing(SubscriptionInfo::getSimSlotIndex)
                        .thenComparing(SubscriptionInfo::getSubscriptionId))
                .collect(Collectors.toList());
+15 −3
Original line number Diff line number Diff line
@@ -941,21 +941,33 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {

    @Test
    public void testGetAccessibleSubscriptionInfoList() {
        doReturn(true).when(mEuiccManager).isEnabled();
        insertSubscription(FAKE_SUBSCRIPTION_INFO2);

        doReturn(true).when(mSubscriptionManager).canManageSubscription(
                any(SubscriptionInfo.class), eq(CALLING_PACKAGE));
        // FAKE_SUBSCRIPTION_INFO2 is a not eSIM. So the list should be empty.
        assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
                CALLING_PACKAGE)).isEmpty();

        insertSubscription(FAKE_SUBSCRIPTION_INFO1);

        doReturn(false).when(mEuiccManager).isEnabled();
        assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
                CALLING_PACKAGE)).isNull();

        doReturn(false).when(mSubscriptionManager).canManageSubscription(
                any(SubscriptionInfo.class), eq(CALLING_PACKAGE));

        doReturn(true).when(mEuiccManager).isEnabled();
        assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
                CALLING_PACKAGE)).isEmpty();

        doReturn(true).when(mSubscriptionManager).canManageSubscription(
                eq(FAKE_SUBSCRIPTION_INFO1.toSubscriptionInfo()), eq(CALLING_PACKAGE));

                any(SubscriptionInfo.class), eq(CALLING_PACKAGE));
        assertThat(mSubscriptionManagerServiceUT.getAccessibleSubscriptionInfoList(
                CALLING_PACKAGE)).isEqualTo(List.of(FAKE_SUBSCRIPTION_INFO1.toSubscriptionInfo()));
                CALLING_PACKAGE)).isEqualTo(List.of(new SubscriptionInfoInternal.Builder(
                        FAKE_SUBSCRIPTION_INFO1).setId(2).build().toSubscriptionInfo()));
    }

    @Test