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

Commit a037cd58 authored by Jack Yu's avatar Jack Yu Committed by Android (Google) Code Review
Browse files

Merge "Moved carrier locale into locale tracker"

parents c2e553e4 0c640e0d
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

@@ -207,6 +208,17 @@ public class LocaleTracker extends Handler {
        mPhone.registerForCellInfo(this, EVENT_UNSOL_CELL_INFO, null);
    }

    private @NonNull String getCarrierCountry() {
        // The locale from the "ro.carrier" system property or R.array.carrier_properties.
        // This will be overwritten by the Locale from the SIM language settings (EF-PL, EF-LI)
        // if applicable.
        final Locale carrierLocale = mPhone.getLocaleFromCarrierProperties();
        if (carrierLocale != null && !TextUtils.isEmpty(carrierLocale.getCountry())) {
            return carrierLocale.getCountry();
        }
        return "";
    }

    /**
     * Get the device's current country.
     *
@@ -399,7 +411,7 @@ public class LocaleTracker extends Handler {
    private synchronized void updateLocale() {
        // If MCC is available from network service state, use it first.
        String mcc = null;
        String countryIso = "";
        String countryIso = getCarrierCountry();
        if (!TextUtils.isEmpty(mOperatorNumeric)) {
            try {
                mcc = mOperatorNumeric.substring(0, 3);
+4 −22
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.net.LinkProperties;
import android.net.NetworkCapabilities;
import android.net.NetworkStats;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.AsyncResult;
import android.os.Build;
import android.os.Handler;
@@ -41,7 +40,6 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.WorkSource;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.telecom.VideoProfile;
import android.telephony.AccessNetworkConstants;
import android.telephony.CarrierConfigManager;
@@ -565,23 +563,6 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            return;
        }

        // The locale from the "ro.carrier" system property or R.array.carrier_properties.
        // This will be overwritten by the Locale from the SIM language settings (EF-PL, EF-LI)
        // if applicable.
        final Locale carrierLocale = getLocaleFromCarrierProperties(mContext);
        if (carrierLocale != null && !TextUtils.isEmpty(carrierLocale.getCountry())) {
            final String country = carrierLocale.getCountry();
            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);
            }
        }

        // Initialize device storage and outgoing SMS usage monitors for SMSDispatchers.
        mTelephonyComponentFactory = telephonyComponentFactory;
        mSmsStorageMonitor = mTelephonyComponentFactory.inject(SmsStorageMonitor.class.getName())
@@ -1681,14 +1662,15 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
     * Set the properties by matching the carrier string in
     * a string-array resource
     */
    private static Locale getLocaleFromCarrierProperties(Context ctx) {
    @Nullable Locale getLocaleFromCarrierProperties() {
        String carrier = SystemProperties.get("ro.carrier");

        if (null == carrier || 0 == carrier.length() || "unknown".equals(carrier)) {
            return null;
        }

        CharSequence[] carrierLocales = ctx.getResources().getTextArray(R.array.carrier_properties);
        CharSequence[] carrierLocales = mContext.getResources().getTextArray(
                R.array.carrier_properties);

        for (int i = 0; i < carrierLocales.length; i+=3) {
            String c = carrierLocales[i].toString();
@@ -3849,7 +3831,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            return new Locale(records.getSimLanguage());
        }

        return getLocaleFromCarrierProperties(mContext);
        return getLocaleFromCarrierProperties();
    }

    public void updateDataConnectionTracker() {