summaryrefslogtreecommitdiff
path: root/tools/aapt2/dump
diff options
context:
space:
mode:
author Iurii Makhno <iuriimak@google.com> 2022-09-07 00:48:04 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-09-07 00:48:04 +0000
commit513f52f970cd61b9918c2ddd877c5bc237203b13 (patch)
tree4343c1ca1af2e3f01ebd6bdeaadf9eda0ac45cc2 /tools/aapt2/dump
parent744acd8079a10301c213b2c807449c0cb3945e0c (diff)
parent05fd929d3e214e08765cd1c96b4a043c99fe47db (diff)
Merge "Use the latest 'uses-sdk' tag to detect target SDK version."
Diffstat (limited to 'tools/aapt2/dump')
-rw-r--r--tools/aapt2/dump/DumpManifest.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp
index 2a5ad9606bb6..c4c002d16ebb 100644
--- a/tools/aapt2/dump/DumpManifest.cpp
+++ b/tools/aapt2/dump/DumpManifest.cpp
@@ -448,7 +448,12 @@ class ManifestExtractor {
/** Recursively visit the xml element tree and return a processed badging element tree. */
std::unique_ptr<Element> Visit(xml::Element* element);
- /** Raises the target sdk value if the min target is greater than the current target. */
+ /** Resets target SDK to 0. */
+ void ResetTargetSdk() {
+ target_sdk_ = 0;
+ }
+
+ /** Raises the target sdk value if the min target is greater than the current target. */
void RaiseTargetSdk(int32_t min_target) {
if (min_target > target_sdk_) {
target_sdk_ = min_target;
@@ -799,6 +804,10 @@ class UsesSdkBadging : public ManifestExtractor::Element {
target_sdk = GetAttributeInteger(FindAttribute(element, TARGET_SDK_VERSION_ATTR));
target_sdk_name = GetAttributeString(FindAttribute(element, TARGET_SDK_VERSION_ATTR));
+ // Resets target SDK first. This is required if APK contains multiple <uses-sdk> elements,
+ // we only need to take the latest values.
+ extractor()->ResetTargetSdk();
+
// Detect the target sdk of the element
if ((min_sdk_name && *min_sdk_name == "Donut")
|| (target_sdk_name && *target_sdk_name == "Donut")) {