summaryrefslogtreecommitdiff
path: root/tools/aapt2/LoadedApk.cpp
diff options
context:
space:
mode:
authorShane Farmer <safarmer@google.com>2017-06-22 12:24:12 -0700
committerShane Farmer <safarmer@google.com>2017-08-16 19:19:54 +0000
commit0a5b201156f1dd01a7da7b7674798ed57cfafc5a (patch)
treec2682b213bb6f5c3bc390631dbc7e71ea6f527e2 /tools/aapt2/LoadedApk.cpp
parent8dbbdf0c370c56426ffde06ccdbe55d2ffb9fb8d (diff)
AAPT2: Add a APK filtering.
Allow resource files to be removed from the final artifact based on the density and locale configuration in the config file. The APK is split along the density, locale and ABI axis. Each split is generated from the original APK without modifying the original. The new resource table is written back to the file system with unneeded assets etc removed. Test: Unit tests Test: Manually run optimize command against an APK and inspect results Test: Installed split searchlite APK (after resigning) and ran on N6 Change-Id: If73597dcfd88c02d2616518585d0e25a5c6a84d1
Diffstat (limited to 'tools/aapt2/LoadedApk.cpp')
-rw-r--r--tools/aapt2/LoadedApk.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/aapt2/LoadedApk.cpp b/tools/aapt2/LoadedApk.cpp
index abc0e4c1b89d..b80780e33dfa 100644
--- a/tools/aapt2/LoadedApk.cpp
+++ b/tools/aapt2/LoadedApk.cpp
@@ -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) {
@@ -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;
}