Loading tools/aapt2/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ cc_library_host_static { "link/XmlCompatVersioner.cpp", "link/XmlNamespaceRemover.cpp", "link/XmlReferenceLinker.cpp", "optimize/MultiApkGenerator.cpp", "optimize/ResourceDeduper.cpp", "optimize/VersionCollapser.cpp", "process/SymbolTable.cpp", Loading tools/aapt2/LoadedApk.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -58,14 +58,15 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadApkFromPath(IAaptContext* context, bool LoadedApk::WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, IArchiveWriter* writer) { FilterChain empty; return WriteToArchive(context, options, &empty, writer); return WriteToArchive(context, table_.get(), options, &empty, writer); } bool LoadedApk::WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer) { bool LoadedApk::WriteToArchive(IAaptContext* context, ResourceTable* split_table, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer) { std::set<std::string> referenced_resources; // List the files being referenced in the resource table. for (auto& pkg : table_->packages) { for (auto& pkg : split_table->packages) { for (auto& type : pkg->types) { for (auto& entry : type->entries) { for (auto& config_value : entry->values) { Loading Loading @@ -108,7 +109,7 @@ bool LoadedApk::WriteToArchive(IAaptContext* context, const TableFlattenerOption // TODO(adamlesinski): How to determine if there were sparse entries (and if to encode // with sparse entries) b/35389232. TableFlattener flattener(options, &buffer); if (!flattener.Consume(context, table_.get())) { if (!flattener.Consume(context, split_table)) { return false; } Loading tools/aapt2/LoadedApk.h +5 −4 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ class LoadedApk { * Writes the APK on disk at the given path, while also removing the resource * files that are not referenced in the resource table. */ bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, virtual bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, IArchiveWriter* writer); /** Loading @@ -55,8 +55,9 @@ class LoadedApk { * files that are not referenced in the resource table. The provided filter * chain is applied to each entry in the APK file. */ bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer); virtual bool WriteToArchive(IAaptContext* context, ResourceTable* split_table, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer); static std::unique_ptr<LoadedApk> LoadApkFromPath(IAaptContext* context, const android::StringPiece& path); Loading tools/aapt2/ResourceTable.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -546,4 +546,34 @@ Maybe<ResourceTable::SearchResult> ResourceTable::FindResource(const ResourceNam return SearchResult{package, type, entry}; } std::unique_ptr<ResourceTable> ResourceTable::Clone() const { std::unique_ptr<ResourceTable> new_table = util::make_unique<ResourceTable>(); for (const auto& pkg : packages) { ResourceTablePackage* new_pkg = new_table->CreatePackage(pkg->name, pkg->id); for (const auto& type : pkg->types) { ResourceTableType* new_type = new_pkg->FindOrCreateType(type->type); if (!new_type->id) { new_type->id = type->id; new_type->symbol_status = type->symbol_status; } for (const auto& entry : type->entries) { ResourceEntry* new_entry = new_type->FindOrCreateEntry(entry->name); if (!new_entry->id) { new_entry->id = entry->id; new_entry->symbol_status = entry->symbol_status; } for (const auto& config_value : entry->values) { ResourceConfigValue* new_value = new_entry->FindOrCreateValue(config_value->config, config_value->product); Value* value = config_value->value->Clone(&new_table->string_pool); new_value->value = std::unique_ptr<Value>(value); } } } } return new_table; } } // namespace aapt tools/aapt2/ResourceTable.h +2 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,8 @@ class ResourceTable { ResourceTablePackage* CreatePackage(const android::StringPiece& name, Maybe<uint8_t> id = {}); std::unique_ptr<ResourceTable> Clone() const; /** * The string pool used by this resource table. Values that reference strings * must use Loading Loading
tools/aapt2/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ cc_library_host_static { "link/XmlCompatVersioner.cpp", "link/XmlNamespaceRemover.cpp", "link/XmlReferenceLinker.cpp", "optimize/MultiApkGenerator.cpp", "optimize/ResourceDeduper.cpp", "optimize/VersionCollapser.cpp", "process/SymbolTable.cpp", Loading
tools/aapt2/LoadedApk.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -58,14 +58,15 @@ std::unique_ptr<LoadedApk> LoadedApk::LoadApkFromPath(IAaptContext* context, bool LoadedApk::WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, IArchiveWriter* writer) { FilterChain empty; return WriteToArchive(context, options, &empty, writer); return WriteToArchive(context, table_.get(), options, &empty, writer); } bool LoadedApk::WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer) { bool LoadedApk::WriteToArchive(IAaptContext* context, ResourceTable* split_table, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer) { std::set<std::string> referenced_resources; // List the files being referenced in the resource table. for (auto& pkg : table_->packages) { for (auto& pkg : split_table->packages) { for (auto& type : pkg->types) { for (auto& entry : type->entries) { for (auto& config_value : entry->values) { Loading Loading @@ -108,7 +109,7 @@ bool LoadedApk::WriteToArchive(IAaptContext* context, const TableFlattenerOption // TODO(adamlesinski): How to determine if there were sparse entries (and if to encode // with sparse entries) b/35389232. TableFlattener flattener(options, &buffer); if (!flattener.Consume(context, table_.get())) { if (!flattener.Consume(context, split_table)) { return false; } Loading
tools/aapt2/LoadedApk.h +5 −4 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ class LoadedApk { * Writes the APK on disk at the given path, while also removing the resource * files that are not referenced in the resource table. */ bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, virtual bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, IArchiveWriter* writer); /** Loading @@ -55,8 +55,9 @@ class LoadedApk { * files that are not referenced in the resource table. The provided filter * chain is applied to each entry in the APK file. */ bool WriteToArchive(IAaptContext* context, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer); virtual bool WriteToArchive(IAaptContext* context, ResourceTable* split_table, const TableFlattenerOptions& options, FilterChain* filters, IArchiveWriter* writer); static std::unique_ptr<LoadedApk> LoadApkFromPath(IAaptContext* context, const android::StringPiece& path); Loading
tools/aapt2/ResourceTable.cpp +30 −0 Original line number Diff line number Diff line Loading @@ -546,4 +546,34 @@ Maybe<ResourceTable::SearchResult> ResourceTable::FindResource(const ResourceNam return SearchResult{package, type, entry}; } std::unique_ptr<ResourceTable> ResourceTable::Clone() const { std::unique_ptr<ResourceTable> new_table = util::make_unique<ResourceTable>(); for (const auto& pkg : packages) { ResourceTablePackage* new_pkg = new_table->CreatePackage(pkg->name, pkg->id); for (const auto& type : pkg->types) { ResourceTableType* new_type = new_pkg->FindOrCreateType(type->type); if (!new_type->id) { new_type->id = type->id; new_type->symbol_status = type->symbol_status; } for (const auto& entry : type->entries) { ResourceEntry* new_entry = new_type->FindOrCreateEntry(entry->name); if (!new_entry->id) { new_entry->id = entry->id; new_entry->symbol_status = entry->symbol_status; } for (const auto& config_value : entry->values) { ResourceConfigValue* new_value = new_entry->FindOrCreateValue(config_value->config, config_value->product); Value* value = config_value->value->Clone(&new_table->string_pool); new_value->value = std::unique_ptr<Value>(value); } } } } return new_table; } } // namespace aapt
tools/aapt2/ResourceTable.h +2 −0 Original line number Diff line number Diff line Loading @@ -251,6 +251,8 @@ class ResourceTable { ResourceTablePackage* CreatePackage(const android::StringPiece& name, Maybe<uint8_t> id = {}); std::unique_ptr<ResourceTable> Clone() const; /** * The string pool used by this resource table. Values that reference strings * must use Loading