Loading core/java/android/app/ContextImpl.java +10 −0 Original line number Diff line number Diff line Loading @@ -3478,6 +3478,16 @@ class ContextImpl extends Context { ((CompatResources) r).setContext(this); } mResources = r; // only do this if the user already has more than one preferred locale if (r.getConfiguration().getLocales().size() > 1) { LocaleConfig lc = LocaleConfig.fromContextIgnoringOverride(this); mResourcesManager.setLocaleList(lc != null && lc.getSupportedLocales() != null && !lc.getSupportedLocales().isEmpty() ? lc.getSupportedLocales() : null); } } void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { Loading core/java/android/app/LocaleConfig.java +4 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,10 @@ public class LocaleConfig implements Parcelable { try { //Get the resource id resId = new ApplicationInfo(context.getApplicationInfo()).getLocaleConfigRes(); if (resId == 0) { mStatus = STATUS_NOT_SPECIFIED; return; } //Get the parser to read XML data XmlResourceParser parser = res.getXml(resId); parseLocaleConfig(parser, res); Loading core/java/android/app/ResourcesManager.java +22 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.res.ResourcesKey; import android.content.res.loader.ResourcesLoader; import android.hardware.display.DisplayManagerGlobal; import android.os.IBinder; import android.os.LocaleList; import android.os.Process; import android.os.Trace; import android.util.ArrayMap; Loading Loading @@ -118,6 +119,11 @@ public class ResourcesManager { private final ArrayList<WeakReference<Resources>> mResourceReferences = new ArrayList<>(); private final ReferenceQueue<Resources> mResourcesReferencesQueue = new ReferenceQueue<>(); /** * The list of locales the app declares it supports. */ private LocaleList mLocaleList = LocaleList.getEmptyLocaleList(); private static class ApkKey { public final String path; public final boolean sharedLib; Loading Loading @@ -1605,6 +1611,22 @@ public class ResourcesManager { } } /** * Returns the LocaleList current set */ public LocaleList getLocaleList() { return mLocaleList; } /** * Sets the LocaleList of app's supported locales */ public void setLocaleList(LocaleList localeList) { if ((localeList != null) && !localeList.isEmpty()) { mLocaleList = localeList; } } private class UpdateHandler implements Resources.UpdateCallbacks { /** Loading core/java/android/content/res/ResourcesImpl.java +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.annotation.PluralsRes; import android.annotation.RawRes; import android.annotation.StyleRes; import android.annotation.StyleableRes; import android.app.ResourcesManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.Config; Loading Loading @@ -408,9 +409,16 @@ public class ResourcesImpl { if ((configChanges & ActivityInfo.CONFIG_LOCALE) != 0) { if (locales.size() > 1) { // The LocaleList has changed. We must query the AssetManager's available // Locales and figure out the best matching Locale in the new LocaleList. String[] availableLocales = mAssets.getNonSystemLocales(); String[] availableLocales; LocaleList localeList = ResourcesManager.getInstance().getLocaleList(); if (!localeList.isEmpty()) { availableLocales = localeList.toLanguageTags().split(","); } else { // The LocaleList has changed. We must query the AssetManager's // available Locales and figure out the best matching Locale in the new // LocaleList. availableLocales = mAssets.getNonSystemLocales(); if (LocaleList.isPseudoLocalesOnly(availableLocales)) { // No app defined locales, so grab the system locales. availableLocales = mAssets.getLocales(); Loading @@ -418,7 +426,7 @@ public class ResourcesImpl { availableLocales = null; } } } if (availableLocales != null) { final Locale bestLocale = locales.getFirstMatchWithEnglishSupported( availableLocales); Loading Loading
core/java/android/app/ContextImpl.java +10 −0 Original line number Diff line number Diff line Loading @@ -3478,6 +3478,16 @@ class ContextImpl extends Context { ((CompatResources) r).setContext(this); } mResources = r; // only do this if the user already has more than one preferred locale if (r.getConfiguration().getLocales().size() > 1) { LocaleConfig lc = LocaleConfig.fromContextIgnoringOverride(this); mResourcesManager.setLocaleList(lc != null && lc.getSupportedLocales() != null && !lc.getSupportedLocales().isEmpty() ? lc.getSupportedLocales() : null); } } void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) { Loading
core/java/android/app/LocaleConfig.java +4 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,10 @@ public class LocaleConfig implements Parcelable { try { //Get the resource id resId = new ApplicationInfo(context.getApplicationInfo()).getLocaleConfigRes(); if (resId == 0) { mStatus = STATUS_NOT_SPECIFIED; return; } //Get the parser to read XML data XmlResourceParser parser = res.getXml(resId); parseLocaleConfig(parser, res); Loading
core/java/android/app/ResourcesManager.java +22 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.content.res.ResourcesKey; import android.content.res.loader.ResourcesLoader; import android.hardware.display.DisplayManagerGlobal; import android.os.IBinder; import android.os.LocaleList; import android.os.Process; import android.os.Trace; import android.util.ArrayMap; Loading Loading @@ -118,6 +119,11 @@ public class ResourcesManager { private final ArrayList<WeakReference<Resources>> mResourceReferences = new ArrayList<>(); private final ReferenceQueue<Resources> mResourcesReferencesQueue = new ReferenceQueue<>(); /** * The list of locales the app declares it supports. */ private LocaleList mLocaleList = LocaleList.getEmptyLocaleList(); private static class ApkKey { public final String path; public final boolean sharedLib; Loading Loading @@ -1605,6 +1611,22 @@ public class ResourcesManager { } } /** * Returns the LocaleList current set */ public LocaleList getLocaleList() { return mLocaleList; } /** * Sets the LocaleList of app's supported locales */ public void setLocaleList(LocaleList localeList) { if ((localeList != null) && !localeList.isEmpty()) { mLocaleList = localeList; } } private class UpdateHandler implements Resources.UpdateCallbacks { /** Loading
core/java/android/content/res/ResourcesImpl.java +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.annotation.PluralsRes; import android.annotation.RawRes; import android.annotation.StyleRes; import android.annotation.StyleableRes; import android.app.ResourcesManager; import android.compat.annotation.UnsupportedAppUsage; import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo.Config; Loading Loading @@ -408,9 +409,16 @@ public class ResourcesImpl { if ((configChanges & ActivityInfo.CONFIG_LOCALE) != 0) { if (locales.size() > 1) { // The LocaleList has changed. We must query the AssetManager's available // Locales and figure out the best matching Locale in the new LocaleList. String[] availableLocales = mAssets.getNonSystemLocales(); String[] availableLocales; LocaleList localeList = ResourcesManager.getInstance().getLocaleList(); if (!localeList.isEmpty()) { availableLocales = localeList.toLanguageTags().split(","); } else { // The LocaleList has changed. We must query the AssetManager's // available Locales and figure out the best matching Locale in the new // LocaleList. availableLocales = mAssets.getNonSystemLocales(); if (LocaleList.isPseudoLocalesOnly(availableLocales)) { // No app defined locales, so grab the system locales. availableLocales = mAssets.getLocales(); Loading @@ -418,7 +426,7 @@ public class ResourcesImpl { availableLocales = null; } } } if (availableLocales != null) { final Locale bestLocale = locales.getFirstMatchWithEnglishSupported( availableLocales); Loading