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

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

Merge "Initialized allowed network types"

parents d8af5888 aa4889d0
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2484,7 +2484,14 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        }
    }

    private String convertAllowedNetworkTypeMapIndexToDbName(
    /**
     * Convert the allowed network types reason to string.
     *
     * @param reason The allowed network types reason.
     *
     * @return The converted string.
     */
    public static String convertAllowedNetworkTypeMapIndexToDbName(
            @TelephonyManager.AllowedNetworkTypesReason int reason) {
        switch (reason) {
            case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER:
+49 −70
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import android.service.euicc.GetEuiccProfileInfoListResult;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.CarrierConfigManager;
import android.telephony.RadioAccessFamily;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.DataRoamingMode;
@@ -84,6 +85,7 @@ import com.android.internal.telephony.MccTable;
import com.android.internal.telephony.MultiSimSettingController;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyPermissions;
@@ -970,6 +972,35 @@ public class SubscriptionManagerService extends ISub.Stub {
        return TelephonyManager.INVALID_PORT_INDEX;
    }

    /**
     * Insert a new subscription into the database.
     *
     * @param iccId The ICCID.
     * @param slotIndex The logical SIM slot index (i.e. phone id).
     * @param displayName The display name.
     * @param subscriptionType The subscription type.
     *
     * @return The subscription id.
     */
    private int insertSubscriptionInfo(@NonNull String iccId, int slotIndex,
            @Nullable String displayName, @SubscriptionType int subscriptionType) {
        String defaultAllowNetworkTypes = Phone.convertAllowedNetworkTypeMapIndexToDbName(
                TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER) + "="
                + RadioAccessFamily.getRafFromNetworkType(RILConstants.PREFERRED_NETWORK_MODE);
        SubscriptionInfoInternal.Builder builder = new SubscriptionInfoInternal.Builder()
                .setIccId(iccId)
                .setCardString(iccId)
                .setSimSlotIndex(slotIndex)
                .setType(subscriptionType)
                .setIconTint(getColor())
                .setAllowedNetworkTypesForReasons(defaultAllowNetworkTypes);
        if (displayName != null) {
            builder.setDisplayName(displayName);
        }

        return mSubscriptionDatabaseManager.insertSubscriptionInfo(builder.build());
    }

    /**
     * Pull the embedded subscription from {@link EuiccController} for the eUICC with the given list
     * of card IDs {@code cardIds}.
@@ -1016,13 +1047,10 @@ public class SubscriptionManagerService extends ISub.Stub {

                    // The subscription does not exist in the database. Insert a new one here.
                    if (subInfo == null) {
                        subInfo = new SubscriptionInfoInternal.Builder()
                                .setIccId(embeddedProfile.getIccid())
                                .setIconTint(getColor())
                                .build();
                        int subId = mSubscriptionDatabaseManager.insertSubscriptionInfo(subInfo);
                        subInfo = new SubscriptionInfoInternal.Builder(subInfo)
                                .setId(subId).build();
                        int subId = insertSubscriptionInfo(embeddedProfile.getIccid(),
                                SubscriptionManager.INVALID_SIM_SLOT_INDEX,
                                null, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
                        subInfo = mSubscriptionDatabaseManager.getSubscriptionInfoInternal(subId);
                    }

                    int nameSource = subInfo.getDisplayNameSource();
@@ -1224,12 +1252,8 @@ public class SubscriptionManagerService extends ISub.Stub {
            int subId;
            if (subInfo == null) {
                // This is a new SIM card. Insert a new record.
                subId = mSubscriptionDatabaseManager.insertSubscriptionInfo(
                        new SubscriptionInfoInternal.Builder()
                                .setIccId(iccId)
                                .setSimSlotIndex(phoneId)
                                .setIconTint(getColor())
                                .build());
                subId = insertSubscriptionInfo(iccId, phoneId, null,
                        SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
                logl("updateSubscriptions: Inserted a new subscription. subId=" + subId
                        + ", phoneId=" + phoneId);
            } else {
@@ -1308,6 +1332,9 @@ public class SubscriptionManagerService extends ISub.Stub {
                } else {
                    loge("updateSubscriptions: ICC card is not available.");
                }

                // Attempt to restore SIM specific settings when SIM is loaded.
                mSubscriptionManager.restoreSimSpecificSettingsForIccIdFromBackup(iccId);
            }
        } else {
            log("updateSubscriptions: No ICCID available for phone " + phoneId);
@@ -1512,9 +1539,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public List<SubscriptionInfo> getAllSubInfoList(@NonNull String callingPackage,
            @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        // Check if the caller has READ_PHONE_STATE, READ_PRIVILEGED_PHONE_STATE, or carrier
        // privilege on any active subscription. The carrier app will get full subscription infos
        // on the subs it has carrier privilege.
@@ -1561,9 +1585,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public SubscriptionInfo getActiveSubscriptionInfo(int subId, @NonNull String callingPackage,
            @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId, callingPackage,
                callingFeatureId, "getActiveSubscriptionInfo")) {
            throw new SecurityException("Need READ_PHONE_STATE, READ_PRIVILEGED_PHONE_STATE, or "
@@ -1595,9 +1616,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    public SubscriptionInfo getActiveSubscriptionInfoForIccId(@NonNull String iccId,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        enforcePermissions("getActiveSubscriptionInfoForIccId",
                Manifest.permission.READ_PRIVILEGED_PHONE_STATE);

@@ -1634,9 +1652,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public SubscriptionInfo getActiveSubscriptionInfoForSimSlotIndex(int slotIndex,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        int subId = mSlotIndexToSubId.getOrDefault(slotIndex,
                SubscriptionManager.INVALID_SUBSCRIPTION_ID);

@@ -1682,9 +1697,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public List<SubscriptionInfo> getActiveSubscriptionInfoList(@NonNull String callingPackage,
            @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        // Check if the caller has READ_PHONE_STATE, READ_PRIVILEGED_PHONE_STATE, or carrier
        // privilege on any active subscription. The carrier app will get full subscription infos
        // on the subs it has carrier privilege.
@@ -1729,9 +1741,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public int getActiveSubInfoCount(@NonNull String callingPackage,
            @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        if (!TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(mContext,
                Binder.getCallingPid(), Binder.getCallingUid(), callingPackage, callingFeatureId,
                "getAllSubInfoList")) {
@@ -1828,6 +1837,9 @@ public class SubscriptionManagerService extends ISub.Stub {
            return null;
        }

        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        return mSubscriptionDatabaseManager.getAllSubscriptions().stream()
                .map(SubscriptionInfoInternal::toSubscriptionInfo)
                .filter(subInfo -> mSubscriptionManager
@@ -1886,15 +1898,8 @@ public class SubscriptionManagerService extends ISub.Stub {
                    loge("Already a subscription on slot " + slotIndex);
                    return -1;
                }
                int subId = mSubscriptionDatabaseManager.insertSubscriptionInfo(
                        new SubscriptionInfoInternal.Builder()
                                .setIccId(iccId)
                                .setSimSlotIndex(slotIndex)
                                .setDisplayName(displayName)
                                .setIconTint(getColor())
                                .setType(subscriptionType)
                                .build()
                );

                int subId = insertSubscriptionInfo(iccId, slotIndex, displayName, subscriptionType);
                mSlotIndexToSubId.put(slotIndex, subId);
            } else {
                // Record already exists.
@@ -2142,9 +2147,6 @@ public class SubscriptionManagerService extends ISub.Stub {
            "carrier privileges",
    })
    public int setOpportunistic(boolean opportunistic, int subId, @NonNull String callingPackage) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        TelephonyPermissions.enforceAnyPermissionGrantedOrCarrierPrivileges(
                mContext, Binder.getCallingUid(), subId, true, "setOpportunistic",
                Manifest.permission.MODIFY_PHONE_STATE);
@@ -2308,9 +2310,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public List<SubscriptionInfo> getOpportunisticSubscriptions(@NonNull String callingPackage,
            @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        // Check if the caller has READ_PHONE_STATE, READ_PRIVILEGED_PHONE_STATE, or carrier
        // privilege on any active subscription. The carrier app will get full subscription infos
        // on the subs it has carrier privilege.
@@ -2359,9 +2358,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE)
    public void removeSubscriptionsFromGroup(@NonNull int[] subIdList,
            @NonNull ParcelUuid groupUuid, @NonNull String callingPackage) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        // If it doesn't have modify phone state permission, or carrier privilege permission,
        // a SecurityException will be thrown. If it's due to invalid parameter or internal state,
        // it will return null.
@@ -2436,9 +2432,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public void addSubscriptionsIntoGroup(@NonNull int[] subIdList, @NonNull ParcelUuid groupUuid,
            @NonNull String callingPackage) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        Objects.requireNonNull(subIdList, "subIdList");
        if (subIdList.length == 0) {
            throw new IllegalArgumentException("Invalid subId list");
@@ -2450,6 +2443,9 @@ public class SubscriptionManagerService extends ISub.Stub {
            throw new IllegalArgumentException("Invalid groupUuid");
        }

        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        // If it doesn't have modify phone state permission, or carrier privilege permission,
        // a SecurityException will be thrown.
        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
@@ -2511,9 +2507,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public List<SubscriptionInfo> getSubscriptionsInGroup(@NonNull ParcelUuid groupUuid,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        // If the calling app neither has carrier privileges nor READ_PHONE_STATE and access to
        // device identifiers, it will throw a SecurityException.
        if (CompatChanges.isChangeEnabled(REQUIRE_DEVICE_IDENTIFIERS_FOR_GROUP_UUID,
@@ -2896,9 +2889,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public String getSubscriptionProperty(int subId, @NonNull String columnName,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        Objects.requireNonNull(columnName);
        if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId,
                callingPackage, callingFeatureId,
@@ -3254,9 +3244,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public String getPhoneNumber(int subId, @PhoneNumberSource int source,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        TelephonyPermissions.enforceAnyPermissionGrantedOrCarrierPrivileges(
                mContext, subId, Binder.getCallingUid(), "getPhoneNumber",
                Manifest.permission.READ_PHONE_NUMBERS,
@@ -3316,9 +3303,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public String getPhoneNumberFromFirstAvailableSource(int subId,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        TelephonyPermissions.enforceAnyPermissionGrantedOrCarrierPrivileges(
                mContext, subId, Binder.getCallingUid(), "getPhoneNumberFromFirstAvailableSource",
                Manifest.permission.READ_PHONE_NUMBERS,
@@ -3362,9 +3346,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    @RequiresPermission("carrier privileges")
    public void setPhoneNumber(int subId, @PhoneNumberSource int source, @NonNull String number,
            @NonNull String callingPackage, @Nullable String callingFeatureId) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        if (!TelephonyPermissions.checkCarrierPrivilegeForSubId(mContext, subId)) {
            throw new SecurityException("setPhoneNumber for CARRIER needs carrier privilege.");
        }
@@ -3402,9 +3383,6 @@ public class SubscriptionManagerService extends ISub.Stub {
    })
    public int setUsageSetting(@UsageSetting int usageSetting, int subId,
            @NonNull String callingPackage) {
        // Verify that the callingPackage belongs to the calling UID
        mAppOpsManager.checkPackage(Binder.getCallingUid(), callingPackage);

        TelephonyPermissions.enforceAnyPermissionGrantedOrCarrierPrivileges(
                mContext, Binder.getCallingUid(), subId, true, "setUsageSetting",
                Manifest.permission.MODIFY_PHONE_STATE);
@@ -3804,6 +3782,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            @NonNull String[] args) {
        IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, "  ");
        pw.println(SubscriptionManagerService.class.getSimpleName() + ":");
        pw.println("Active modem count=" + mTelephonyManager.getActiveModemCount());
        pw.println("Logical SIM slot sub id mapping:");
        pw.increaseIndent();
        mSlotIndexToSubId.forEach((slotIndex, subId)
+1 −0
Original line number Diff line number Diff line
@@ -1168,6 +1168,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
    @SmallTest
    public void testGetEmptyIccCard() {
        doReturn(null).when(mUiccController).getUiccProfileForPhone(anyInt());
        doReturn(null).when(mUiccController).getUiccSlotForPhone(anyInt());

        IccCard iccCard = mPhoneUT.getIccCard();

+6 −1
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ public abstract class TelephonyTest {
    protected ImsPhoneCallTracker mImsCT;
    protected UiccController mUiccController;
    protected UiccProfile mUiccProfile;
    protected UiccSlot mUiccSlot;
    protected CallManager mCallManager;
    protected PhoneNotifier mNotifier;
    protected TelephonyComponentFactory mTelephonyComponentFactory;
@@ -415,6 +416,7 @@ public abstract class TelephonyTest {
        mImsCT = Mockito.mock(ImsPhoneCallTracker.class);
        mUiccController = Mockito.mock(UiccController.class);
        mUiccProfile = Mockito.mock(UiccProfile.class);
        mUiccSlot = Mockito.mock(UiccSlot.class);
        mCallManager = Mockito.mock(CallManager.class);
        mNotifier = Mockito.mock(PhoneNotifier.class);
        mTelephonyComponentFactory = Mockito.mock(TelephonyComponentFactory.class);
@@ -522,6 +524,8 @@ public abstract class TelephonyTest {
        mPhone.mCi = mSimulatedCommands;
        mCT.mCi = mSimulatedCommands;
        doReturn(mUiccCard).when(mPhone).getUiccCard();
        doReturn(mUiccCard).when(mUiccSlot).getUiccCard();
        doReturn(mUiccCard).when(mUiccController).getUiccCardForPhone(anyInt());
        doReturn(mUiccPort).when(mPhone).getUiccPort();
        doReturn(mUiccProfile).when(mUiccPort).getUiccProfile();

@@ -662,7 +666,8 @@ public abstract class TelephonyTest {
                }
            }
        }).when(mUiccController).getIccRecords(anyInt(), anyInt());
        doReturn(new UiccSlot[] {}).when(mUiccController).getUiccSlots();
        doReturn(new UiccSlot[] {mUiccSlot}).when(mUiccController).getUiccSlots();
        doReturn(mUiccSlot).when(mUiccController).getUiccSlotForPhone(anyInt());
        doReturn(mPinStorage).when(mUiccController).getPinStorage();

        //UiccCardApplication
+60 −6
Original line number Diff line number Diff line
@@ -24,8 +24,11 @@ import static com.android.internal.telephony.subscription.SubscriptionDatabaseMa
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_CONTACT1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_CONTACT2;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_COUNTRY_CODE2;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_EHPLMNS1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_HPLMNS1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_ICCID1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_ICCID2;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_IMSI1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_MCC1;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_MCC2;
import static com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.FAKE_MNC1;
@@ -77,8 +80,10 @@ import android.service.carrier.CarrierIdentifier;
import android.service.euicc.EuiccProfileInfo;
import android.service.euicc.EuiccService;
import android.service.euicc.GetEuiccProfileInfoListResult;
import android.telephony.RadioAccessFamily;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.UiccAccessRule;
import android.test.mock.MockContentResolver;
import android.testing.AndroidTestingRunner;
@@ -86,12 +91,12 @@ import android.testing.TestableLooper;
import android.util.Base64;

import com.android.internal.telephony.ContextFixture;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.euicc.EuiccController;
import com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.SubscriptionProvider;
import com.android.internal.telephony.subscription.SubscriptionManagerService.SubscriptionManagerServiceCallback;
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccSlot;

import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;
@@ -128,8 +133,6 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
    // mocked
    private SubscriptionManagerServiceCallback mMockedSubscriptionManagerServiceCallback;
    private EuiccController mEuiccController;
    private UiccSlot mUiccSlot;
    private UiccCard mUiccCard;

    @Rule
    public TestRule compatChangeRule = new PlatformCompatChangeRule();
@@ -148,12 +151,10 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        doReturn(true).when(mTelephonyManager).isVoiceCapable();
        mEuiccController = Mockito.mock(EuiccController.class);
        replaceInstance(EuiccController.class, "sInstance", null, mEuiccController);
        mUiccSlot = Mockito.mock(UiccSlot.class);
        mUiccCard = Mockito.mock(UiccCard.class);
        mMockedSubscriptionManagerServiceCallback = Mockito.mock(
                SubscriptionManagerServiceCallback.class);
        doReturn(mUiccCard).when(mUiccSlot).getUiccCard();
        doReturn(FAKE_ICCID1).when(mUiccCard).getCardId();
        doReturn(FAKE_ICCID1).when(mUiccPort).getIccId();

        ((MockContentResolver) mContext.getContentResolver()).addProvider(
                Telephony.Carriers.CONTENT_URI.getAuthority(), mSubscriptionProvider);
@@ -1738,4 +1739,57 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        assertThat(subInfo.isRemovableEmbedded()).isFalse();
        assertThat(subInfo.getNativeAccessRules()).isEqualTo(FAKE_NATIVE_ACCESS_RULES1);
    }

    @Test
    public void testInsertNewSim() {
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.MODIFY_PHONE_STATE);
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE);

        doReturn(FAKE_IMSI1).when(mTelephonyManager).getSubscriberId();
        doReturn(FAKE_MCC1 + FAKE_MNC1).when(mTelephonyManager).getSimOperatorNumeric(anyInt());
        doReturn(FAKE_PHONE_NUMBER1).when(mTelephonyManager).getLine1Number(anyInt());
        doReturn(FAKE_EHPLMNS1.split(",")).when(mSimRecords).getEhplmns();
        doReturn(FAKE_HPLMNS1.split(",")).when(mSimRecords).getPlmnsFromHplmnActRecord();
        doReturn(0).when(mUiccSlot).getPortIndexFromIccId(anyString());
        doReturn(false).when(mUiccSlot).isEuicc();
        doReturn(1).when(mUiccController).convertToPublicCardId(eq(FAKE_ICCID1));

        mSubscriptionManagerServiceUT.updateSimState(
                0, TelephonyManager.SIM_STATE_READY, null, null);
        processAllMessages();

        mSubscriptionManagerServiceUT.updateSimState(
                0, TelephonyManager.SIM_STATE_LOADED, null, null);
        processAllMessages();
        mSubscriptionManagerServiceUT.setCarrierId(1, FAKE_CARRIER_ID1);
        mSubscriptionManagerServiceUT.setDisplayNameUsingSrc(FAKE_CARRIER_NAME1, 1,
                SubscriptionManager.NAME_SOURCE_SIM_SPN);
        mSubscriptionManagerServiceUT.setCarrierName(1, FAKE_CARRIER_NAME1);

        SubscriptionInfoInternal subInfo = mSubscriptionManagerServiceUT
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo.getSubscriptionId()).isEqualTo(1);
        assertThat(subInfo.getSimSlotIndex()).isEqualTo(0);
        assertThat(subInfo.getIccId()).isEqualTo(FAKE_ICCID1);
        assertThat(subInfo.getPortIndex()).isEqualTo(0);
        assertThat(subInfo.isEmbedded()).isFalse();
        assertThat(subInfo.getCarrierId()).isEqualTo(FAKE_CARRIER_ID1);
        assertThat(subInfo.getDisplayName()).isEqualTo(FAKE_CARRIER_NAME1);
        assertThat(subInfo.getDisplayNameSource()).isEqualTo(
                SubscriptionManager.NAME_SOURCE_SIM_SPN);
        assertThat(subInfo.getCarrierName()).isEqualTo(FAKE_CARRIER_NAME1);
        assertThat(subInfo.isOpportunistic()).isFalse();
        assertThat(subInfo.getNumber()).isEqualTo(FAKE_PHONE_NUMBER1);
        assertThat(subInfo.getMcc()).isEqualTo(FAKE_MCC1);
        assertThat(subInfo.getMnc()).isEqualTo(FAKE_MNC1);
        assertThat(subInfo.getEhplmns()).isEqualTo(FAKE_EHPLMNS1);
        assertThat(subInfo.getHplmns()).isEqualTo(FAKE_HPLMNS1);
        assertThat(subInfo.getCardString()).isEqualTo(FAKE_ICCID1);
        assertThat(subInfo.getCardId()).isEqualTo(1);
        assertThat(subInfo.getSubscriptionType()).isEqualTo(
                SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
        assertThat(subInfo.areUiccApplicationsEnabled()).isTrue();
        assertThat(subInfo.getAllowedNetworkTypesForReasons()).isEqualTo("user="
                + RadioAccessFamily.getRafFromNetworkType(RILConstants.PREFERRED_NETWORK_MODE));
    }
}