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

Commit f66c7db5 authored by Robert Greenwalt's avatar Robert Greenwalt Committed by Android Git Automerger
Browse files

am e595a18f: Merge "Revert "Stop using the sim mnc/mcc to set wifi country."" into klp-dev

* commit 'e595a18f':
  Revert "Stop using the sim mnc/mcc to set wifi country."
parents f050f02b e595a18f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ public final class MccTable
            if (mcc != 0) {
                setTimezoneFromMccIfNeeded(context, mcc);
                setLocaleFromMccIfNeeded(context, mcc);
                setWifiCountryCodeFromMcc(context, mcc);
            }
            try {
                Configuration config = ActivityManagerNative.getDefault().getConfiguration();
@@ -294,6 +295,22 @@ public final class MccTable
        setSystemLocale(context, language, country);
    }

    /**
     * If the number of allowed wifi channels has not been set, set it based on
     * the MCC of the SIM.
     * @param context Context to act on.
     * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA)
     */
    private static void setWifiCountryCodeFromMcc(Context context, int mcc) {
        String country = MccTable.countryCodeForMcc(mcc);
        if (!country.isEmpty()) {
            Rlog.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);

+12 −0
Original line number Diff line number Diff line
@@ -709,6 +709,18 @@ public abstract class PhoneBase extends Handler implements Phone {
                    country = l.substring(3, 5);
                }
                MccTable.setSystemLocale(mContext, language, country);

                if (!country.isEmpty()) {
                    try {
                        Settings.Global.getInt(mContext.getContentResolver(),
                                Settings.Global.WIFI_COUNTRY_CODE);
                    } catch (Settings.SettingNotFoundException e) {
                        // note this is not persisting
                        WifiManager wM = (WifiManager)
                                mContext.getSystemService(Context.WIFI_SERVICE);
                        wM.setCountryCode(country, false);
                    }
                }
                return;
            }
        }