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

Commit 4f49d597 authored by Sarah Chin's avatar Sarah Chin
Browse files

Notify subscriptions loaded after radio unavailable

Fixed a regression from ag/14924999 where SubscriptionInfoUpdater
wouldn't notify all subscriptions loaded after radio unavailable,
causing MultiSimSettingController to not update state properly.

Bug: 193176588
Fix: 194149302
Test: atest MultiSimSettingControllerTest, SubscriptionInfoUpdaterTest
Change-Id: I344aa88a37e59be73e91949479de88f3a4db9e76
Merged-In: I344aa88a37e59be73e91949479de88f3a4db9e76
parent 97083863
Loading
Loading
Loading
Loading
+16 −9
Original line number Original line Diff line number Diff line
@@ -341,17 +341,19 @@ public class MultiSimSettingController extends Handler {
    }
    }


    /**
    /**
     * Upon initialization, update defaults and mobile data enabling.
     * Upon initialization or radio available, update defaults and mobile data enabling.
     * Should only be triggered once.
     * Should only be triggered once.
     */
     */
    private void onAllSubscriptionsLoaded() {
    private void onAllSubscriptionsLoaded() {
        if (DBG) log("onAllSubscriptionsLoaded");
        if (DBG) log("onAllSubscriptionsLoaded: mSubInfoInitialized=" + mSubInfoInitialized);
        if (!mSubInfoInitialized) {
            mSubInfoInitialized = true;
            mSubInfoInitialized = true;
            for (Phone phone : PhoneFactory.getPhones()) {
            for (Phone phone : PhoneFactory.getPhones()) {
                phone.mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
                phone.mCi.registerForRadioStateChanged(this, EVENT_RADIO_STATE_CHANGED, null);
            }
            }
            reEvaluateAll();
            reEvaluateAll();
        }
        }
    }


    /**
    /**
     * Make sure default values are cleaned or updated.
     * Make sure default values are cleaned or updated.
@@ -445,11 +447,16 @@ public class MultiSimSettingController extends Handler {
    }
    }


    /**
    /**
     * Wait for subInfo initialization (after boot up) and carrier config load for all active
     * Wait for subInfo initialization (after boot up or radio unavailable) and carrier config load
     * subscriptions before re-evaluate multi SIM settings.
     * for all active subscriptions before re-evaluate multi SIM settings.
     */
     */
    private boolean isReadyToReevaluate() {
    private boolean isReadyToReevaluate() {
        return mSubInfoInitialized && isCarrierConfigLoadedForAllSub();
        boolean carrierConfigsLoaded = isCarrierConfigLoadedForAllSub();
        if (DBG) {
            log("isReadyToReevaluate: subInfoInitialized=" + mSubInfoInitialized
                    + ", carrierConfigsLoaded=" + carrierConfigsLoaded);
        }
        return mSubInfoInitialized && carrierConfigsLoaded;
    }
    }


    private void reEvaluateAll() {
    private void reEvaluateAll() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -790,8 +790,8 @@ public class SubscriptionInfoUpdater extends Handler {
            if (DBG) logd("SubInfo Initialized");
            if (DBG) logd("SubInfo Initialized");
            sIsSubInfoInitialized = true;
            sIsSubInfoInitialized = true;
            mSubscriptionController.notifySubInfoReady();
            mSubscriptionController.notifySubInfoReady();
            MultiSimSettingController.getInstance().notifyAllSubscriptionLoaded();
        }
        }
        MultiSimSettingController.getInstance().notifyAllSubscriptionLoaded();
    }
    }


    /**
    /**
+8 −0
Original line number Original line Diff line number Diff line
@@ -209,6 +209,14 @@ public class MultiSimSettingControllerTest extends TelephonyTest {
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(1, 2);
        mMultiSimSettingControllerUT.notifyCarrierConfigChanged(1, 2);
        processAllMessages();
        processAllMessages();


        // Ensure all subscription loaded only updates state once
        clearInvocations(mSubControllerMock);
        mMultiSimSettingControllerUT.notifyAllSubscriptionLoaded();
        processAllMessages();
        verify(mSubControllerMock, never()).setDefaultDataSubId(anyInt());
        verify(mSubControllerMock, never()).setDefaultVoiceSubId(anyInt());
        verify(mSubControllerMock, never()).setDefaultSmsSubId(anyInt());

        // Notify radio unavailable.
        // Notify radio unavailable.
        replaceInstance(BaseCommands.class, "mState", mSimulatedCommands,
        replaceInstance(BaseCommands.class, "mState", mSimulatedCommands,
                TelephonyManager.RADIO_POWER_UNAVAILABLE);
                TelephonyManager.RADIO_POWER_UNAVAILABLE);