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

Commit a6cda048 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Initialized allowed network types am: 24856630

parents 44623ac1 24856630
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2460,7 +2460,15 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        }
    }

    private String convertAllowedNetworkTypeMapIndexToDbName(int reason) {
    /**
     * 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:
                return ALLOWED_NETWORK_TYPES_TEXT_USER;
+49 −70
Original line number Diff line number Diff line
@@ -52,6 +52,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;
@@ -83,6 +84,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;
@@ -945,6 +947,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}.
@@ -991,13 +1022,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();
@@ -1199,12 +1227,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 {
@@ -1283,6 +1307,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);
@@ -1487,9 +1514,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.
@@ -1536,9 +1560,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 "
@@ -1570,9 +1591,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);

@@ -1609,9 +1627,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);

@@ -1657,9 +1672,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.
@@ -1704,9 +1716,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")) {
@@ -1803,6 +1812,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
@@ -1861,15 +1873,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.
@@ -2117,9 +2122,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);
@@ -2283,9 +2285,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.
@@ -2334,9 +2333,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.
@@ -2411,9 +2407,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");
@@ -2425,6 +2418,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)
@@ -2486,9 +2482,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,
@@ -2871,9 +2864,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,
@@ -3229,9 +3219,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,
@@ -3291,9 +3278,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,
@@ -3337,9 +3321,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.");
        }
@@ -3377,9 +3358,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);
@@ -3757,6 +3735,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
@@ -1126,6 +1126,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);
@@ -521,6 +523,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;
@@ -79,8 +82,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;
@@ -88,12 +93,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;
@@ -130,8 +135,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();
@@ -150,12 +153,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);
@@ -1746,4 +1747,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));
    }
}