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

Commit 99fc6406 authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Merge "Moved carrier locale into locale tracker" am: 3e138b39

am: bf3c9538

Change-Id: Id0ab16c5f912730a5626861f3742fba81f42b24e
parents 944c6390 bf3c9538
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -47,6 +47,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;

@@ -206,6 +207,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.
     *
@@ -398,7 +410,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;
@@ -567,23 +565,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())
@@ -1716,14 +1697,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();
@@ -3900,7 +3882,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
            return new Locale(records.getSimLanguage());
        }

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

    public void updateDataConnectionTracker() {