Merge "Fix incorrect initial locale negotiation." into nyc-dev

am: 48d8a39

* commit '48d8a39b7114565838f0db7c7b5ef4bea0819cae':
  Fix incorrect initial locale negotiation.

Change-Id: I8363dbd7df5e79c09a3f0bc0bb3ad00165e302b6
This commit is contained in:
Seigo Nonaka
2016-03-30 19:54:21 +00:00
committed by android-build-merger
2 changed files with 27 additions and 24 deletions

View File

@@ -5075,26 +5075,6 @@ public final class ActivityThread {
*/
TimeZone.setDefault(null);
synchronized (mResourcesManager) {
/*
* Initialize the default locales in this process for the reasons we set the time zone.
*
* We do this through ResourcesManager, since we need to do locale negotiation.
*/
mResourcesManager.setDefaultLocalesLocked(data.config.getLocales());
/*
* Update the system configuration since its preloaded and might not
* reflect configuration changes. The configuration object passed
* in AppBindData can be safely assumed to be up to date
*/
mResourcesManager.applyConfigurationToResourcesLocked(data.config, data.compatInfo);
mCurDefaultDisplayDpi = data.config.densityDpi;
// This calls mResourcesManager so keep it within the synchronized block.
applyCompatConfiguration(mCurDefaultDisplayDpi);
}
data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
/**
@@ -5219,6 +5199,26 @@ public final class ActivityThread {
}
final ContextImpl appContext = ContextImpl.createAppContext(this, data.info);
synchronized (mResourcesManager) {
/*
* Initialize the default locales in this process for the reasons we set the time zone.
*
* We do this through ResourcesManager, since we need to do locale negotiation.
*/
mResourcesManager.setDefaultLocalesLocked(data.config.getLocales());
/*
* Update the system configuration since its preloaded and might not
* reflect configuration changes. The configuration object passed
* in AppBindData can be safely assumed to be up to date
*/
mResourcesManager.applyConfigurationToResourcesLocked(data.config, data.compatInfo);
mCurDefaultDisplayDpi = data.config.densityDpi;
// This calls mResourcesManager so keep it within the synchronized block.
applyCompatConfiguration(mCurDefaultDisplayDpi);
}
if (!Process.isIsolated() && !"android".equals(appContext.getPackageName())) {
// This cache location probably points at credential-encrypted
// storage which may not be accessible yet; assign it anyway instead

View File

@@ -66,7 +66,7 @@ public class ResourcesManager {
}
};
private String[] mSystemLocales = {};
private String[] mSystemLocales = null;
private final HashSet<String> mNonSystemLocales = new HashSet<>();
private boolean mHasNonSystemLocales = false;
@@ -431,7 +431,7 @@ public class ResourcesManager {
final boolean findSystemLocales;
final boolean hasNonSystemLocales;
synchronized (this) {
findSystemLocales = (mSystemLocales.length == 0);
findSystemLocales = (mSystemLocales == null || mSystemLocales.length == 0);
hasNonSystemLocales = mHasNonSystemLocales;
if (DEBUG) {
@@ -483,7 +483,7 @@ public class ResourcesManager {
LocaleList.isPseudoLocalesOnly(nonSystemLocales);
synchronized (this) {
if (mSystemLocales.length == 0) {
if (mSystemLocales == null || mSystemLocales.length == 0) {
mSystemLocales = systemLocales;
}
mNonSystemLocales.addAll(Arrays.asList(nonSystemLocales));
@@ -552,6 +552,9 @@ public class ResourcesManager {
}
/* package */ void setDefaultLocalesLocked(@NonNull LocaleList locales) {
if (mSystemLocales == null) {
throw new RuntimeException("ResourcesManager is not ready to negotiate locales.");
}
final int bestLocale;
if (mHasNonSystemLocales) {
bestLocale = locales.getFirstMatchIndexWithEnglishSupported(mNonSystemLocales);
@@ -649,4 +652,4 @@ public class ResourcesManager {
return changes != 0;
}
}
}