diff options
author | 2022-08-24 18:56:12 +0000 | |
---|---|---|
committer | 2022-08-24 19:00:49 +0000 | |
commit | 05fd929d3e214e08765cd1c96b4a043c99fe47db (patch) | |
tree | 067aa250aabd5bcd2d5fa51ed89b10c1e4da476a /tools/aapt2/dump | |
parent | a833d0f25bab61cb3b9c089bc760f68664ede8b2 (diff) |
Use the latest 'uses-sdk' tag to detect target SDK version.
At the moment aapt2 dumps information from the latest <uses-sdk> element
but uses all of them to detect target SDK which affects implied
permissions. Use only the latest one for detecting targetSdk as well.
Bug: b/243145989
Test: Dump_test
Change-Id: I70f828f1845ab070fa84c5297af12df24e7068dc
Diffstat (limited to 'tools/aapt2/dump')
-rw-r--r-- | tools/aapt2/dump/DumpManifest.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index b3165d320e9b..f0b0e867b35b 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")) { |