summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Seigo Nonaka <nona@google.com> 2016-05-18 17:33:04 +0900
committer Seigo Nonaka <nona@google.com> 2016-05-19 13:28:05 +0900
commitea906b37dfd6f84a74ab15f85f5f13d41cda6bb6 (patch)
treec6d18c27fef1aeffd12a54a884202d81a5a9d615
parent31884efd13b3ac60078edaa0b7e8a4b75d995538 (diff)
Fix system locale propagation during user creation.
Since Android N, the system locale is stored in Settings.System. Because of this change, we need to propagate the previous user's system locale to the newly created user. When the user switch happens, updateUserConfigurationLocked is called for the next user. Usually, some configuration values (font scale and system locale) are overwritten by the next user's settings. However, the first time the next user logs in (and only the first time), the settings value is empty. So, we need to decide between keeping the passed configuration's value or resetting to the default. For the fontScale, it is reset to the default (issue 27187556). For the system locale, the previous user's locale should be used. This CL addresses this. At the same time, the inherited configuration should be stored to the settings, otherwise the inherited configuration is lost the next time the second user logs in. Bug: 27803966 Change-Id: I4632671316d26e00ab6fe80ff3433f097f0e0954
-rwxr-xr-xcore/java/android/provider/Settings.java28
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java4
2 files changed, 25 insertions, 7 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 8cc165d75c2b..210abeb182ac 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);
+ }
+ }
}
/**
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index a243493a31e7..1c62eeaed535 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -18247,8 +18247,8 @@ public final class ActivityManagerService extends ActivityManagerNative
void updateUserConfigurationLocked() {
Configuration configuration = new Configuration(mConfiguration);
- Settings.System.getConfigurationForUser(mContext.getContentResolver(), configuration,
- mUserController.getCurrentUserIdLocked());
+ Settings.System.adjustConfigurationForUser(mContext.getContentResolver(), configuration,
+ mUserController.getCurrentUserIdLocked(), Settings.System.canWrite(mContext));
updateConfigurationLocked(configuration, null, false);
}