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

Commit bd5cbdd6 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

Make system locale persistent.

Configuration values are not persistent.
To make system locale persistent, use Settings.System entry.

During start up, the configuration is filled from Settings.
When the system locale is changed by Settings, the locale list in
configuration is copied to Settings value.

Bug: 26732134
Change-Id: If57e13cc4179ff6299c71b4ab030f9d856748dea
parent b3fdffbb
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ import android.text.TextUtils;
import android.util.AndroidException;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.LocaleList;
import android.util.Log;

import com.android.internal.util.ArrayUtils;
@@ -2071,6 +2072,8 @@ public final class Settings {
            if (outConfig.fontScale < 0) {
                outConfig.fontScale = 1;
            }
            outConfig.setLocales(LocaleList.forLanguageTags(
                    Settings.System.getStringForUser(cr, SYSTEM_LOCALES, userHandle)));
        }

        /**
@@ -2079,6 +2082,9 @@ public final class Settings {
         */
        public static void clearConfiguration(Configuration inoutConfig) {
            inoutConfig.fontScale = 0;
            if (!inoutConfig.userSetLocale) {
                inoutConfig.setLocales(LocaleList.getEmptyLocaleList());
            }
        }

        /**
@@ -2096,12 +2102,15 @@ public final class Settings {
        /** @hide */
        public static boolean putConfigurationForUser(ContentResolver cr, Configuration config,
                int userHandle) {
            return Settings.System.putFloatForUser(cr, FONT_SCALE, config.fontScale, userHandle);
            return Settings.System.putFloatForUser(cr, FONT_SCALE, config.fontScale, userHandle) &&
                    Settings.System.putStringForUser(
                            cr, SYSTEM_LOCALES, config.getLocales().toLanguageTags(), userHandle);
        }

        /** @hide */
        public static boolean hasInterestingConfigurationChanges(int changes) {
            return (changes&ActivityInfo.CONFIG_FONT_SCALE) != 0;
            return (changes & ActivityInfo.CONFIG_FONT_SCALE) != 0 ||
                    (changes & ActivityInfo.CONFIG_LOCALE) != 0;
        }

        /** @deprecated - Do not use */
@@ -2479,6 +2488,18 @@ public final class Settings {
            }
        };

        /**
         * The serialized system locale value.
         *
         * Do not use this value directory.
         * To get system locale, use {@link android.util.LocaleList#getDefault} instead.
         * To update system locale, use {@link com.android.internal.app.LocalePicker#updateLocales}
         * instead.
         * @hide
         */
        public static final String SYSTEM_LOCALES = "system_locales";


        /**
         * Name of an application package to be debugged.
         *
+1 −1
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ public class LocalePicker extends ListFragment {
            config.setLocales(locales);
            config.userSetLocale = true;

            am.updateConfiguration(config);
            am.updatePersistentConfiguration(config);
            // Trigger the dirty bit for the Settings Provider.
            BackupManager.dataChanged("com.android.providers.settings");
        } catch (RemoteException e) {