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

Commit 7f14ab63 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Add check for empty operatorNumeric to avoid crash.

Bug: 28600710
Change-Id: I7816457abbe2431c543274715f33220ff9f0cb29
parent 54dd4016
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ public class SubscriptionInfoUpdater extends Handler {

            String operator = tm.getSimOperatorNumericForPhone(slotId);

            if (operator != null) {
            if (!TextUtils.isEmpty(operator)) {
                if (subId == SubscriptionController.getInstance().getDefaultSubId()) {
                    MccTable.updateMccMncConfiguration(mContext, operator, false);
                }
+28 −0
Original line number Diff line number Diff line
@@ -240,6 +240,34 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                eq(IccCardConstants.INTENT_VALUE_ICC_LOADED));
    }

    @Test
    @SmallTest
    public void testSimLoadedEmptyOperatorNumeric() {
        /* mock new sim got loaded and there is no sim loaded before */
        doReturn(null).when(mSubscriptionController)
                .getSubInfoUsingSlotIdWithCheck(eq(0), anyBoolean(), anyString());
        doReturn("89012604200000000000").when(mIccRecord).getFullIccId();
        // operator numeric is empty
        doReturn("").when(mTelephonyManager).getSimOperatorNumericForPhone(0);
        Intent mIntent = new Intent(IccCardProxy.ACTION_INTERNAL_SIM_STATE_CHANGED);
        mIntent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE,
                IccCardConstants.INTENT_VALUE_ICC_LOADED);
        mIntent.putExtra(PhoneConstants.PHONE_KEY, 0);

        mContext.sendBroadcast(mIntent);
        waitForMs(100);
        SubscriptionManager mSubscriptionManager = SubscriptionManager.from(mContext);
        verify(mTelephonyManager).getSimOperatorNumericForPhone(0);
        verify(mSubscriptionManager, times(1)).addSubscriptionInfoRecord(
                eq("89012604200000000000"), eq(0));
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
        verify(mSubscriptionController, times(0)).setMccMnc(anyString(), anyInt());
        CarrierConfigManager mConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager, times(1)).updateConfigForPhoneId(eq(0),
                eq(IccCardConstants.INTENT_VALUE_ICC_LOADED));
    }

    @Test
    @SmallTest
    public void testSimLockedWithOutIccId() {