Loading core/java/android/app/LocaleConfig.java +12 −15 Original line number Diff line number Diff line Loading @@ -144,15 +144,12 @@ public class LocaleConfig implements Parcelable { } } Resources res = context.getResources(); //Get the resource id int resId = context.getApplicationInfo().getLocaleConfigRes(); if (resId == 0) { mStatus = STATUS_NOT_SPECIFIED; return; } try { //Get the parser to read XML data XmlResourceParser parser = res.getXml(resId); try (XmlResourceParser parser = res.getXml(resId)) { parseLocaleConfig(parser, res); } catch (Resources.NotFoundException e) { Slog.w(TAG, "The resource file pointed to by the given resource ID isn't found."); Loading Loading @@ -208,22 +205,22 @@ public class LocaleConfig implements Parcelable { String defaultLocale = null; if (android.content.res.Flags.defaultLocale()) { // Read the defaultLocale attribute of the LocaleConfig element TypedArray att = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig); try (TypedArray att = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig)) { defaultLocale = att.getString( R.styleable.LocaleConfig_defaultLocale); att.recycle(); } } Set<String> localeNames = new HashSet<>(); while (XmlUtils.nextElementWithin(parser, outerDepth)) { if (TAG_LOCALE.equals(parser.getName())) { final TypedArray attributes = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig_Locale); try (TypedArray attributes = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig_Locale)) { String nameAttr = attributes.getString( com.android.internal.R.styleable.LocaleConfig_Locale_name); localeNames.add(nameAttr); attributes.recycle(); } } else { XmlUtils.skipCurrentTag(parser); } Loading libs/androidfw/AssetManager2.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -879,10 +879,10 @@ base::expected<FindEntryResult, NullOrIOError> AssetManager2::FindEntry( // if we don't have a result yet if (!final_result || // or this config is better before the locale than the existing result result->config.isBetterThanBeforeLocale(final_result->config, desired_config) || result->config.isBetterThanBeforeLocale(final_result->config, *desired_config) || // or the existing config isn't better before locale and this one specifies a locale // whereas the existing one doesn't (!final_result->config.isBetterThanBeforeLocale(result->config, desired_config) (!final_result->config.isBetterThanBeforeLocale(result->config, *desired_config) && has_locale && !final_has_locale)) { final_result = result.value(); final_overlaid = overlaid; Loading libs/androidfw/ResourceTypes.cpp +7 −9 Original line number Diff line number Diff line Loading @@ -2615,16 +2615,14 @@ bool ResTable_config::isLocaleBetterThan(const ResTable_config& o, } bool ResTable_config::isBetterThanBeforeLocale(const ResTable_config& o, const ResTable_config* requested) const { if (requested) { const ResTable_config& requested) const { if (imsi || o.imsi) { if ((mcc != o.mcc) && requested->mcc) { return (mcc); if ((mcc != o.mcc) && requested.mcc) { return mcc; } if ((mnc != o.mnc) && requested->mnc) { return (mnc); } if ((mnc != o.mnc) && requested.mnc) { return mnc; } } return false; Loading libs/androidfw/include/androidfw/ResourceTypes.h +4 −1 Original line number Diff line number Diff line Loading @@ -1416,7 +1416,10 @@ struct ResTable_config // match the requested configuration at all. bool isLocaleBetterThan(const ResTable_config& o, const ResTable_config* requested) const; bool isBetterThanBeforeLocale(const ResTable_config& o, const ResTable_config* requested) const; // The first part of isBetterThan() that only compares the fields that are higher priority than // the locale. Use it when you need to do custom locale matching to filter out the configs prior // to that. bool isBetterThanBeforeLocale(const ResTable_config& o, const ResTable_config& requested) const; String8 toString() const; Loading Loading
core/java/android/app/LocaleConfig.java +12 −15 Original line number Diff line number Diff line Loading @@ -144,15 +144,12 @@ public class LocaleConfig implements Parcelable { } } Resources res = context.getResources(); //Get the resource id int resId = context.getApplicationInfo().getLocaleConfigRes(); if (resId == 0) { mStatus = STATUS_NOT_SPECIFIED; return; } try { //Get the parser to read XML data XmlResourceParser parser = res.getXml(resId); try (XmlResourceParser parser = res.getXml(resId)) { parseLocaleConfig(parser, res); } catch (Resources.NotFoundException e) { Slog.w(TAG, "The resource file pointed to by the given resource ID isn't found."); Loading Loading @@ -208,22 +205,22 @@ public class LocaleConfig implements Parcelable { String defaultLocale = null; if (android.content.res.Flags.defaultLocale()) { // Read the defaultLocale attribute of the LocaleConfig element TypedArray att = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig); try (TypedArray att = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig)) { defaultLocale = att.getString( R.styleable.LocaleConfig_defaultLocale); att.recycle(); } } Set<String> localeNames = new HashSet<>(); while (XmlUtils.nextElementWithin(parser, outerDepth)) { if (TAG_LOCALE.equals(parser.getName())) { final TypedArray attributes = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig_Locale); try (TypedArray attributes = res.obtainAttributes( attrs, com.android.internal.R.styleable.LocaleConfig_Locale)) { String nameAttr = attributes.getString( com.android.internal.R.styleable.LocaleConfig_Locale_name); localeNames.add(nameAttr); attributes.recycle(); } } else { XmlUtils.skipCurrentTag(parser); } Loading
libs/androidfw/AssetManager2.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -879,10 +879,10 @@ base::expected<FindEntryResult, NullOrIOError> AssetManager2::FindEntry( // if we don't have a result yet if (!final_result || // or this config is better before the locale than the existing result result->config.isBetterThanBeforeLocale(final_result->config, desired_config) || result->config.isBetterThanBeforeLocale(final_result->config, *desired_config) || // or the existing config isn't better before locale and this one specifies a locale // whereas the existing one doesn't (!final_result->config.isBetterThanBeforeLocale(result->config, desired_config) (!final_result->config.isBetterThanBeforeLocale(result->config, *desired_config) && has_locale && !final_has_locale)) { final_result = result.value(); final_overlaid = overlaid; Loading
libs/androidfw/ResourceTypes.cpp +7 −9 Original line number Diff line number Diff line Loading @@ -2615,16 +2615,14 @@ bool ResTable_config::isLocaleBetterThan(const ResTable_config& o, } bool ResTable_config::isBetterThanBeforeLocale(const ResTable_config& o, const ResTable_config* requested) const { if (requested) { const ResTable_config& requested) const { if (imsi || o.imsi) { if ((mcc != o.mcc) && requested->mcc) { return (mcc); if ((mcc != o.mcc) && requested.mcc) { return mcc; } if ((mnc != o.mnc) && requested->mnc) { return (mnc); } if ((mnc != o.mnc) && requested.mnc) { return mnc; } } return false; Loading
libs/androidfw/include/androidfw/ResourceTypes.h +4 −1 Original line number Diff line number Diff line Loading @@ -1416,7 +1416,10 @@ struct ResTable_config // match the requested configuration at all. bool isLocaleBetterThan(const ResTable_config& o, const ResTable_config* requested) const; bool isBetterThanBeforeLocale(const ResTable_config& o, const ResTable_config* requested) const; // The first part of isBetterThan() that only compares the fields that are higher priority than // the locale. Use it when you need to do custom locale matching to filter out the configs prior // to that. bool isBetterThanBeforeLocale(const ResTable_config& o, const ResTable_config& requested) const; String8 toString() const; Loading