[res] Change callback from function to function_ref

function_ref should be the default callback type if it's
a function argument and won't get stored anywhere

Bug: 237583012
Test: build + boot
Change-Id: I1957665436f003f7a5e758b229640c9601c28faf
This commit is contained in:
Yurii Zubrytskyi
2022-11-14 23:44:52 -08:00
parent dbce35604c
commit 9eb44c9727
2 changed files with 15 additions and 11 deletions

View File

@@ -1417,6 +1417,18 @@ std::unique_ptr<Theme> AssetManager2::NewTheme() {
return theme;
}
void AssetManager2::ForEachPackage(base::function_ref<bool(const std::string&, uint8_t)> func,
package_property_t excluded_property_flags) const {
for (const PackageGroup& package_group : package_groups_) {
const auto loaded_package = package_group.packages_.front().loaded_package_;
if ((loaded_package->GetPropertyFlags() & excluded_property_flags) == 0U
&& !func(loaded_package->GetPackageName(),
package_group.dynamic_ref_table->mAssignedPackageId)) {
return;
}
}
}
Theme::Theme(AssetManager2* asset_manager) : asset_manager_(asset_manager) {
}

View File

@@ -17,6 +17,7 @@
#ifndef ANDROIDFW_ASSETMANAGER2_H_
#define ANDROIDFW_ASSETMANAGER2_H_
#include "android-base/function_ref.h"
#include "android-base/macros.h"
#include <array>
@@ -320,17 +321,8 @@ class AssetManager2 {
// Creates a new Theme from this AssetManager.
std::unique_ptr<Theme> NewTheme();
void ForEachPackage(const std::function<bool(const std::string&, uint8_t)> func,
package_property_t excluded_property_flags = 0U) const {
for (const PackageGroup& package_group : package_groups_) {
const auto loaded_package = package_group.packages_.front().loaded_package_;
if ((loaded_package->GetPropertyFlags() & excluded_property_flags) == 0U
&& !func(loaded_package->GetPackageName(),
package_group.dynamic_ref_table->mAssignedPackageId)) {
return;
}
}
}
void ForEachPackage(base::function_ref<bool(const std::string&, uint8_t)> func,
package_property_t excluded_property_flags = 0U) const;
void DumpToLog() const;