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

Commit 2eee17f3 authored by Allen Su's avatar Allen Su
Browse files

Add log to debug locale suggestion

Bug: 414487560
Bug: 414542778
Bug: 414487553
Test: by manual
Flag: EXEMPT add log
Change-Id: I844698f64a150533164014de9fa1ff9cb40ac338
parent 207537e9
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class LocaleStore {
    private static final HashMap<String, LocaleInfo> sLocaleCache = new HashMap<>();
    private static final String TAG = LocaleStore.class.getSimpleName();
    private static boolean sFullyInitialized = false;
    private static boolean sLocationAvailable = false;
    private static Set<String> sSimCountries;

    public static class LocaleInfo implements Serializable {
        public static final int SUGGESTION_TYPE_NONE = 0;
@@ -304,15 +304,16 @@ public class LocaleStore {
        TelephonyManager tm = context.getSystemService(TelephonyManager.class);

        if (tm != null) {
            String iso = tm.getSimCountryIso().toUpperCase(Locale.US);
            if (!iso.isEmpty()) {
                result.add(iso);
            String simIso = tm.getSimCountryIso().toUpperCase(Locale.US);
            if (!simIso.isEmpty()) {
                result.add(simIso);
            }

            iso = tm.getNetworkCountryIso().toUpperCase(Locale.US);
            if (!iso.isEmpty()) {
                result.add(iso);
            String networkIso = tm.getNetworkCountryIso().toUpperCase(Locale.US);
            if (!networkIso.isEmpty()) {
                result.add(networkIso);
            }
            Log.d(TAG, "sim country:" + simIso + " network country:" + networkIso);
        }

        return result;
@@ -322,7 +323,9 @@ public class LocaleStore {
     * @return whether SIM country or network country code is available during locale initialization
     */
    public static boolean isSimOrNwCountryAvailable() {
        return sLocationAvailable;
        Log.d(TAG,
                "SimCountries:" + sSimCountries + "location available:" + !sSimCountries.isEmpty());
        return !sSimCountries.isEmpty();
    }

    /*
@@ -341,13 +344,20 @@ public class LocaleStore {
     */
    public static void updateSimCountries(Context context) {
        Set<String> simCountries = getSimCountries(context);
        if (sSimCountries.equals(simCountries)) {
            Log.d(TAG, "updateSimCountries N/A");
            return;
        } else {
            sSimCountries = simCountries;
            Log.d(TAG, "updateSimCountries to " + simCountries);
        }

        for (LocaleInfo li : sLocaleCache.values()) {
            // This method sets the suggestion flags for the (new) SIM locales, but it does not
            // try to clean up the old flags. After all, if the user replaces a German SIM
            // with a French one, it is still possible that they are speaking German.
            // So both French and German are reasonable suggestions.
            if (simCountries.contains(li.getLocale().getCountry())) {
            if (sSimCountries.contains(li.getLocale().getCountry())) {
                li.mSuggestionFlags |= LocaleInfo.SUGGESTION_TYPE_SIM;
            }
        }
@@ -470,8 +480,7 @@ public class LocaleStore {
            return;
        }

        Set<String> simCountries = getSimCountries(context);
        sLocationAvailable = !simCountries.isEmpty();
        sSimCountries = getSimCountries(context);

        final boolean isInDeveloperMode = Settings.Global.getInt(context.getContentResolver(),
                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
@@ -498,7 +507,7 @@ public class LocaleStore {
                }
            }

            if (simCountries.contains(li.getLocale().getCountry())) {
            if (sSimCountries.contains(li.getLocale().getCountry())) {
                li.mSuggestionFlags |= LocaleInfo.SUGGESTION_TYPE_SIM;
            }
            numberSystemLocaleList.forEach(l -> {
@@ -544,6 +553,7 @@ public class LocaleStore {
            li.setTranslated(localizedLocales.contains(li.getLangScriptKey()));
        }

        Log.d(TAG, "Locale.getDefault():" + Locale.getDefault());
        addSuggestedLocalesForRegion(Locale.getDefault());

        sFullyInitialized = true;