Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48d8a39b authored by Roozbeh Pournader's avatar Roozbeh Pournader Committed by Android (Google) Code Review
Browse files

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

parents 0fd3b1ab c14dd78a
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -5077,26 +5077,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);

        /**
@@ -5221,6 +5201,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
+7 −4
Original line number Diff line number Diff line
@@ -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);