summaryrefslogtreecommitdiff
path: root/tools/aapt2/dump
diff options
context:
space:
mode:
author Jeremy Meyer <jakmcbane@google.com> 2022-12-15 18:43:36 +0000
committer Jeremy Meyer <jakmcbane@google.com> 2023-01-24 18:32:10 +0000
commit5fd34eabbd37092077ba083eefa2c42c3ce93c5a (patch)
treed21f3ded6a369f8b982759e299439d6d776ecf37 /tools/aapt2/dump
parentfd723c205c3654aa5414ea92c2f06ca67ec1fcdb (diff)
Have aapt2 check library names the same as package manager
Bug: 231297692 Test: Manual Change-Id: I11a660969443aa90cf6b51a0947accca4231310f
Diffstat (limited to 'tools/aapt2/dump')
-rw-r--r--tools/aapt2/dump/DumpManifest.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/tools/aapt2/dump/DumpManifest.cpp b/tools/aapt2/dump/DumpManifest.cpp
index d1957fb30cb9..c66f4e5b7c30 100644
--- a/tools/aapt2/dump/DumpManifest.cpp
+++ b/tools/aapt2/dump/DumpManifest.cpp
@@ -16,6 +16,8 @@
#include "DumpManifest.h"
+#include <androidfw/ApkParsing.h>
+
#include <algorithm>
#include <array>
#include <memory>
@@ -2729,19 +2731,25 @@ bool ManifestExtractor::Extract(android::IDiagnostics* diag) {
}));
supports_screen_ = screen ? screen : &default_screens;
+ bool has_renderscript_bitcode = false;
+ auto it = apk_->GetFileCollection()->Iterator();
+ while (it->HasNext()) {
+ if (it->Next()->GetSource().path.ends_with(".bc")) {
+ has_renderscript_bitcode = true;
+ break;
+ }
+ }
+
// Gather the supported architectures_ of the app
std::set<std::string> architectures_from_apk;
- auto it = apk_->GetFileCollection()->Iterator();
+ it = apk_->GetFileCollection()->Iterator();
while (it->HasNext()) {
- auto file_path = it->Next()->GetSource().path;
- if (file_path.starts_with("lib/")) {
- file_path = file_path.substr(4);
- size_t pos = file_path.find('/');
- if (pos != std::string::npos) {
- file_path = file_path.substr(0, pos);
- }
+ auto file_path = it->Next()->GetSource().path.c_str();
- architectures_from_apk.insert(file_path);
+ const char* last_slash =
+ android::util::ValidLibraryPathLastSlash(file_path, has_renderscript_bitcode, false);
+ if (last_slash) {
+ architectures_from_apk.insert(std::string(file_path + APK_LIB_LEN, last_slash));
}
}