diff options
author | 2021-03-29 10:05:21 -0600 | |
---|---|---|
committer | 2021-03-29 10:05:23 -0600 | |
commit | abcddfd12bb644213334ae445498dcce54f8b0f6 (patch) | |
tree | 9cc3a7065a05847a25060129c4f4aceab9d8b787 /tools/aapt2/dump | |
parent | 2b5b144ed094ebfd3ee87667d2b6d86ff486d689 (diff) |
Emit "usesPermissionFlags" in "dump badging".
Since developers can declare the "neverForLocation" flag in their
manifest as public API, we should also offer a way to inspect the
value that we parsed from the manifest.
Bug: 183816684
Test: aapt2 dump badging \
CtsAppThatRequestsBluetoothPermissionNeverForLocation31.apk
Change-Id: I93c0371d6fb1a0ca928aa26265074acee2bee879
Diffstat (limited to 'tools/aapt2/dump')
-rw-r--r-- | tools/aapt2/dump/DumpManifest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp index cc1cf7f23246..fb7c596e7497 100644 --- a/tools/aapt2/dump/DumpManifest.cpp +++ b/tools/aapt2/dump/DumpManifest.cpp @@ -88,10 +88,12 @@ enum { COMPILE_SDK_VERSION_CODENAME_ATTR = 0x01010573, VERSION_MAJOR_ATTR = 0x01010577, PACKAGE_TYPE_ATTR = 0x01010587, + USES_PERMISSION_FLAGS_ATTR = 0x01010644, }; const std::string& kAndroidNamespace = "http://schemas.android.com/apk/res/android"; constexpr int kCurrentDevelopmentVersion = 10000; +constexpr int kNeverForLocation = 0x00010000; /** Retrieves the attribute of the element with the specified attribute resource id. */ static xml::Attribute* FindAttribute(xml::Element *el, uint32_t resd_id) { @@ -1067,6 +1069,7 @@ class UsesPermission : public ManifestExtractor::Element { std::vector<std::string> requiredNotFeatures; int32_t required = true; int32_t maxSdkVersion = -1; + int32_t usesPermissionFlags = 0; void Extract(xml::Element* element) override { name = GetAttributeStringDefault(FindAttribute(element, NAME_ATTR), ""); @@ -1083,6 +1086,8 @@ class UsesPermission : public ManifestExtractor::Element { required = GetAttributeIntegerDefault(FindAttribute(element, REQUIRED_ATTR), 1); maxSdkVersion = GetAttributeIntegerDefault( FindAttribute(element, MAX_SDK_VERSION_ATTR), -1); + usesPermissionFlags = GetAttributeIntegerDefault( + FindAttribute(element, USES_PERMISSION_FLAGS_ATTR), 0); if (!name.empty()) { CommonFeatureGroup* common = extractor()->GetCommonFeatureGroup(); @@ -1096,6 +1101,9 @@ class UsesPermission : public ManifestExtractor::Element { if (maxSdkVersion >= 0) { printer->Print(StringPrintf(" maxSdkVersion='%d'", maxSdkVersion)); } + if ((usesPermissionFlags & kNeverForLocation) != 0) { + printer->Print(StringPrintf(" usesPermissionFlags='neverForLocation'")); + } printer->Print("\n"); for (const std::string& requiredFeature : requiredFeatures) { printer->Print(StringPrintf(" required-feature='%s'\n", requiredFeature.data())); @@ -1108,6 +1116,9 @@ class UsesPermission : public ManifestExtractor::Element { if (maxSdkVersion >= 0) { printer->Print(StringPrintf(" maxSdkVersion='%d'", maxSdkVersion)); } + if ((usesPermissionFlags & kNeverForLocation) != 0) { + printer->Print(StringPrintf(" usesPermissionFlags='neverForLocation'")); + } printer->Print("\n"); } } @@ -1118,6 +1129,9 @@ class UsesPermission : public ManifestExtractor::Element { if (maxSdkVersion >= 0) { printer->Print(StringPrintf(" maxSdkVersion='%d'", maxSdkVersion)); } + if ((usesPermissionFlags & kNeverForLocation) != 0) { + printer->Print(StringPrintf(" usesPermissionFlags='neverForLocation'")); + } printer->Print(StringPrintf(" reason='%s'\n", reason.data())); } }; |