From 95f024289bca153eb562f011e4fe767bc6519c79 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Thu, 30 Apr 2020 10:25:53 -0700 Subject: [PATCH] Treat non-integer target SDK as version 10000 Currently aapt2 treats non-integer target SDK values as SDK level 0. This resulted in incorrect implied permission dumps. This change causes aapt2 to treat non-integer SDK values as version 10000. Bug: 155391001 Test: aapt2 dump badging CtsSkQPTestCases.apk Change-Id: Ie4312a827974a7a10b40b12f8f23d264d1b1999a --- tools/aapt2/dump/DumpManifest.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index e7a82034c77a8..4a6bfd0312843 100644 --- a/tools/aapt2/dump/DumpManifest.cpp +++ b/tools/aapt2/dump/DumpManifest.cpp @@ -91,6 +91,7 @@ enum { }; const std::string& kAndroidNamespace = "http://schemas.android.com/apk/res/android"; +constexpr int kCurrentDevelopmentVersion = 10000; /** Retrieves the attribute of the element with the specified attribute resource id. */ static xml::Attribute* FindAttribute(xml::Element *el, uint32_t resd_id) { @@ -325,7 +326,7 @@ class ManifestExtractor { ConfigDescription config; config.orientation = android::ResTable_config::ORIENTATION_PORT; config.density = android::ResTable_config::DENSITY_MEDIUM; - config.sdkVersion = 10000; // Very high. + config.sdkVersion = kCurrentDevelopmentVersion; // Very high. config.screenWidthDp = 320; config.screenHeightDp = 480; config.smallestScreenWidthDp = 320; @@ -622,6 +623,8 @@ class UsesSdkBadging : public ManifestExtractor::Element { } if (target_sdk) { extractor()->RaiseTargetSdk(*target_sdk); + } else if (target_sdk_name) { + extractor()->RaiseTargetSdk(kCurrentDevelopmentVersion); } }