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

Commit 7b76fa66 authored by Jack Yu's avatar Jack Yu
Browse files

Fixed incorrect carrier name shown in dialog

The default data sub selection dialog was popped with
default carrier name "CARD x". The reason is that the dialog
was popped up too early before the display name was set correctly.

Fixed by correctly checking if carrier config is loaded in
MultiSimSettingController.

Test: Manually insert 2nd SIM and verify the correct name shown in dialog
Test: Basic telephony functionality tests
Test: atest MultiSimSettingControllerTest
Fix: 301987330
Change-Id: I2dfffb9ccd3a6b093dc295e2bd177ec608abba63
parent d88f06bc
Loading
Loading
Loading
Loading
+5 −14
Original line number Diff line number Diff line
@@ -420,23 +420,14 @@ public class MultiSimSettingController extends Handler {
            return;
        }

        // b/153860050 Occasionally we receive carrier config change broadcast without subId
        // being specified in it. So here we do additional check to make sur we don't miss the
        // subId.
        if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
            subId = SubscriptionManager.getSubscriptionId(phoneId);
            if (SubscriptionManager.isValidSubscriptionId(subId)) {
        CarrierConfigManager cm = mContext.getSystemService(CarrierConfigManager.class);
                if (cm != null && cm.getConfigForSubId(subId) != null) {
                    loge("onCarrierConfigChanged with invalid subId while subId "
                            + subId + " is active and its config is loaded");
                }
            }
        }

        if (cm != null) {
            if (CarrierConfigManager.isConfigForIdentifiedCarrier(cm.getConfigForSubId(subId))) {
                mCarrierConfigLoadedSubIds[phoneId] = subId;
                reEvaluateAll();
            }
        }
    }

    /**
     * Check whether carrier config loaded for all subs
+14 −7
Original line number Diff line number Diff line
@@ -247,6 +247,10 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
            return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        }).when(mPhoneMock2).getSubId();

        PersistableBundle bundle = new PersistableBundle();
        bundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(anyInt());

        replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
        // Capture listener to emulate the carrier config change notification used later
        ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor =
@@ -885,6 +889,13 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        doReturn(true).when(mPhoneMock2).isUserDataEnabled();
        mMultiSimSettingControllerUT.notifyAllSubscriptionLoaded();
        processAllMessages();

        PersistableBundle bundle = new PersistableBundle();
        bundle.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(eq(1));
        PersistableBundle bundle2 = new PersistableBundle();
        doReturn(bundle).when(mCarrierConfigManager).getConfigForSubId(eq(2));

        sendCarrierConfigChanged(0, 1);
        // Notify carrier config change on phone1 without specifying subId.
        sendCarrierConfigChanged(1, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
@@ -893,13 +904,9 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        verify(mDataSettingsManagerMock2, never()).setDataEnabled(
                TelephonyManager.DATA_ENABLED_REASON_USER, false, PHONE_PACKAGE);

        // Still notify carrier config without specifying subId2, but this time subController
        // and CarrierConfigManager have subId 2 active and ready.
        doReturn(2).when(mSubscriptionManagerService).getSubId(1);
        CarrierConfigManager cm = (CarrierConfigManager) mContext.getSystemService(
                mContext.CARRIER_CONFIG_SERVICE);
        doReturn(new PersistableBundle()).when(cm).getConfigForSubId(2);
        sendCarrierConfigChanged(1, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        logd("Sending the correct phone id and sub id");
        bundle2.putBoolean(CarrierConfigManager.KEY_CARRIER_CONFIG_APPLIED_BOOL, true);
        sendCarrierConfigChanged(1, 2);
        processAllMessages();
        // This time user data should be disabled on phone1.
        verify(mDataSettingsManagerMock2).setDataEnabled(