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

Commit 7f01a783 authored by Allen Su's avatar Allen Su Committed by Android (Google) Code Review
Browse files

Merge "[B&R]Fix temperature unit not restored" into main

parents b44d154e bc3fc615
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ public class SettingsHelper {
    private static final String UNICODE_LOCALE_EXTENSION_FW = "fw";
    private static final String UNICODE_LOCALE_EXTENSION_MU = "mu";
    private static final String UNICODE_LOCALE_EXTENSION_NU = "nu";
    private static final String UNICODE_LOCALE_EXTENSION_MS = "ms";
    private static final float FLOAT_TOLERANCE = 0.01f;

    /** See frameworks/base/core/res/res/values/config.xml#config_longPressOnPowerBehavior **/
@@ -147,6 +148,7 @@ public class SettingsHelper {
    static {
        UNICODE_LOCALE_SUPPORTED_EXTENSIONS.add(UNICODE_LOCALE_EXTENSION_FW);
        UNICODE_LOCALE_SUPPORTED_EXTENSIONS.add(UNICODE_LOCALE_EXTENSION_MU);
        UNICODE_LOCALE_SUPPORTED_EXTENSIONS.add(UNICODE_LOCALE_EXTENSION_MS);
    }

    private interface SettingsLookup {
@@ -689,11 +691,6 @@ public class SettingsHelper {
                filtered.add(restoredLocaleWithExtension);
            }
        }

        if (filtered.size() == current.size()) {
            return current;  // Nothing added to current locale list.
        }

        return new LocaleList(filtered.toArray(new Locale[filtered.size()]));
    }

+28 −0
Original line number Diff line number Diff line
@@ -400,6 +400,34 @@ public class SettingsHelperTest {
                        new String[] {
                                "en-US" , "zh-Hans-TW" , "en-UK", "en-GB", "zh-Hans-HK", "fr-FR"
                        }));

        assertEquals(LocaleList.forLanguageTags("en-US-u-ms-uksystem-mu-celsius"),
                SettingsHelper.resolveLocales(
                        // restore
                        LocaleList.forLanguageTags("en-US-u-ms-uksystem-mu-celsius"),

                        // current
                        LocaleList.forLanguageTags("en-US"),

                        // supported
                        new String[] {
                                "en-US"
                        }));

        assertEquals(LocaleList.forLanguageTags(
                "en-US-u-ms-uksystem-mu-celsius,fr-FR-u-ms-uksystem-mu-celsius"),
                SettingsHelper.resolveLocales(
                        // restore
                        LocaleList.forLanguageTags(
                                "en-US-u-ms-uksystem-mu-celsius,fr-FR-u-ms-uksystem-mu-celsius"),

                        // current
                        LocaleList.forLanguageTags("en-US"),

                        // supported
                        new String[] {
                                "en-US", "fr-FR"
                        }));
    }

    @Test