Loading core/jni/android_util_AssetManager.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1077,7 +1077,7 @@ static jstring NativeGetLastResourceResolution(JNIEnv* env, static jobjectArray NativeGetLocales(JNIEnv* env, jclass /*class*/, jlong ptr, jboolean exclude_system) { auto assetmanager = LockAndStartAssetManager(ptr); std::set<std::string> locales = auto locales = assetmanager->GetResourceLocales(exclude_system, true /*merge_equivalent_languages*/); jobjectArray array = env->NewObjectArray(locales.size(), g_stringClass, nullptr); Loading libs/androidfw/AssetManager2.cpp +4 −5 Original line number Diff line number Diff line Loading @@ -603,12 +603,12 @@ base::expected<std::set<ResTable_config>, IOError> AssetManager2::GetResourceCon return configurations; } std::set<std::string> AssetManager2::GetResourceLocales(bool exclude_system, bool merge_equivalent_languages) const { LoadedPackage::Locales AssetManager2::GetResourceLocales( bool exclude_system, bool merge_equivalent_languages) const { ATRACE_NAME("AssetManager::GetResourceLocales"); auto op = StartOperation(); std::set<std::string> locales; LoadedPackage::Locales locales; const auto non_system_overlays = exclude_system ? GetNonSystemOverlays() : std::set<ApkAssetsPtr>(); Loading @@ -622,8 +622,7 @@ std::set<std::string> AssetManager2::GetResourceLocales(bool exclude_system, if (!non_system_overlays.empty()) { // Exclude overlays that target only system resources. const auto& apk_assets = GetApkAssets(package_group.cookies_[i]); if (apk_assets && apk_assets->IsOverlay() && non_system_overlays.find(apk_assets) == non_system_overlays.end()) { if (apk_assets && apk_assets->IsOverlay() && !non_system_overlays.contains(apk_assets)) { continue; } } Loading libs/androidfw/LoadedArsc.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -361,14 +361,18 @@ base::expected<std::monostate, IOError> LoadedPackage::CollectConfigurations( return {}; } void LoadedPackage::CollectLocales(bool canonicalize, std::set<std::string>* out_locales) const { char temp_locale[RESTABLE_MAX_LOCALE_LEN]; void LoadedPackage::CollectLocales(bool canonicalize, Locales* out_locales) const { for (const auto& type_spec : type_specs_) { for (const auto& type_entry : type_spec.second.type_entries) { if (type_entry.config.locale != 0) { char temp_locale[RESTABLE_MAX_LOCALE_LEN]; type_entry.config.getBcp47Locale(temp_locale, canonicalize); std::string locale(temp_locale); out_locales->insert(std::move(locale)); auto locale_sv = std::string_view(temp_locale); if (auto it = out_locales->lower_bound(locale_sv); it == out_locales->end() || *it != locale_sv) { out_locales->emplace_hint(it, locale_sv); } } } } Loading libs/androidfw/include/androidfw/AssetManager2.h +2 −2 Original line number Diff line number Diff line Loading @@ -189,8 +189,8 @@ class AssetManager2 { // ('android' package, other libraries) will be excluded from the list. // If `merge_equivalent_languages` is set to true, resource locales will be canonicalized // and de-duped in the resulting list. std::set<std::string> GetResourceLocales(bool exclude_system = false, bool merge_equivalent_languages = false) const; LoadedPackage::Locales GetResourceLocales( bool exclude_system = false, bool merge_equivalent_languages = false) const; // Searches the set of APKs loaded by this AssetManager and opens the first one found located // in the assets/ directory. Loading libs/androidfw/include/androidfw/LoadedArsc.h +2 −1 Original line number Diff line number Diff line Loading @@ -238,7 +238,8 @@ class LoadedPackage { // Populates a set of strings representing locales. // If `canonicalize` is set to true, each locale is transformed into its canonical format // before being inserted into the set. This may cause some equivalent locales to de-dupe. void CollectLocales(bool canonicalize, std::set<std::string>* out_locales) const; using Locales = std::set<std::string, std::less<>>; void CollectLocales(bool canonicalize, Locales* out_locales) const; // type_idx is TT - 1 from 0xPPTTEEEE. inline const TypeSpec* GetTypeSpecByTypeIndex(uint8_t type_index) const { Loading Loading
core/jni/android_util_AssetManager.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1077,7 +1077,7 @@ static jstring NativeGetLastResourceResolution(JNIEnv* env, static jobjectArray NativeGetLocales(JNIEnv* env, jclass /*class*/, jlong ptr, jboolean exclude_system) { auto assetmanager = LockAndStartAssetManager(ptr); std::set<std::string> locales = auto locales = assetmanager->GetResourceLocales(exclude_system, true /*merge_equivalent_languages*/); jobjectArray array = env->NewObjectArray(locales.size(), g_stringClass, nullptr); Loading
libs/androidfw/AssetManager2.cpp +4 −5 Original line number Diff line number Diff line Loading @@ -603,12 +603,12 @@ base::expected<std::set<ResTable_config>, IOError> AssetManager2::GetResourceCon return configurations; } std::set<std::string> AssetManager2::GetResourceLocales(bool exclude_system, bool merge_equivalent_languages) const { LoadedPackage::Locales AssetManager2::GetResourceLocales( bool exclude_system, bool merge_equivalent_languages) const { ATRACE_NAME("AssetManager::GetResourceLocales"); auto op = StartOperation(); std::set<std::string> locales; LoadedPackage::Locales locales; const auto non_system_overlays = exclude_system ? GetNonSystemOverlays() : std::set<ApkAssetsPtr>(); Loading @@ -622,8 +622,7 @@ std::set<std::string> AssetManager2::GetResourceLocales(bool exclude_system, if (!non_system_overlays.empty()) { // Exclude overlays that target only system resources. const auto& apk_assets = GetApkAssets(package_group.cookies_[i]); if (apk_assets && apk_assets->IsOverlay() && non_system_overlays.find(apk_assets) == non_system_overlays.end()) { if (apk_assets && apk_assets->IsOverlay() && !non_system_overlays.contains(apk_assets)) { continue; } } Loading
libs/androidfw/LoadedArsc.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -361,14 +361,18 @@ base::expected<std::monostate, IOError> LoadedPackage::CollectConfigurations( return {}; } void LoadedPackage::CollectLocales(bool canonicalize, std::set<std::string>* out_locales) const { char temp_locale[RESTABLE_MAX_LOCALE_LEN]; void LoadedPackage::CollectLocales(bool canonicalize, Locales* out_locales) const { for (const auto& type_spec : type_specs_) { for (const auto& type_entry : type_spec.second.type_entries) { if (type_entry.config.locale != 0) { char temp_locale[RESTABLE_MAX_LOCALE_LEN]; type_entry.config.getBcp47Locale(temp_locale, canonicalize); std::string locale(temp_locale); out_locales->insert(std::move(locale)); auto locale_sv = std::string_view(temp_locale); if (auto it = out_locales->lower_bound(locale_sv); it == out_locales->end() || *it != locale_sv) { out_locales->emplace_hint(it, locale_sv); } } } } Loading
libs/androidfw/include/androidfw/AssetManager2.h +2 −2 Original line number Diff line number Diff line Loading @@ -189,8 +189,8 @@ class AssetManager2 { // ('android' package, other libraries) will be excluded from the list. // If `merge_equivalent_languages` is set to true, resource locales will be canonicalized // and de-duped in the resulting list. std::set<std::string> GetResourceLocales(bool exclude_system = false, bool merge_equivalent_languages = false) const; LoadedPackage::Locales GetResourceLocales( bool exclude_system = false, bool merge_equivalent_languages = false) const; // Searches the set of APKs loaded by this AssetManager and opens the first one found located // in the assets/ directory. Loading
libs/androidfw/include/androidfw/LoadedArsc.h +2 −1 Original line number Diff line number Diff line Loading @@ -238,7 +238,8 @@ class LoadedPackage { // Populates a set of strings representing locales. // If `canonicalize` is set to true, each locale is transformed into its canonical format // before being inserted into the set. This may cause some equivalent locales to de-dupe. void CollectLocales(bool canonicalize, std::set<std::string>* out_locales) const; using Locales = std::set<std::string, std::less<>>; void CollectLocales(bool canonicalize, Locales* out_locales) const; // type_idx is TT - 1 from 0xPPTTEEEE. inline const TypeSpec* GetTypeSpecByTypeIndex(uint8_t type_index) const { Loading