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

Commit 931aabfd authored by Jack Yu's avatar Jack Yu
Browse files

Fixed getAccessibleSubscriptionInfoList returns the non-embedded sub

getAccessibleSubscriptionInfoList should only return accessible
embedded subscriptions.

Fix: 272337651
Test: atest SubscriptionManagerServiceTest
Test: Basic phone funcationality tests
Merged-In: I9758f8b05f03935e375297cca2874790ae2f2f94
Change-Id: I9758f8b05f03935e375297cca2874790ae2f2f94
parent 22f2f483
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1896,8 +1896,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
@@ -948,21 +948,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