From 4670805ea441edb8b280f9312571e7799f1284cf Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Fri, 29 Sep 2017 14:49:15 -0700 Subject: [PATCH] AAPT2: Move format related files under same directory Test: make aapt2_tests Change-Id: Id72cdfc12ba3add294048e60c55f2461344464bf --- tools/aapt2/Android.bp | 14 +- tools/aapt2/LoadedApk.cpp | 6 +- tools/aapt2/LoadedApk.h | 34 ++-- tools/aapt2/ResourceUtils.cpp | 6 +- tools/aapt2/cmd/Compile.cpp | 6 +- tools/aapt2/cmd/Dump.cpp | 4 +- tools/aapt2/cmd/Link.cpp | 12 +- tools/aapt2/cmd/Optimize.cpp | 4 +- tools/aapt2/compile/PngChunkFilter.cpp | 4 +- tools/aapt2/{flatten => format}/Archive.cpp | 18 +- tools/aapt2/{flatten => format}/Archive.h | 6 +- .../binary}/BinaryResourceParser.cpp | 166 ++++++++---------- .../binary}/BinaryResourceParser.h | 51 ++---- .../{flatten => format/binary}/ChunkWriter.h | 21 ++- .../binary}/ResChunkPullParser.cpp | 7 +- .../binary}/ResChunkPullParser.h | 55 +++--- .../binary}/ResourceTypeExtensions.h | 12 +- .../binary}/TableFlattener.cpp | 46 +++-- .../binary}/TableFlattener.h | 9 +- .../binary}/TableFlattener_test.cpp | 112 +++++------- .../binary}/XmlFlattener.cpp | 26 ++- .../{flatten => format/binary}/XmlFlattener.h | 13 +- .../binary}/XmlFlattener_test.cpp | 5 +- .../{ => format}/proto/ProtoDeserialize.cpp | 10 +- .../{ => format}/proto/ProtoDeserialize.h | 6 +- .../{ => format}/proto/ProtoSerialize.cpp | 2 +- .../aapt2/{ => format}/proto/ProtoSerialize.h | 6 +- .../proto/ProtoSerialize_test.cpp | 4 +- tools/aapt2/io/Util.h | 2 +- tools/aapt2/optimize/MultiApkGenerator.cpp | 4 +- .../aapt2/optimize/MultiApkGenerator_test.cpp | 4 +- tools/aapt2/xml/XmlDom_test.cpp | 2 +- 32 files changed, 310 insertions(+), 367 deletions(-) rename tools/aapt2/{flatten => format}/Archive.cpp (95%) rename tools/aapt2/{flatten => format}/Archive.h (96%) rename tools/aapt2/{unflatten => format/binary}/BinaryResourceParser.cpp (76%) rename tools/aapt2/{unflatten => format/binary}/BinaryResourceParser.h (73%) rename tools/aapt2/{flatten => format/binary}/ChunkWriter.h (85%) rename tools/aapt2/{unflatten => format/binary}/ResChunkPullParser.cpp (92%) rename tools/aapt2/{unflatten => format/binary}/ResChunkPullParser.h (64%) rename tools/aapt2/{flatten => format/binary}/ResourceTypeExtensions.h (75%) rename tools/aapt2/{flatten => format/binary}/TableFlattener.cpp (93%) rename tools/aapt2/{flatten => format/binary}/TableFlattener.h (89%) rename tools/aapt2/{flatten => format/binary}/TableFlattener_test.cpp (83%) rename tools/aapt2/{flatten => format/binary}/XmlFlattener.cpp (94%) rename tools/aapt2/{flatten => format/binary}/XmlFlattener.h (83%) rename tools/aapt2/{flatten => format/binary}/XmlFlattener_test.cpp (98%) rename tools/aapt2/{ => format}/proto/ProtoDeserialize.cpp (98%) rename tools/aapt2/{ => format}/proto/ProtoDeserialize.h (95%) rename tools/aapt2/{ => format}/proto/ProtoSerialize.cpp (99%) rename tools/aapt2/{ => format}/proto/ProtoSerialize.h (95%) rename tools/aapt2/{ => format}/proto/ProtoSerialize_test.cpp (99%) diff --git a/tools/aapt2/Android.bp b/tools/aapt2/Android.bp index 7a8a4eea1aa60..ff51d5146eb8e 100644 --- a/tools/aapt2/Android.bp +++ b/tools/aapt2/Android.bp @@ -83,9 +83,13 @@ cc_library_host_static { "configuration/ConfigurationParser.cpp", "filter/AbiFilter.cpp", "filter/ConfigFilter.cpp", - "flatten/Archive.cpp", - "flatten/TableFlattener.cpp", - "flatten/XmlFlattener.cpp", + "format/Archive.cpp", + "format/binary/BinaryResourceParser.cpp", + "format/binary/ResChunkPullParser.cpp", + "format/binary/TableFlattener.cpp", + "format/binary/XmlFlattener.cpp", + "format/proto/ProtoDeserialize.cpp", + "format/proto/ProtoSerialize.cpp", "io/BigBufferStreams.cpp", "io/File.cpp", "io/FileInputStream.cpp", @@ -106,13 +110,9 @@ cc_library_host_static { "optimize/ResourceDeduper.cpp", "optimize/VersionCollapser.cpp", "process/SymbolTable.cpp", - "proto/ProtoDeserialize.cpp", - "proto/ProtoSerialize.cpp", "split/TableSplitter.cpp", "text/Unicode.cpp", "text/Utf8Iterator.cpp", - "unflatten/BinaryResourceParser.cpp", - "unflatten/ResChunkPullParser.cpp", "util/BigBuffer.cpp", "util/Files.cpp", "util/Util.cpp", diff --git a/tools/aapt2/LoadedApk.cpp b/tools/aapt2/LoadedApk.cpp index 6f2b86528b5b9..c1815c82b5b5c 100644 --- a/tools/aapt2/LoadedApk.cpp +++ b/tools/aapt2/LoadedApk.cpp @@ -18,9 +18,9 @@ #include "ResourceValues.h" #include "ValueVisitor.h" -#include "flatten/Archive.h" -#include "flatten/TableFlattener.h" -#include "flatten/XmlFlattener.h" +#include "format/Archive.h" +#include "format/binary/TableFlattener.h" +#include "format/binary/XmlFlattener.h" #include "io/BigBufferInputStream.h" #include "io/Util.h" #include "xml/XmlDom.h" diff --git a/tools/aapt2/LoadedApk.h b/tools/aapt2/LoadedApk.h index d779b7e7663f5..d2dd5cf2bc678 100644 --- a/tools/aapt2/LoadedApk.h +++ b/tools/aapt2/LoadedApk.h @@ -21,27 +21,35 @@ #include "ResourceTable.h" #include "filter/Filter.h" -#include "flatten/Archive.h" -#include "flatten/TableFlattener.h" +#include "format/Archive.h" +#include "format/binary/BinaryResourceParser.h" +#include "format/binary/TableFlattener.h" #include "io/ZipArchive.h" -#include "unflatten/BinaryResourceParser.h" #include "xml/XmlDom.h" namespace aapt { -/** Info about an APK loaded in memory. */ +// Info about an APK loaded in memory. class LoadedApk { public: - LoadedApk(const Source& source, std::unique_ptr apk, - std::unique_ptr table) - : source_(source), apk_(std::move(apk)), table_(std::move(table)) { + LoadedApk( + const Source& source, + std::unique_ptr apk, + std::unique_ptr table) + : source_(source), apk_(std::move(apk)), table_(std::move(table)) {} + virtual ~LoadedApk() = default; + + io::IFileCollection* GetFileCollection() { + return apk_.get(); } - io::IFileCollection* GetFileCollection() { return apk_.get(); } + ResourceTable* GetResourceTable() { + return table_.get(); + } - ResourceTable* GetResourceTable() { return table_.get(); } - - const Source& GetSource() { return source_; } + const Source& GetSource() { + return source_; + } /** * Writes the APK on disk at the given path, while also removing the resource @@ -70,11 +78,11 @@ class LoadedApk { const android::StringPiece& path); private: + DISALLOW_COPY_AND_ASSIGN(LoadedApk); + Source source_; std::unique_ptr apk_; std::unique_ptr table_; - - DISALLOW_COPY_AND_ASSIGN(LoadedApk); }; } // namespace aapt diff --git a/tools/aapt2/ResourceUtils.cpp b/tools/aapt2/ResourceUtils.cpp index f193fe0c65933..6fac6e9dfefee 100644 --- a/tools/aapt2/ResourceUtils.cpp +++ b/tools/aapt2/ResourceUtils.cpp @@ -23,12 +23,12 @@ #include "NameMangler.h" #include "SdkConstants.h" -#include "flatten/ResourceTypeExtensions.h" +#include "format/binary/ResourceTypeExtensions.h" #include "util/Files.h" #include "util/Util.h" -using android::StringPiece; -using android::StringPiece16; +using ::android::StringPiece; +using ::android::StringPiece16; namespace aapt { namespace ResourceUtils { diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp index 0690dc1b8ec66..a5e6aefd1e0f6 100644 --- a/tools/aapt2/cmd/Compile.cpp +++ b/tools/aapt2/cmd/Compile.cpp @@ -35,12 +35,12 @@ #include "compile/Png.h" #include "compile/PseudolocaleGenerator.h" #include "compile/XmlIdCollector.h" -#include "flatten/Archive.h" -#include "flatten/XmlFlattener.h" +#include "format/Archive.h" +#include "format/binary/XmlFlattener.h" +#include "format/proto/ProtoSerialize.h" #include "io/BigBufferOutputStream.h" #include "io/FileInputStream.h" #include "io/Util.h" -#include "proto/ProtoSerialize.h" #include "util/Files.h" #include "util/Maybe.h" #include "util/Util.h" diff --git a/tools/aapt2/cmd/Dump.cpp b/tools/aapt2/cmd/Dump.cpp index 0dedc91d2d2e0..44032f6a730db 100644 --- a/tools/aapt2/cmd/Dump.cpp +++ b/tools/aapt2/cmd/Dump.cpp @@ -21,10 +21,10 @@ #include "Debug.h" #include "Diagnostics.h" #include "Flags.h" +#include "format/binary/BinaryResourceParser.h" +#include "format/proto/ProtoDeserialize.h" #include "io/ZipArchive.h" #include "process/IResourceTableConsumer.h" -#include "proto/ProtoDeserialize.h" -#include "unflatten/BinaryResourceParser.h" #include "util/Files.h" using ::android::StringPiece; diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp index f72069cc967a9..88e0f699fd580 100644 --- a/tools/aapt2/cmd/Link.cpp +++ b/tools/aapt2/cmd/Link.cpp @@ -38,9 +38,12 @@ #include "cmd/Util.h" #include "compile/IdAssigner.h" #include "filter/ConfigFilter.h" -#include "flatten/Archive.h" -#include "flatten/TableFlattener.h" -#include "flatten/XmlFlattener.h" +#include "format/Archive.h" +#include "format/binary/BinaryResourceParser.h" +#include "format/binary/TableFlattener.h" +#include "format/binary/XmlFlattener.h" +#include "format/proto/ProtoDeserialize.h" +#include "format/proto/ProtoSerialize.h" #include "io/BigBufferInputStream.h" #include "io/FileInputStream.h" #include "io/FileSystem.h" @@ -58,10 +61,7 @@ #include "optimize/VersionCollapser.h" #include "process/IResourceTableConsumer.h" #include "process/SymbolTable.h" -#include "proto/ProtoDeserialize.h" -#include "proto/ProtoSerialize.h" #include "split/TableSplitter.h" -#include "unflatten/BinaryResourceParser.h" #include "util/Files.h" #include "xml/XmlDom.h" diff --git a/tools/aapt2/cmd/Optimize.cpp b/tools/aapt2/cmd/Optimize.cpp index 56b61d04ff9eb..67ac67a9367e8 100644 --- a/tools/aapt2/cmd/Optimize.cpp +++ b/tools/aapt2/cmd/Optimize.cpp @@ -31,8 +31,8 @@ #include "cmd/Util.h" #include "configuration/ConfigurationParser.h" #include "filter/AbiFilter.h" -#include "flatten/TableFlattener.h" -#include "flatten/XmlFlattener.h" +#include "format/binary/TableFlattener.h" +#include "format/binary/XmlFlattener.h" #include "io/BigBufferInputStream.h" #include "io/Util.h" #include "optimize/MultiApkGenerator.h" diff --git a/tools/aapt2/compile/PngChunkFilter.cpp b/tools/aapt2/compile/PngChunkFilter.cpp index 5af91fdc71b9c..bc2e6990433c1 100644 --- a/tools/aapt2/compile/PngChunkFilter.cpp +++ b/tools/aapt2/compile/PngChunkFilter.cpp @@ -21,8 +21,8 @@ #include "io/Io.h" -using android::StringPiece; -using android::base::StringPrintf; +using ::android::StringPiece; +using ::android::base::StringPrintf; namespace aapt { diff --git a/tools/aapt2/flatten/Archive.cpp b/tools/aapt2/format/Archive.cpp similarity index 95% rename from tools/aapt2/flatten/Archive.cpp rename to tools/aapt2/format/Archive.cpp index 5f8bd063f9b09..d152a9cc7e62c 100644 --- a/tools/aapt2/flatten/Archive.cpp +++ b/tools/aapt2/format/Archive.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "flatten/Archive.h" +#include "format/Archive.h" #include #include @@ -106,9 +106,13 @@ class DirectoryWriter : public IArchiveWriter { return !in->HadError(); } - bool HadError() const override { return !error_.empty(); } + bool HadError() const override { + return !error_.empty(); + } - std::string GetError() const override { return error_; } + std::string GetError() const override { + return error_; + } private: DISALLOW_COPY_AND_ASSIGN(DirectoryWriter); @@ -221,9 +225,13 @@ class ZipFileWriter : public IArchiveWriter { } } - bool HadError() const override { return !error_.empty(); } + bool HadError() const override { + return !error_.empty(); + } - std::string GetError() const override { return error_; } + std::string GetError() const override { + return error_; + } virtual ~ZipFileWriter() { if (writer_) { diff --git a/tools/aapt2/flatten/Archive.h b/tools/aapt2/format/Archive.h similarity index 96% rename from tools/aapt2/flatten/Archive.h rename to tools/aapt2/format/Archive.h index 4ee4ce71a5c51..4e8a39df91651 100644 --- a/tools/aapt2/flatten/Archive.h +++ b/tools/aapt2/format/Archive.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef AAPT_FLATTEN_ARCHIVE_H -#define AAPT_FLATTEN_ARCHIVE_H +#ifndef AAPT_FORMAT_ARCHIVE_H +#define AAPT_FORMAT_ARCHIVE_H #include #include @@ -78,4 +78,4 @@ std::unique_ptr CreateZipFileArchiveWriter(IDiagnostics* diag, } // namespace aapt -#endif /* AAPT_FLATTEN_ARCHIVE_H */ +#endif /* AAPT_FORMAT_ARCHIVE_H */ diff --git a/tools/aapt2/unflatten/BinaryResourceParser.cpp b/tools/aapt2/format/binary/BinaryResourceParser.cpp similarity index 76% rename from tools/aapt2/unflatten/BinaryResourceParser.cpp rename to tools/aapt2/format/binary/BinaryResourceParser.cpp index b87278b5ce2fa..95eec4ae8248a 100644 --- a/tools/aapt2/unflatten/BinaryResourceParser.cpp +++ b/tools/aapt2/format/binary/BinaryResourceParser.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "unflatten/BinaryResourceParser.h" +#include "format/binary/BinaryResourceParser.h" #include #include @@ -31,15 +31,15 @@ #include "ResourceValues.h" #include "Source.h" #include "ValueVisitor.h" -#include "unflatten/ResChunkPullParser.h" +#include "format/binary/ResChunkPullParser.h" #include "util/Util.h" -namespace aapt { - using namespace android; using ::android::base::StringPrintf; +namespace aapt { + namespace { // Visitor that converts a reference's resource ID to a resource name, given a mapping from @@ -118,15 +118,11 @@ bool BinaryResourceParser::Parse() { return true; } -/** - * Parses the resource table, which contains all the packages, types, and - * entries. - */ +// Parses the resource table, which contains all the packages, types, and entries. bool BinaryResourceParser::ParseTable(const ResChunk_header* chunk) { const ResTable_header* table_header = ConvertTo(chunk); if (!table_header) { - context_->GetDiagnostics()->Error(DiagMessage(source_) - << "corrupt ResTable_header chunk"); + context_->GetDiagnostics()->Error(DiagMessage(source_) << "corrupt ResTable_header chunk"); return false; } @@ -136,21 +132,20 @@ bool BinaryResourceParser::ParseTable(const ResChunk_header* chunk) { switch (util::DeviceToHost16(parser.chunk()->type)) { case android::RES_STRING_POOL_TYPE: if (value_pool_.getError() == NO_INIT) { - status_t err = value_pool_.setTo( - parser.chunk(), util::DeviceToHost32(parser.chunk()->size)); + status_t err = + value_pool_.setTo(parser.chunk(), util::DeviceToHost32(parser.chunk()->size)); if (err != NO_ERROR) { - context_->GetDiagnostics()->Error( - DiagMessage(source_) << "corrupt string pool in ResTable: " - << value_pool_.getError()); + context_->GetDiagnostics()->Error(DiagMessage(source_) + << "corrupt string pool in ResTable: " + << value_pool_.getError()); return false; } // Reserve some space for the strings we are going to add. - table_->string_pool.HintWillAdd(value_pool_.size(), - value_pool_.styleCount()); + table_->string_pool.HintWillAdd(value_pool_.size(), value_pool_.styleCount()); } else { - context_->GetDiagnostics()->Warn( - DiagMessage(source_) << "unexpected string pool in ResTable"); + context_->GetDiagnostics()->Warn(DiagMessage(source_) + << "unexpected string pool in ResTable"); } break; @@ -169,8 +164,8 @@ bool BinaryResourceParser::ParseTable(const ResChunk_header* chunk) { } if (parser.event() == ResChunkPullParser::Event::kBadDocument) { - context_->GetDiagnostics()->Error( - DiagMessage(source_) << "corrupt resource table: " << parser.error()); + context_->GetDiagnostics()->Error(DiagMessage(source_) + << "corrupt resource table: " << parser.error()); return false; } return true; @@ -187,26 +182,25 @@ bool BinaryResourceParser::ParsePackage(const ResChunk_header* chunk) { uint32_t package_id = util::DeviceToHost32(package_header->id); if (package_id > std::numeric_limits::max()) { - context_->GetDiagnostics()->Error( - DiagMessage(source_) << "package ID is too big (" << package_id << ")"); + context_->GetDiagnostics()->Error(DiagMessage(source_) + << "package ID is too big (" << package_id << ")"); return false; } // Extract the package name. - size_t len = strnlen16((const char16_t*)package_header->name, - arraysize(package_header->name)); + size_t len = strnlen16((const char16_t*)package_header->name, arraysize(package_header->name)); std::u16string package_name; package_name.resize(len); for (size_t i = 0; i < len; i++) { package_name[i] = util::DeviceToHost16(package_header->name[i]); } - ResourceTablePackage* package = table_->CreatePackage( - util::Utf16ToUtf8(package_name), static_cast(package_id)); + ResourceTablePackage* package = + table_->CreatePackage(util::Utf16ToUtf8(package_name), static_cast(package_id)); if (!package) { - context_->GetDiagnostics()->Error( - DiagMessage(source_) << "incompatible package '" << package_name - << "' with ID " << package_id); + context_->GetDiagnostics()->Error(DiagMessage(source_) + << "incompatible package '" << package_name << "' with ID " + << package_id); return false; } @@ -221,23 +215,21 @@ bool BinaryResourceParser::ParsePackage(const ResChunk_header* chunk) { switch (util::DeviceToHost16(parser.chunk()->type)) { case android::RES_STRING_POOL_TYPE: if (type_pool_.getError() == NO_INIT) { - status_t err = type_pool_.setTo( - parser.chunk(), util::DeviceToHost32(parser.chunk()->size)); + status_t err = + type_pool_.setTo(parser.chunk(), util::DeviceToHost32(parser.chunk()->size)); if (err != NO_ERROR) { context_->GetDiagnostics()->Error(DiagMessage(source_) << "corrupt type string pool in " - << "ResTable_package: " - << type_pool_.getError()); + << "ResTable_package: " << type_pool_.getError()); return false; } } else if (key_pool_.getError() == NO_INIT) { - status_t err = key_pool_.setTo( - parser.chunk(), util::DeviceToHost32(parser.chunk()->size)); + status_t err = + key_pool_.setTo(parser.chunk(), util::DeviceToHost32(parser.chunk()->size)); if (err != NO_ERROR) { context_->GetDiagnostics()->Error(DiagMessage(source_) << "corrupt key string pool in " - << "ResTable_package: " - << key_pool_.getError()); + << "ResTable_package: " << key_pool_.getError()); return false; } } else { @@ -272,8 +264,8 @@ bool BinaryResourceParser::ParsePackage(const ResChunk_header* chunk) { } if (parser.event() == ResChunkPullParser::Event::kBadDocument) { - context_->GetDiagnostics()->Error( - DiagMessage(source_) << "corrupt ResTable_package: " << parser.error()); + context_->GetDiagnostics()->Error(DiagMessage(source_) + << "corrupt ResTable_package: " << parser.error()); return false; } @@ -286,22 +278,19 @@ bool BinaryResourceParser::ParsePackage(const ResChunk_header* chunk) { bool BinaryResourceParser::ParseTypeSpec(const ResChunk_header* chunk) { if (type_pool_.getError() != NO_ERROR) { - context_->GetDiagnostics()->Error(DiagMessage(source_) - << "missing type string pool"); + context_->GetDiagnostics()->Error(DiagMessage(source_) << "missing type string pool"); return false; } const ResTable_typeSpec* type_spec = ConvertTo(chunk); if (!type_spec) { - context_->GetDiagnostics()->Error(DiagMessage(source_) - << "corrupt ResTable_typeSpec chunk"); + context_->GetDiagnostics()->Error(DiagMessage(source_) << "corrupt ResTable_typeSpec chunk"); return false; } if (type_spec->id == 0) { context_->GetDiagnostics()->Error(DiagMessage(source_) - << "ResTable_typeSpec has invalid id: " - << type_spec->id); + << "ResTable_typeSpec has invalid id: " << type_spec->id); return false; } return true; @@ -310,14 +299,12 @@ bool BinaryResourceParser::ParseTypeSpec(const ResChunk_header* chunk) { bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, const ResChunk_header* chunk) { if (type_pool_.getError() != NO_ERROR) { - context_->GetDiagnostics()->Error(DiagMessage(source_) - << "missing type string pool"); + context_->GetDiagnostics()->Error(DiagMessage(source_) << "missing type string pool"); return false; } if (key_pool_.getError() != NO_ERROR) { - context_->GetDiagnostics()->Error(DiagMessage(source_) - << "missing key string pool"); + context_->GetDiagnostics()->Error(DiagMessage(source_) << "missing key string pool"); return false; } @@ -325,15 +312,13 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, // a lot and has its own code to handle variable size. const ResTable_type* type = ConvertTo(chunk); if (!type) { - context_->GetDiagnostics()->Error(DiagMessage(source_) - << "corrupt ResTable_type chunk"); + context_->GetDiagnostics()->Error(DiagMessage(source_) << "corrupt ResTable_type chunk"); return false; } if (type->id == 0) { context_->GetDiagnostics()->Error(DiagMessage(source_) - << "ResTable_type has invalid id: " - << (int)type->id); + << "ResTable_type has invalid id: " << (int)type->id); return false; } @@ -344,9 +329,9 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, const ResourceType* parsed_type = ParseResourceType(type_str); if (!parsed_type) { - context_->GetDiagnostics()->Error( - DiagMessage(source_) << "invalid type name '" << type_str - << "' for type with ID " << (int)type->id); + context_->GetDiagnostics()->Error(DiagMessage(source_) + << "invalid type name '" << type_str << "' for type with ID " + << (int)type->id); return false; } @@ -357,12 +342,10 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, continue; } - const ResourceName name( - package->name, *parsed_type, - util::GetString(key_pool_, util::DeviceToHost32(entry->key.index))); + const ResourceName name(package->name, *parsed_type, + util::GetString(key_pool_, util::DeviceToHost32(entry->key.index))); - const ResourceId res_id(package->id.value(), type->id, - static_cast(it.index())); + const ResourceId res_id(package->id.value(), type->id, static_cast(it.index())); std::unique_ptr resource_value; if (entry->flags & ResTable_entry::FLAG_COMPLEX) { @@ -377,10 +360,9 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package, } if (!resource_value) { - context_->GetDiagnostics()->Error( - DiagMessage(source_) << "failed to parse value for resource " << name - << " (" << res_id << ") with configuration '" - << config << "'"); + context_->GetDiagnostics()->Error(DiagMessage(source_) + << "failed to parse value for resource " << name << " (" + << res_id << ") with configuration '" << config << "'"); return false; } @@ -433,19 +415,19 @@ std::unique_ptr BinaryResourceParser::ParseValue(const ResourceNameRef& na if (file_ref != nullptr) { file_ref->file = files_->FindFile(*file_ref->path); if (file_ref->file == nullptr) { - context_->GetDiagnostics()->Warn(DiagMessage() << "resource " << name << " for config '" - << config << "' is a file reference to '" - << *file_ref->path - << "' but no such path exists"); + context_->GetDiagnostics()->Warn(DiagMessage() + << "resource " << name << " for config '" << config + << "' is a file reference to '" << *file_ref->path + << "' but no such path exists"); } } } return item; } -std::unique_ptr BinaryResourceParser::ParseMapEntry( - const ResourceNameRef& name, const ConfigDescription& config, - const ResTable_map_entry* map) { +std::unique_ptr BinaryResourceParser::ParseMapEntry(const ResourceNameRef& name, + const ConfigDescription& config, + const ResTable_map_entry* map) { switch (name.type) { case ResourceType::kStyle: return ParseStyle(name, config, map); @@ -470,9 +452,9 @@ std::unique_ptr BinaryResourceParser::ParseMapEntry( return {}; } -std::unique_ptr