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/configuration/ConfigurationParser.h b/tools/aapt2/configuration/ConfigurationParser.h
index a58685e..9bc9081 100644
--- a/tools/aapt2/configuration/ConfigurationParser.h
+++ b/tools/aapt2/configuration/ConfigurationParser.h
@@ -33,6 +33,10 @@
template<class T>
using Group = std::unordered_map<std::string, std::vector<T>>;
+/** A mapping of group label to a single configuration item. */
+template <class T>
+using Entry = std::unordered_map<std::string, T>;
+
/** Output artifact configuration options. */
struct Artifact {
/** Name to use for output of processing foo.apk -> foo.<name>.apk. */
@@ -104,6 +108,12 @@
Maybe<std::string> max_sdk_version;
Maybe<AndroidManifest> manifest;
+ static AndroidSdk ForMinSdk(std::string min_sdk) {
+ AndroidSdk sdk;
+ sdk.min_sdk_version = {std::move(min_sdk)};
+ return sdk;
+ }
+
inline friend bool operator==(const AndroidSdk& lhs, const AndroidSdk& rhs) {
return lhs.min_sdk_version == rhs.min_sdk_version &&
lhs.target_sdk_version == rhs.target_sdk_version &&
@@ -134,7 +144,7 @@
Group<Abi> abi_groups;
Group<ConfigDescription> screen_density_groups;
Group<ConfigDescription> locale_groups;
- Group<AndroidSdk> android_sdk_groups;
+ Entry<AndroidSdk> android_sdk_groups;
Group<DeviceFeature> device_feature_groups;
Group<GlTexture> gl_texture_groups;