From 5fd34eabbd37092077ba083eefa2c42c3ce93c5a Mon Sep 17 00:00:00 2001 From: Jeremy Meyer Date: Thu, 15 Dec 2022 18:43:36 +0000 Subject: Have aapt2 check library names the same as package manager Bug: 231297692 Test: Manual Change-Id: I11a660969443aa90cf6b51a0947accca4231310f --- tools/aapt2/dump/DumpManifest.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'tools/aapt2/dump') 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 + #include #include #include @@ -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 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)); } } -- cgit v1.2.3-59-g8ed1b