summaryrefslogtreecommitdiff
path: root/libs/androidfw/LoadedArsc.cpp
diff options
context:
space:
mode:
author Ryan Mitchell <rtmitchell@google.com> 2018-12-12 18:45:34 -0800
committer Ryan Mitchell <rtmitchell@google.com> 2019-01-11 14:45:09 -0800
commitef5673a4c4021ca27b40e48020203928d71c95a8 (patch)
treeb97e02462524775bd8a1a5a6104ff0b726d3a478 /libs/androidfw/LoadedArsc.cpp
parent56ac01ebb4475440669f5f009c453dba0a86f6dd (diff)
Add encoding of name and actor overlayable fields
Encode the actor and name attributes of <overlayable> elements in the overlayable chunks. Two chunks cannot have the same name. Bug: 110869880 Bug: 119390855 Test: aapt2_tests and libandroidfw_tests Change-Id: I0ed95efef640b3927046b6155d1840f0d96030dd
Diffstat (limited to 'libs/androidfw/LoadedArsc.cpp')
-rw-r--r--libs/androidfw/LoadedArsc.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/androidfw/LoadedArsc.cpp b/libs/androidfw/LoadedArsc.cpp
index 5a267804ddf1..70ce9bc705ef 100644
--- a/libs/androidfw/LoadedArsc.cpp
+++ b/libs/androidfw/LoadedArsc.cpp
@@ -593,7 +593,12 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
return {};
}
- // Iterate over the overlayable policy chunks
+ std::string name;
+ util::ReadUtf16StringFromDevice(header->name, arraysize(header->name), &name);
+ std::string actor;
+ util::ReadUtf16StringFromDevice(header->actor, arraysize(header->actor), &actor);
+
+ // Iterate over the overlayable policy chunks contained within the overlayable chunk data
ChunkIterator overlayable_iter(child_chunk.data_ptr(), child_chunk.data_size());
while (overlayable_iter.HasNext()) {
const Chunk overlayable_child_chunk = overlayable_iter.Next();
@@ -613,7 +618,7 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
return {};
}
- // Retrieve all the ids belonging to this policy
+ // Retrieve all the resource ids belonging to this policy chunk
std::unordered_set<uint32_t> ids;
const auto ids_begin =
reinterpret_cast<const ResTable_ref*>(overlayable_child_chunk.data_ptr());
@@ -622,8 +627,10 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
ids.insert(dtohl(id_iter->ident));
}
- // Add the pairing of overlayable properties to resource ids to the package
+ // Add the pairing of overlayable properties and resource ids to the package
OverlayableInfo overlayable_info{};
+ overlayable_info.name = name;
+ overlayable_info.actor = actor;
overlayable_info.policy_flags = policy_header->policy_flags;
loaded_package->overlayable_infos_.push_back(std::make_pair(overlayable_info, ids));
break;
@@ -636,7 +643,7 @@ std::unique_ptr<const LoadedPackage> LoadedPackage::Load(const Chunk& chunk,
}
if (overlayable_iter.HadError()) {
- LOG(ERROR) << StringPrintf("Error parsing RES_TABLE_OVERLAYABLE_POLICY_TYPE: %s",
+ LOG(ERROR) << StringPrintf("Error parsing RES_TABLE_OVERLAYABLE_TYPE: %s",
overlayable_iter.GetLastError().c_str());
if (overlayable_iter.HadFatalError()) {
return {};