Add --enable-compact-entries to aapt2 convert
Currently, when we run the resource shrinker we will do:
- Convert apk from binary to proto
- Do resource shrinking
- Convert shrunken proto format apk back to binary
The original apk is linked with --enable-compact-entries (which we generally set on platform)
but the flag is not available when converting, so the last conversion step will not use the compact mode
Bug: 294016857
Test: tableflattener tests already cover these, this is just a flag passed
Change-Id: If5f1336c5eb3736bc40db89cdefe6f1a9aa189dd
diff --git a/tools/aapt2/cmd/Convert.h b/tools/aapt2/cmd/Convert.h
index 15fe11f..9452e58 100644
--- a/tools/aapt2/cmd/Convert.h
+++ b/tools/aapt2/cmd/Convert.h
@@ -46,6 +46,10 @@
"This decreases APK size at the cost of resource retrieval performance.\n"
"Applies sparse encoding to all resources regardless of minSdk.",
&force_sparse_encoding_);
+ AddOptionalSwitch(
+ "--enable-compact-entries",
+ "This decreases APK size by using compact resource entries for simple data types.",
+ &enable_compact_entries_);
AddOptionalSwitch("--keep-raw-values",
android::base::StringPrintf("Preserve raw attribute values in xml files when using the"
" '%s' output format", kOutputFormatBinary),
@@ -85,6 +89,7 @@
bool verbose_ = false;
bool enable_sparse_encoding_ = false;
bool force_sparse_encoding_ = false;
+ bool enable_compact_entries_ = false;
std::optional<std::string> resources_config_path_;
};