Set the default locale list when it is changed.
When the system language is changed by the Settings app, we need to call
LocaleList.setDefault() to change the default locale list
since components like TextView should be able to assume that
LocaleList.getDefault() returns the latest system locale list.
BUG: 26731035
Change-Id: I482567476e1b14cd9b4716343183627f81d96ace
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 93122dd..7b01953 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -83,6 +83,7 @@
import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.util.EventLog;
+import android.util.LocaleList;
import android.util.Log;
import android.util.LogPrinter;
import android.util.Pair;
@@ -128,7 +129,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.TimeZone;
@@ -4887,9 +4887,9 @@
TimeZone.setDefault(null);
/*
- * Initialize the default locale in this process for the reasons we set the time zone.
+ * Initialize the default locales in this process for the reasons we set the time zone.
*/
- Locale.setDefault(data.config.locale);
+ LocaleList.setDefault(data.config.getLocales());
/*
* Update the system configuration since its preloaded and might not
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index 3187984..260216c 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -27,6 +27,7 @@
import android.hardware.display.DisplayManagerGlobal;
import android.util.ArrayMap;
import android.util.DisplayMetrics;
+import android.util.LocaleList;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
@@ -34,7 +35,6 @@
import android.view.DisplayAdjustments;
import java.lang.ref.WeakReference;
-import java.util.Locale;
/** @hide */
public class ResourcesManager {
@@ -284,8 +284,9 @@
}
// set it for java, this also affects newly created Resources
- if (config.locale != null) {
- Locale.setDefault(config.locale);
+ final LocaleList localeList = config.getLocales();
+ if (!localeList.isEmpty()) {
+ LocaleList.setDefault(localeList);
}
Resources.updateSystemConfiguration(config, defaultDisplayMetrics, compat);