diff options
author | 2024-02-07 18:31:38 +0000 | |
---|---|---|
committer | 2024-02-15 18:22:04 +0000 | |
commit | a01591339b6c6c4426c4f087c32d75edf1d0fb98 (patch) | |
tree | 3d8252bd54c274702fc93e8257af9cd1dad625a8 /libnativeloader/library_namespaces.cpp | |
parent | 8a9b51e34f3769a5e3ea3a4383e3f00489088738 (diff) |
Improve debug logging to reflect all code paths in OpenNativeLibrary.
Also some related code cleanups.
Test: atest libnativeloader_e2e_tests \
libnativeloader_test libnativeloader_lazy_test
Bug: 237577392
Change-Id: Ia8842cdaf84d282353f3b0c55ca3d56bbc3bd4aa
Diffstat (limited to 'libnativeloader/library_namespaces.cpp')
-rw-r--r-- | libnativeloader/library_namespaces.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libnativeloader/library_namespaces.cpp b/libnativeloader/library_namespaces.cpp index 683e76247f..2aeaf88a1e 100644 --- a/libnativeloader/library_namespaces.cpp +++ b/libnativeloader/library_namespaces.cpp @@ -23,6 +23,7 @@ #include <dirent.h> #include <dlfcn.h> +#include <optional> #include <regex> #include <string> #include <vector> @@ -356,12 +357,12 @@ Result<NativeLoaderNamespace*> LibraryNamespaces::Create(JNIEnv* env, } for (const std::string& each_jar_path : android::base::Split(dex_path, ":")) { - Result<std::string> apex_ns_name = FindApexNamespaceName(each_jar_path); - if (apex_ns_name.ok()) { - const std::string& jni_libs = apex_jni_libraries(*apex_ns_name); + std::optional<std::string> apex_ns_name = FindApexNamespaceName(each_jar_path); + if (apex_ns_name.has_value()) { + const std::string& jni_libs = apex_jni_libraries(apex_ns_name.value()); if (jni_libs != "") { Result<NativeLoaderNamespace> apex_ns = - NativeLoaderNamespace::GetExportedNamespace(*apex_ns_name, is_bridged); + NativeLoaderNamespace::GetExportedNamespace(apex_ns_name.value(), is_bridged); if (apex_ns.ok()) { linked = app_ns->Link(&apex_ns.value(), jni_libs); if (!linked.ok()) { @@ -444,7 +445,7 @@ NativeLoaderNamespace* LibraryNamespaces::FindParentNamespaceByClassLoader(JNIEn return nullptr; } -base::Result<std::string> FindApexNamespaceName(const std::string& location) { +std::optional<std::string> FindApexNamespaceName(const std::string& location) { // Lots of implicit assumptions here: we expect `location` to be of the form: // /apex/modulename/... // @@ -458,7 +459,7 @@ base::Result<std::string> FindApexNamespaceName(const std::string& location) { std::replace(name.begin(), name.end(), '.', '_'); return name; } - return base::Error(); + return std::nullopt; } } // namespace android::nativeloader |