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

Commit 6d43bcd3 authored by shilu's avatar shilu Committed by Shi Lu
Browse files

Caching Manual Network Selection Config

Bug: 143187230

Test:  make, test with dumpstate && make offline-sdk-docs
Change-Id: I994c64e27d534cc83eeaa7df2caa45f445ae7f5a
parent fa836529
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -174,6 +174,9 @@ public class GsmCdmaPhone extends Phone {
     */
    private SIMRecords mSimRecords;

    // For non-persisted manual network selection
    private String mManualNetworkSelectionPlmn = "";

    //Common
    // Instance Variables
    @UnsupportedAppUsage
@@ -1871,6 +1874,29 @@ public class GsmCdmaPhone extends Phone {
        }
    }

    /**
     * Update non-persisited manual network selection.
     *
     * @param nsm contains Plmn info
     */
    @Override
    protected void updateManualNetworkSelection(NetworkSelectMessage nsm) {
        int subId = getSubId();
        if (SubscriptionManager.isValidSubscriptionId(subId)) {
            mManualNetworkSelectionPlmn = nsm.operatorNumeric;
        } else {
        //on Phone0 in emergency mode (no SIM), or in some races then clear the cache
            mManualNetworkSelectionPlmn = "";
            Rlog.e(LOG_TAG, "Cannot update network selection due to invalid subId "
                    + subId);
        }
    }

    @Override
    public String getManualNetworkSelectionPlmn() {
        return (mManualNetworkSelectionPlmn == null) ? "" : mManualNetworkSelectionPlmn;
    }

    @Override
    public String getCdmaPrlVersion() {
        return mSST.getPrlVersion();
@@ -3848,6 +3874,7 @@ public class GsmCdmaPhone extends Phone {
            pw.println(" isMinInfoReady()=" + isMinInfoReady());
        }
        pw.println(" isCspPlmnEnabled()=" + isCspPlmnEnabled());
        pw.println(" mManualNetworkSelectionPlmn=" + mManualNetworkSelectionPlmn);
        pw.flush();
    }

+21 −2
Original line number Diff line number Diff line
@@ -246,7 +246,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * if we are looking for automatic selection. operatorAlphaLong is the
     * corresponding operator name.
     */
    private static class NetworkSelectMessage {
    protected static class NetworkSelectMessage {
        public Message message;
        public String operatorNumeric;
        public String operatorAlphaLong;
@@ -1379,6 +1379,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            updateSavedNetworkOperator(nsm);
        } else {
            clearSavedNetworkSelection();
            updateManualNetworkSelection(nsm);
        }
    }

@@ -1420,6 +1421,15 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        }
    }

    /**
     * Update non-perisited manual network selection.
     *
     * @param nsm PLMN info of the selected network
     */
    protected void updateManualNetworkSelection(NetworkSelectMessage nsm)  {
        Rlog.e(LOG_TAG, "updateManualNetworkSelection() should be overridden");
    }

    /**
     * Used to track the settings upon completion of the network change.
     */
@@ -1444,7 +1454,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    /**
     * Method to retrieve the saved operator from the Shared Preferences
     */
    private OperatorInfo getSavedNetworkSelection() {
    @NonNull
    public OperatorInfo getSavedNetworkSelection() {
        // open the shared preferences and search with our key.
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        String numeric = sp.getString(NETWORK_SELECTION_KEY + getSubId(), "");
@@ -1903,6 +1914,14 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        return mVmCount != 0;
    }

    /**
     *  Retrieves manually selected network info.
     */
    public String getManualNetworkSelectionPlmn() {
        return "";
    }


    private int getCallForwardingIndicatorFromSharedPref() {
        int status = IccRecords.CALL_FORWARDING_STATUS_DISABLED;
        int subId = getSubId();