summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2016-05-26 03:51:38 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-05-26 03:51:39 +0000
commitce9f5e3657b7a8fb68c6c65a2cd5a27eaf556cc8 (patch)
tree8b7369d9e399b658584a3116c3850f5191436068 /core/java/android
parent5513b6776e0b00fd0444cf4f964451d0ef61a511 (diff)
parentea906b37dfd6f84a74ab15f85f5f13d41cda6bb6 (diff)
Merge "Fix system locale propagation during user creation." into nyc-dev
Diffstat (limited to 'core/java/android')
-rwxr-xr-xcore/java/android/provider/Settings.java28
1 files changed, 23 insertions, 5 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index cbe98f7cd6e5..0bc514ed0545 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2219,19 +2219,37 @@ public final class Settings {
* @param outConfig Where to place the configuration settings.
*/
public static void getConfiguration(ContentResolver cr, Configuration outConfig) {
- getConfigurationForUser(cr, outConfig, UserHandle.myUserId());
+ adjustConfigurationForUser(cr, outConfig, UserHandle.myUserId(),
+ false /* updateSettingsIfEmpty */);
}
/** @hide */
- public static void getConfigurationForUser(ContentResolver cr, Configuration outConfig,
- int userHandle) {
+ public static void adjustConfigurationForUser(ContentResolver cr, Configuration outConfig,
+ int userHandle, boolean updateSettingsIfEmpty) {
outConfig.fontScale = Settings.System.getFloatForUser(
cr, FONT_SCALE, DEFAULT_FONT_SCALE, userHandle);
if (outConfig.fontScale < 0) {
outConfig.fontScale = DEFAULT_FONT_SCALE;
}
- outConfig.setLocales(LocaleList.forLanguageTags(
- Settings.System.getStringForUser(cr, SYSTEM_LOCALES, userHandle)));
+
+ final String localeValue =
+ Settings.System.getStringForUser(cr, SYSTEM_LOCALES, userHandle);
+ if (localeValue != null) {
+ outConfig.setLocales(LocaleList.forLanguageTags(localeValue));
+ } else {
+ // Do not update configuration with emtpy settings since we need to take over the
+ // locale list of previous user if the settings value is empty. This happens when a
+ // new user is created.
+
+ if (updateSettingsIfEmpty) {
+ // Make current configuration persistent. This is necessary the first time a
+ // user log in. At the first login, the configuration settings are empty, so we
+ // need to store the adjusted configuration as the initial settings.
+ Settings.System.putStringForUser(
+ cr, SYSTEM_LOCALES, outConfig.getLocales().toLanguageTags(),
+ userHandle);
+ }
+ }
}
/**