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/optimize/MultiApkGenerator.h b/tools/aapt2/optimize/MultiApkGenerator.h
index f325d83..b064400 100644
--- a/tools/aapt2/optimize/MultiApkGenerator.h
+++ b/tools/aapt2/optimize/MultiApkGenerator.h
@@ -23,6 +23,12 @@
namespace aapt {
+struct MultiApkGeneratorOptions {
+ std::string out_dir;
+ configuration::PostProcessingConfiguration config;
+ TableFlattenerOptions table_flattener_options;
+};
+
/**
* Generates a set of APKs that are a subset of the original base APKs. Each of the new APKs contain
* only the resources and assets for an artifact in the configuration file.
@@ -35,9 +41,13 @@
* Writes a set of APKs to the provided output directory. Each APK is a subset fo the base APK and
* represents an artifact in the post processing configuration.
*/
- bool FromBaseApk(const std::string& out_dir,
- const configuration::PostProcessingConfiguration& config,
- const TableFlattenerOptions& table_flattener_options);
+ bool FromBaseApk(const MultiApkGeneratorOptions& options);
+
+ protected:
+ virtual std::unique_ptr<ResourceTable> FilterTable(
+ const configuration::Artifact& artifact,
+ const configuration::PostProcessingConfiguration& config, const ResourceTable& old_table,
+ FilterChain* chain);
private:
IDiagnostics* GetDiagnostics() {