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

Commit 8cef6eea authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Update saved network operator on manual network selection req instead of resp.

Bug: 17989129
Change-Id: I207187a7cc5d1ac067ad0e45b8d5205aca13ac93
parent 0b83b4f0
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -859,6 +859,8 @@ public abstract class PhoneBase extends Handler implements Phone {

        Message msg = obtainMessage(EVENT_SET_NETWORK_AUTOMATIC_COMPLETE, nsm);
        mCi.setNetworkSelectionModeAutomatic(msg);

        updateSavedNetworkOperator(nsm);
    }

    @Override
@@ -872,6 +874,22 @@ public abstract class PhoneBase extends Handler implements Phone {

        Message msg = obtainMessage(EVENT_SET_NETWORK_MANUAL_COMPLETE, nsm);
        mCi.setNetworkSelectionModeManual(network.getOperatorNumeric(), msg);

        updateSavedNetworkOperator(nsm);
    }

    private void updateSavedNetworkOperator(NetworkSelectMessage nsm) {
        // open the shared preferences editor, and write the value.
        // nsm.operatorNumeric is "" if we're in automatic.selection.
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        SharedPreferences.Editor editor = sp.edit();
        editor.putString(NETWORK_SELECTION_KEY, nsm.operatorNumeric);
        editor.putString(NETWORK_SELECTION_NAME_KEY, nsm.operatorAlphaLong);

        // commit and log the result.
        if (!editor.commit()) {
            Rlog.e(LOG_TAG, "failed to commit network selection preference");
        }
    }

    /**
@@ -893,18 +911,6 @@ public abstract class PhoneBase extends Handler implements Phone {
            AsyncResult.forMessage(nsm.message, ar.result, ar.exception);
            nsm.message.sendToTarget();
        }

        // open the shared preferences editor, and write the value.
        // nsm.operatorNumeric is "" if we're in automatic.selection.
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
        SharedPreferences.Editor editor = sp.edit();
        editor.putString(NETWORK_SELECTION_KEY, nsm.operatorNumeric);
        editor.putString(NETWORK_SELECTION_NAME_KEY, nsm.operatorAlphaLong);

        // commit and log the result.
        if (!editor.commit()) {
            Rlog.e(LOG_TAG, "failed to commit network selection preference");
        }
    }

    /**