summaryrefslogtreecommitdiff
path: root/tools/aapt2/dump
diff options
context:
space:
mode:
author Iurii Makhno <iuriimak@google.com> 2022-11-29 19:19:13 +0000
committer Iurii Makhno <iuriimak@google.com> 2022-11-30 13:31:16 +0000
commit0df4e6d05f9d8a6107bb657600513171a796405e (patch)
treed126c4d6e2c43d562e91174e3cdd3adfc7370e5d /tools/aapt2/dump
parentf0f510e46d03a508c7edd8de48ef4b6761e90ff6 (diff)
Fix compatibility between 'aapt2 dump' and 'aapt dump.'.
1. Report permissions declared only under <manifest>. 2. If the same feature reported multiple times: the last declaration wins. Bug: b/260704482 Test: manual runs Change-Id: Ic9ff32573d2bf6550c3a01ed3019da83590eda2f
Diffstat (limited to 'tools/aapt2/dump')
-rw-r--r--tools/aapt2/dump/DumpManifest.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp
index c4c002d16ebb..d60869af2846 100644
--- a/tools/aapt2/dump/DumpManifest.cpp
+++ b/tools/aapt2/dump/DumpManifest.cpp
@@ -1076,7 +1076,7 @@ class FeatureGroup : public ManifestExtractor::Element {
/** Adds a feature to the feature group. */
void AddFeature(const std::string& name, bool required = true, int32_t version = -1) {
- features_.insert(std::make_pair(name, Feature{ required, version }));
+ features_.insert_or_assign(name, Feature{required, version});
if (required) {
if (name == "android.hardware.camera.autofocus" ||
name == "android.hardware.camera.flash") {
@@ -1348,6 +1348,11 @@ class UsesPermission : public ManifestExtractor::Element {
std::string impliedReason;
void Extract(xml::Element* element) override {
+ const auto parent_stack = extractor()->parent_stack();
+ if (!extractor()->options_.only_permissions &&
+ (parent_stack.size() != 1 || !ElementCast<Manifest>(parent_stack[0]))) {
+ return;
+ }
name = GetAttributeStringDefault(FindAttribute(element, NAME_ATTR), "");
std::string feature =
GetAttributeStringDefault(FindAttribute(element, REQUIRED_FEATURE_ATTR), "");
@@ -1472,6 +1477,11 @@ class UsesPermissionSdk23 : public ManifestExtractor::Element {
const int32_t* maxSdkVersion = nullptr;
void Extract(xml::Element* element) override {
+ const auto parent_stack = extractor()->parent_stack();
+ if (!extractor()->options_.only_permissions &&
+ (parent_stack.size() != 1 || !ElementCast<Manifest>(parent_stack[0]))) {
+ return;
+ }
name = GetAttributeString(FindAttribute(element, NAME_ATTR));
maxSdkVersion = GetAttributeInteger(FindAttribute(element, MAX_SDK_VERSION_ATTR));