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
diff --git a/tools/aapt2/test/Builders.cpp b/tools/aapt2/test/Builders.cpp
index b579545..80e6adf 100644
--- a/tools/aapt2/test/Builders.cpp
+++ b/tools/aapt2/test/Builders.cpp
@@ -212,5 +212,63 @@
return doc;
}
+PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::SetAbiGroup(
+ const std::string& name, const std::vector<configuration::Abi>& abis) {
+ config_.abi_groups[name] = abis;
+ return *this;
+}
+
+PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::SetLocaleGroup(
+ const std::string& name, const std::vector<std::string>& locales) {
+ auto& group = config_.locale_groups[name];
+ for (const auto& locale : locales) {
+ group.push_back(ParseConfigOrDie(locale));
+ }
+ return *this;
+}
+
+PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::SetDensityGroup(
+ const std::string& name, const std::vector<std::string>& densities) {
+ auto& group = config_.screen_density_groups[name];
+ for (const auto& density : densities) {
+ group.push_back(ParseConfigOrDie(density));
+ }
+ return *this;
+}
+
+PostProcessingConfigurationBuilder& PostProcessingConfigurationBuilder::AddArtifact(
+ const configuration::Artifact& artifact) {
+ config_.artifacts.push_back(artifact);
+ return *this;
+}
+
+configuration::PostProcessingConfiguration PostProcessingConfigurationBuilder::Build() {
+ return config_;
+}
+
+ArtifactBuilder& ArtifactBuilder::SetName(const std::string& name) {
+ artifact_.name = {name};
+ return *this;
+}
+
+ArtifactBuilder& ArtifactBuilder::SetAbiGroup(const std::string& name) {
+ artifact_.abi_group = {name};
+ return *this;
+}
+
+ArtifactBuilder& ArtifactBuilder::SetDensityGroup(const std::string& name) {
+ artifact_.screen_density_group = {name};
+ return *this;
+}
+
+ArtifactBuilder& ArtifactBuilder::SetLocaleGroup(const std::string& name) {
+ artifact_.locale_group = {name};
+ return *this;
+}
+
+configuration::Artifact ArtifactBuilder::Build() {
+ return artifact_;
+}
+
} // namespace test
} // namespace aapt