[res] Change OverlayableInfo to hold string views
No need to copy the strings as we keep them in separate containers anyway, may just reference them Bug: 237583012 Test: build + boot + UTs Change-Id: I2853cd3c992ca482ed6988e0c52a4037b158d999
This commit is contained in:
@@ -89,7 +89,7 @@ Result<Unit> CheckOverlayable(const TargetResourceContainer& target,
|
||||
// If the overlay supplies a target overlayable name, the resource must belong to the
|
||||
// overlayable defined with the specified name to be overlaid.
|
||||
return Error(R"(<overlay> android:targetName "%s" does not match overlayable name "%s")",
|
||||
overlay_info.target_name.c_str(), (*overlayable_info)->name.c_str());
|
||||
overlay_info.target_name.c_str(), (*overlayable_info)->name.data());
|
||||
}
|
||||
|
||||
// Enforce policy restrictions if the resource is declared as overlayable.
|
||||
|
||||
@@ -374,7 +374,7 @@ bool AssetManager2::GetOverlayablesToString(android::StringPiece package_name,
|
||||
const std::string name = ToFormattedResourceString(*res_name);
|
||||
output.append(base::StringPrintf(
|
||||
"resource='%s' overlayable='%s' actor='%s' policy='0x%08x'\n",
|
||||
name.c_str(), info->name.c_str(), info->actor.c_str(), info->policy_flags));
|
||||
name.c_str(), info->name.data(), info->actor.data(), info->policy_flags));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,10 +648,11 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
|
||||
util::ReadUtf16StringFromDevice(overlayable->name, std::size(overlayable->name), &name);
|
||||
std::string actor;
|
||||
util::ReadUtf16StringFromDevice(overlayable->actor, std::size(overlayable->actor), &actor);
|
||||
auto [it, inserted] =
|
||||
loaded_package->overlayable_map_.emplace(name, actor);
|
||||
auto [name_to_actor_it, inserted] =
|
||||
loaded_package->overlayable_map_.emplace(std::move(name), std::move(actor));
|
||||
if (!inserted) {
|
||||
LOG(ERROR) << "Multiple <overlayable> blocks with the same name '" << it->first << "'.";
|
||||
LOG(ERROR) << "Multiple <overlayable> blocks with the same name '"
|
||||
<< name_to_actor_it->first << "'.";
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -668,7 +669,6 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
|
||||
LOG(ERROR) << "RES_TABLE_OVERLAYABLE_POLICY_TYPE too small.";
|
||||
return {};
|
||||
}
|
||||
|
||||
if ((overlayable_child_chunk.data_size() / sizeof(ResTable_ref))
|
||||
< dtohl(policy_header->entry_count)) {
|
||||
LOG(ERROR) << "RES_TABLE_OVERLAYABLE_POLICY_TYPE too small to hold entries.";
|
||||
@@ -690,8 +690,8 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
|
||||
|
||||
// Add the pairing of overlayable properties and resource ids to the package
|
||||
OverlayableInfo overlayable_info {
|
||||
.name = name,
|
||||
.actor = actor,
|
||||
.name = name_to_actor_it->first,
|
||||
.actor = name_to_actor_it->second,
|
||||
.policy_flags = policy_header->policy_flags
|
||||
};
|
||||
loaded_package->overlayable_infos_.emplace_back(std::move(overlayable_info), std::move(ids));
|
||||
|
||||
@@ -99,8 +99,8 @@ enum : package_property_t {
|
||||
};
|
||||
|
||||
struct OverlayableInfo {
|
||||
std::string name;
|
||||
std::string actor;
|
||||
std::string_view name;
|
||||
std::string_view actor;
|
||||
uint32_t policy_flags;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user