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

Commit 1c121528 authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Merge 00a3e058 on remote branch

Change-Id: Ia6921909facfd1d93f32f009c73ee51f03d30de7
parents 07764c73 00a3e058
Loading
Loading
Loading
Loading
+40 −30
Original line number Diff line number Diff line
@@ -173,8 +173,10 @@ public final class MccTable
     * correct version of resources.  If MCC is 0, MCC and MNC will be ignored (not set).
     * @param context Context to act on.
     * @param mccmnc truncated imsi with just the MCC and MNC - MNC assumed to be from 4th to end
     * @param fromServiceState true if coming from the radio service state, false if from SIM
     */
    public static void updateMccMncConfiguration(Context context, String mccmnc) {
    public static void updateMccMncConfiguration(Context context, String mccmnc,
            boolean fromServiceState) {
        if (!TextUtils.isEmpty(mccmnc)) {
            int mcc, mnc;

@@ -201,8 +203,11 @@ public final class MccTable
            if (mcc != 0) {
                setTimezoneFromMccIfNeeded(context, mcc);
                locale = getLocaleFromMcc(context, mcc);
                setWifiCountryCodeFromMcc(context, mcc);
            }
            if (fromServiceState) {
                setWifiCountryCodeFromMcc(context, mcc);
            } else {
                // from SIM
                try {
                    Configuration config = new Configuration();
                    boolean updateConfig = false;
@@ -225,6 +230,12 @@ public final class MccTable
                    Slog.e(LOG_TAG, "Can't update configuration", e);
                }
            }
        } else {
            if (fromServiceState) {
                // an empty mccmnc means no signal - tell wifi we don't know
                setWifiCountryCodeFromMcc(context, 0);
            }
        }
    }

    /**
@@ -354,20 +365,19 @@ public final class MccTable
    }

    /**
     * If the number of allowed wifi channels has not been set, set it based on
     * the MCC of the SIM.
     * Set the country code for wifi.  This sets allowed wifi channels based on the
     * country of the carrier we see.  If we can't see any, reset to 0 so we don't
     * broadcast on forbidden channels.
     * @param context Context to act on.
     * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA)
     * @param mcc Mobile Country Code of the operator.  0 if not known
     */
    private static void setWifiCountryCodeFromMcc(Context context, int mcc) {
        String country = MccTable.countryCodeForMcc(mcc);
        if (!country.isEmpty()) {
        Slog.d(LOG_TAG, "WIFI_COUNTRY_CODE set to " + country);
        WifiManager wM = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        //persist
        wM.setCountryCode(country, true);
    }
    }

    static {
        sTable = new ArrayList<MccEntry>(240);
+11 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import android.content.Context;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -25,6 +26,7 @@ import android.os.SystemClock;
import android.telephony.CellInfo;
import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.text.TextUtils;
import android.util.Pair;
import android.util.TimeUtils;
import android.net.ConnectivityManager;
@@ -818,6 +820,14 @@ public abstract class ServiceStateTracker extends Handler {
        }
    }

    protected void updateCarrierMccMncConfiguration(String newOp, String oldOp, Context context) {
        // if we have a change in operator, notify wifi (even to/from none)
        if (((newOp == null) && (TextUtils.isEmpty(oldOp) == false)) ||
                ((newOp != null) && (newOp.equals(oldOp) == false))) {
            MccTable.updateMccMncConfiguration(context, newOp, true);
        }
    }

    protected boolean isCallerOnDifferentThread() {
        boolean value = Thread.currentThread() != getLooper().getThread();
        if (VDBG) log("isCallerOnDifferentThread: " + value);
+1 −1
Original line number Diff line number Diff line
@@ -1595,7 +1595,7 @@ public class CDMAPhone extends PhoneBase {
                getContext().getContentResolver().insert(uri, map);

                // Updates MCC MNC device configuration information
                MccTable.updateMccMncConfiguration(mContext, operatorNumeric);
                MccTable.updateMccMncConfiguration(mContext, operatorNumeric, false);

                return true;
            } catch (SQLException e) {
+2 −0
Original line number Diff line number Diff line
@@ -434,6 +434,8 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
                    SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
            operatorNumeric = mSS.getOperatorNumeric();
            mPhone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric);
            updateCarrierMccMncConfiguration(operatorNumeric,
                    prevOperatorNumeric, mPhone.getContext());

            if (operatorNumeric == null) {
                if (DBG) log("operatorNumeric is null");
+2 −1
Original line number Diff line number Diff line
@@ -1086,7 +1086,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
                    SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
            operatorNumeric = mSS.getOperatorNumeric();
            mPhone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, operatorNumeric);

            updateCarrierMccMncConfiguration(operatorNumeric,
                    prevOperatorNumeric, mPhone.getContext());
            if (operatorNumeric == null) {
                if (DBG) log("operatorNumeric is null");
                mPhone.setSystemProperty(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
Loading