summaryrefslogtreecommitdiff
path: root/tools/aapt2/optimize
diff options
context:
space:
mode:
authorShane Farmer <safarmer@google.com>2017-12-04 09:08:38 -0800
committerShane Farmer <safarmer@google.com>2017-12-19 13:52:30 -0800
commit78c43d7bee2a476d6edffe0a4368eb6fcef38c31 (patch)
tree6d039a14cd325c041d404e2058bed7d2a201c216 /tools/aapt2/optimize
parent39e474f4b4a975d8befa1e8f4cbedab5f47a43fa (diff)
AAPT2: Sort artifacts based on the Play Store rules.
Sort output artifacts so that the updated versionCode manifest entry will allow correct handling of updates from Play Store. The most important dimension is Android SDK version. It is important that a split based on min SDK version will allow a user to get a new APK if they upgrade the OS on their device to support a new split. ABI splits need to also be taken into consideration as it is possible for a device to run in ARM emulation mode and installing an ARM APK over a x86 APK could cause performance regressions. The XML file format was updated to give each of the configuration groups have their own section of the XML file. This allows the sort order to be determined by a groups ordering. Artifacts can now be added to the configuration file in an arbitrary order. Since this will be the common case for developers, it will help reduce errors from inserting a new artifact in the wrong spot. The implementation follows the rules outlined at: https://developer.android.com/google/play/publishing/multiple-apks.html Test: Unit tests Test: Manual process XML configuration Change-Id: I0face862c6d6b9d3cd2d99088afe5b9491be0120
Diffstat (limited to 'tools/aapt2/optimize')
-rw-r--r--tools/aapt2/optimize/MultiApkGenerator.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/tools/aapt2/optimize/MultiApkGenerator.cpp b/tools/aapt2/optimize/MultiApkGenerator.cpp
index 16898d6f3e03..991faadcafc4 100644
--- a/tools/aapt2/optimize/MultiApkGenerator.cpp
+++ b/tools/aapt2/optimize/MultiApkGenerator.cpp
@@ -120,8 +120,6 @@ MultiApkGenerator::MultiApkGenerator(LoadedApk* apk, IAaptContext* context)
}
bool MultiApkGenerator::FromBaseApk(const MultiApkGeneratorOptions& options) {
- // TODO(safarmer): Handle APK version codes for the generated APKs.
-
std::unordered_set<std::string> artifacts_to_keep = options.kept_artifacts;
std::unordered_set<std::string> filtered_artifacts;
std::unordered_set<std::string> kept_artifacts;
@@ -237,8 +235,8 @@ std::unique_ptr<ResourceTable> MultiApkGenerator::FilterTable(IAaptContext* cont
splits.config_filter = &axis_filter;
}
- if (artifact.android_sdk && artifact.android_sdk.value().min_sdk_version) {
- wrapped_context.SetMinSdkVersion(artifact.android_sdk.value().min_sdk_version.value());
+ if (artifact.android_sdk) {
+ wrapped_context.SetMinSdkVersion(artifact.android_sdk.value().min_sdk_version);
}
std::unique_ptr<ResourceTable> table = old_table.Clone();
@@ -301,7 +299,7 @@ bool MultiApkGenerator::UpdateManifest(const OutputArtifact& artifact,
if (xml::Attribute* min_sdk_attr =
uses_sdk_el->FindAttribute(xml::kSchemaAndroid, "minSdkVersion")) {
// Populate with a pre-compiles attribute to we don't need to relink etc.
- const std::string& min_sdk_str = std::to_string(android_sdk.min_sdk_version.value());
+ const std::string& min_sdk_str = std::to_string(android_sdk.min_sdk_version);
min_sdk_attr->compiled_value = ResourceUtils::TryParseInt(min_sdk_str);
} else {
// There was no minSdkVersion. This is strange since at this point we should have been