AAPT2: Multi APK generator by version
- Added an additional axis for generating a multi-apk split by minimum
Android SDK version. This removes any resources that will not be used
for the desired minimum SDK version. If there are multiple resources
that would be valid for any version newer than the requested minimum,
then all would be kept so that the best match can be found.
- Added a context wrapper to set the appropriate Android SDK version for
each generated artifact.
- Split out the FilterTable method to allow it to be directly tested
without the need to mock the APK writing steps.
Test: Unit tests
Test: manually run optimize command
Change-Id: I7e6018df081af9ed5d9e8aaf40ed216c1275f138
diff --git a/tools/aapt2/cmd/Optimize.cpp b/tools/aapt2/cmd/Optimize.cpp
index 887803e..33a1d3a 100644
--- a/tools/aapt2/cmd/Optimize.cpp
+++ b/tools/aapt2/cmd/Optimize.cpp
@@ -194,8 +194,10 @@
if (options_.configuration && options_.output_dir) {
MultiApkGenerator generator{apk.get(), context_};
- if (!generator.FromBaseApk(options_.output_dir.value(), options_.configuration.value(),
- options_.table_flattener_options)) {
+ MultiApkGeneratorOptions generator_options = {options_.output_dir.value(),
+ options_.configuration.value(),
+ options_.table_flattener_options};
+ if (!generator.FromBaseApk(generator_options)) {
return 1;
}
}