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

Commit 0623a6e2 authored by Shishir Agrawal's avatar Shishir Agrawal Committed by Android (Google) Code Review
Browse files

Merge "On IMSI change and CDMA mode, set automatic network selection if it is...

Merge "On IMSI change and CDMA mode, set automatic network selection if it is manual." into lmp-mr1-dev
parents 4307afa0 3b9b9d70
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1092,6 +1092,15 @@ public interface Phone {
    void selectNetworkManually(OperatorInfo network,
                            Message response);

    /**
     * Query the radio for the current network selection mode.
     *
     * Return values:
     *     0 - automatic.
     *     1 - manual.
     */
    void getNetworkSelectionMode(Message response);

    /**
     *  Requests to set the preferred network type for searching and registering
     * (CS/PS domain, RAT, and operation mode)
+5 −0
Original line number Diff line number Diff line
@@ -866,6 +866,11 @@ public abstract class PhoneBase extends Handler implements Phone {
        updateSavedNetworkOperator(nsm);
    }

    @Override
    public void getNetworkSelectionMode(Message message) {
        mCi.getNetworkSelectionMode(message);
    }

    @Override
    public void selectNetworkManually(OperatorInfo network, Message response) {
        // wrap the response message in our own message along with
+5 −0
Original line number Diff line number Diff line
@@ -866,6 +866,11 @@ public class PhoneProxy extends Handler implements Phone {
        mActivePhone.setNetworkSelectionModeAutomatic(response);
    }

    @Override
    public void getNetworkSelectionMode(Message response) {
        mActivePhone.getNetworkSelectionMode(response);
    }

    @Override
    public void selectNetworkManually(OperatorInfo network, Message response) {
        mActivePhone.selectNetworkManually(network, response);
+14 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public class SubscriptionInfoUpdater extends Handler {
    private static final int PROJECT_SIM_NUM = TelephonyManager.getDefault().getPhoneCount();
    private static final int EVENT_OFFSET = 8;
    private static final int EVENT_QUERY_ICCID_DONE = 1;
    private static final int EVENT_GET_NETWORK_SELECTION_MODE_DONE = 2;
    private static final String ICCID_STRING_FOR_NO_SIM = "";
    /**
     *  int[] sInsertSimState maintains all slots' SIM inserted status currently,
@@ -194,8 +195,9 @@ public class SubscriptionInfoUpdater extends Handler {
                            Settings.Global.putInt(sPhone[slotId].getContext().getContentResolver(),
                                    Settings.Global.PREFERRED_NETWORK_MODE, networkType);

                            // Only support automatic selection mode on IMSI change
                            sPhone[slotId].setNetworkSelectionModeAutomatic(null);
                            // Only support automatic selection mode on IMSI change.
                            sPhone[slotId].getNetworkSelectionMode(
                                    obtainMessage(EVENT_GET_NETWORK_SELECTION_MODE_DONE));

                            // Update stored IMSI
                            SharedPreferences.Editor editor = sp.edit();
@@ -289,6 +291,16 @@ public class SubscriptionInfoUpdater extends Handler {
                    updateSubscriptionInfoByIccId();
                }
                break;
            case EVENT_GET_NETWORK_SELECTION_MODE_DONE:
                if (ar.exception == null && ar.result != null) {
                    int[] modes = (int[])ar.result;
                    if (modes[0] == 1) {  // Manual mode.
                        sPhone[slotId].setNetworkSelectionModeAutomatic(null);
                    }
                } else {
                    logd("EVENT_GET_NETWORK_SELECTION_MODE_DONE: error getting network mode.");
                }
                break;
            default:
                logd("Unknown msg:" + msg.what);
        }
+15 −4
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
            }

            // Only support automatic selection mode in CDMA.
            // mPhone.setNetworkSelectionModeAutomatic(null);
            mCi.getNetworkSelectionMode(obtainMessage(EVENT_POLL_STATE_NETWORK_SELECTION_MODE));

            mPhone.prepareEri();
            break;
@@ -321,7 +321,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
            updatePhoneObject();

            // Only support automatic selection mode in CDMA.
            // mPhone.setNetworkSelectionModeAutomatic(null);
            mCi.getNetworkSelectionMode(obtainMessage(EVENT_POLL_STATE_NETWORK_SELECTION_MODE));

            // For Non-RUIM phones, the subscription information is stored in
            // Non Volatile. Here when Non-Volatile is ready, we can poll the CDMA
@@ -523,14 +523,25 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
            setPowerStateToDesired();
            break;

        case EVENT_POLL_STATE_NETWORK_SELECTION_MODE:
            if (DBG) log("EVENT_POLL_STATE_NETWORK_SELECTION_MODE");
            ar = (AsyncResult) msg.obj;
            if (ar.exception == null && ar.result != null) {
                ints = (int[])ar.result;
                if (ints[0] == 1) {  // Manual selection.
                    mPhone.setNetworkSelectionModeAutomatic(null);
                }
            } else {
                log("Unable to getNetworkSelectionMode");
            }
            break;

        default:
            super.handleMessage(msg);
        break;
        }
    }

    //***** Private Instance Methods

    private void handleCdmaSubscriptionSource(int newSubscriptionSource) {
        log("Subscription Source : " + newSubscriptionSource);
        mIsSubscriptionFromRuim =