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

Commit 2e974408 authored by Shalini Kalra's avatar Shalini Kalra Committed by Android (Google) Code Review
Browse files

Revert "Revert "Revert "Use LocaleConfig to determine an app's locale"""

This reverts commit 1be13e62.

Reason for revert: <Look like g3 compat main failures are reported b/285957785 , testing the revert>

Change-Id: I377f5c600f31d23428a8bf2fd09e66bb811e5296
parent 1be13e62
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -3478,9 +3478,6 @@ class ContextImpl extends Context {
            ((CompatResources) r).setContext(this);
        }
        mResources = r;

        LocaleConfig lc = LocaleConfig.fromContextIgnoringOverride(this);
        mResourcesManager.setLocaleList(lc != null ? lc.getSupportedLocales() : null);
    }

    void installSystemApplicationInfo(ApplicationInfo info, ClassLoader classLoader) {
+1 −3
Original line number Diff line number Diff line
@@ -142,9 +142,7 @@ public class LocaleConfig implements Parcelable {
            XmlResourceParser parser = res.getXml(resId);
            parseLocaleConfig(parser, res);
        } catch (Resources.NotFoundException e) {
            if (resId != 0) {
            Slog.w(TAG, "The resource file pointed to by the given resource ID isn't found.");
            }
            mStatus = STATUS_NOT_SPECIFIED;
        } catch (XmlPullParserException | IOException e) {
            Slog.w(TAG, "Failed to parse XML configuration from "
+0 −22
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ 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;
@@ -119,11 +118,6 @@ 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;
@@ -1611,22 +1605,6 @@ 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 {

        /**
+8 −16
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ 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;
@@ -409,16 +408,9 @@ public class ResourcesImpl {

                if ((configChanges & ActivityInfo.CONFIG_LOCALE) != 0) {
                    if (locales.size() > 1) {
                        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();
                        // 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();
                        if (LocaleList.isPseudoLocalesOnly(availableLocales)) {
                            // No app defined locales, so grab the system locales.
                            availableLocales = mAssets.getLocales();
@@ -426,7 +418,7 @@ public class ResourcesImpl {
                                availableLocales = null;
                            }
                        }
                        }

                        if (availableLocales != null) {
                            final Locale bestLocale = locales.getFirstMatchWithEnglishSupported(
                                    availableLocales);