From 7e0e4c11f2d3206948973bbd85e14c5bf3bbedcb Mon Sep 17 00:00:00 2001 From: Dave Ingram Date: Thu, 1 Aug 2019 15:11:41 -0700 Subject: [PATCH] Badging should print package attributes at most once Following up to change 7938786; if an APK had platformBuildVersionCode compiled as *both* integer and string, it would be output twice. This then confuses anything that tries to parse the output. With this change, the value will be printed at most once, with the string version taking priority. Bug: 138666693 Test: manually built SDK28 APK and ran aapt2 dump badging Change-Id: Icf6eb656ac0cb263969bb2f0c5ca03139985f6ca --- tools/aapt2/dump/DumpManifest.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index 54f0816f03989..31aa2494052c2 100644 --- a/tools/aapt2/dump/DumpManifest.cpp +++ b/tools/aapt2/dump/DumpManifest.cpp @@ -468,14 +468,12 @@ class Manifest : public ManifestExtractor::Element { } if (platformVersionName) { printer->Print(StringPrintf(" platformBuildVersionName='%s'", platformVersionName->data())); - } - if (platformVersionNameInt) { + } else if (platformVersionNameInt) { printer->Print(StringPrintf(" platformBuildVersionName='%d'", *platformVersionNameInt)); } if (platformVersionCode) { printer->Print(StringPrintf(" platformBuildVersionCode='%s'", platformVersionCode->data())); - } - if (platformVersionCodeInt) { + } else if (platformVersionCodeInt) { printer->Print(StringPrintf(" platformBuildVersionCode='%d'", *platformVersionCodeInt)); } if (compilesdkVersion) {