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

Commit 7861a360 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Delay DCT initialization till subId is known.

Bug: 23372606
Change-Id: If2c5ed6aefdf246cb664656b52786158bef544ee
parent c6986382
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -249,7 +249,8 @@ public abstract class ServiceStateTracker extends Handler {
        new SstSubscriptionsChangedListener();
        new SstSubscriptionsChangedListener();


    protected class SstSubscriptionsChangedListener extends OnSubscriptionsChangedListener {
    protected class SstSubscriptionsChangedListener extends OnSubscriptionsChangedListener {
        public final AtomicInteger mPreviousSubId = new AtomicInteger(-1); // < 0 is invalid subId
        public final AtomicInteger mPreviousSubId =
                new AtomicInteger(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
        /**
        /**
         * Callback invoked when there is any change to any SubscriptionInfo. Typically
         * Callback invoked when there is any change to any SubscriptionInfo. Typically
         * this method would invoke {@link SubscriptionManager#getActiveSubscriptionInfoList}
         * this method would invoke {@link SubscriptionManager#getActiveSubscriptionInfoList}
+13 −5
Original line number Original line Diff line number Diff line
@@ -1483,15 +1483,16 @@ public final class DcTracker extends DcTrackerBase {
        }
        }
    }
    }


    private void onRecordsLoaded() {
    @Override
        if (DBG) log("onRecordsLoaded: createAllApnList");
    void onRecordsLoadedOrSubIdChanged() {
        if (DBG) log("onRecordsLoadedOrSubIdChanged: createAllApnList");
        mAutoAttachOnCreationConfig = mPhone.getContext().getResources()
        mAutoAttachOnCreationConfig = mPhone.getContext().getResources()
                .getBoolean(com.android.internal.R.bool.config_auto_attach_data_on_creation);
                .getBoolean(com.android.internal.R.bool.config_auto_attach_data_on_creation);


        createAllApnList();
        createAllApnList();
        setInitialAttachApn();
        setInitialAttachApn();
        if (mPhone.mCi.getRadioState().isOn()) {
        if (mPhone.mCi.getRadioState().isOn()) {
            if (DBG) log("onRecordsLoaded: notifying data availability");
            if (DBG) log("onRecordsLoadedOrSubIdChanged: notifying data availability");
            notifyOffApnsOfAvailability(Phone.REASON_SIM_LOADED);
            notifyOffApnsOfAvailability(Phone.REASON_SIM_LOADED);
        }
        }
        setupDataOnConnectableApns(Phone.REASON_SIM_LOADED);
        setupDataOnConnectableApns(Phone.REASON_SIM_LOADED);
@@ -2587,7 +2588,14 @@ public final class DcTracker extends DcTrackerBase {


        switch (msg.what) {
        switch (msg.what) {
            case DctConstants.EVENT_RECORDS_LOADED:
            case DctConstants.EVENT_RECORDS_LOADED:
                onRecordsLoaded();
                // If onRecordsLoadedOrSubIdChanged() is not called here, it should be called on
                // onSubscriptionsChanged() when a valid subId is available.
                int subId = mPhone.getSubId();
                if (SubscriptionManager.isValidSubscriptionId(subId)) {
                    onRecordsLoadedOrSubIdChanged();
                } else {
                    log("Ignoring EVENT_RECORDS_LOADED as subId is not valid: " + subId);
                }
                break;
                break;


            case DctConstants.EVENT_DATA_CONNECTION_DETACHED:
            case DctConstants.EVENT_DATA_CONNECTION_DETACHED:
@@ -2753,7 +2761,7 @@ public final class DcTracker extends DcTrackerBase {
                mIccRecords.set(null);
                mIccRecords.set(null);
            }
            }
            if (newIccRecords != null) {
            if (newIccRecords != null) {
                if (mPhone.getSubId() >= 0) {
                if (SubscriptionManager.isValidSubscriptionId(mPhone.getSubId())) {
                    log("New records found.");
                    log("New records found.");
                    mIccRecords.set(newIccRecords);
                    mIccRecords.set(newIccRecords);
                    newIccRecords.registerForRecordsLoaded(
                    newIccRecords.registerForRecordsLoaded(
+30 −19
Original line number Original line Diff line number Diff line
@@ -391,6 +391,9 @@ public abstract class DcTrackerBase extends Handler {
    private SubscriptionManager mSubscriptionManager;
    private SubscriptionManager mSubscriptionManager;
    private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
    private final OnSubscriptionsChangedListener mOnSubscriptionsChangedListener =
            new OnSubscriptionsChangedListener() {
            new OnSubscriptionsChangedListener() {
                public final AtomicInteger mPreviousSubId =
                        new AtomicInteger(SubscriptionManager.INVALID_SUBSCRIPTION_ID);

                /**
                /**
                 * Callback invoked when there is any change to any SubscriptionInfo. Typically
                 * Callback invoked when there is any change to any SubscriptionInfo. Typically
                 * this method would invoke {@link SubscriptionManager#getActiveSubscriptionInfoList}
                 * this method would invoke {@link SubscriptionManager#getActiveSubscriptionInfoList}
@@ -408,6 +411,11 @@ public abstract class DcTrackerBase extends Handler {
                        mDataRoamingSettingObserver = new DataRoamingSettingObserver(mPhone,
                        mDataRoamingSettingObserver = new DataRoamingSettingObserver(mPhone,
                                mPhone.getContext());
                                mPhone.getContext());
                        mDataRoamingSettingObserver.register();
                        mDataRoamingSettingObserver.register();

                    }
                    if (mPreviousSubId.getAndSet(subId) != subId &&
                            SubscriptionManager.isValidSubscriptionId(subId)) {
                        onRecordsLoadedOrSubIdChanged();
                    }
                    }
                }
                }
            };
            };
@@ -1928,6 +1936,9 @@ public abstract class DcTrackerBase extends Handler {
        return mAutoAttachOnCreation.get();
        return mAutoAttachOnCreation.get();
    }
    }


    void onRecordsLoadedOrSubIdChanged() {
    }

    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println("DcTrackerBase:");
        pw.println("DcTrackerBase:");
        pw.println(" RADIO_TESTS=" + RADIO_TESTS);
        pw.println(" RADIO_TESTS=" + RADIO_TESTS);