From a01591339b6c6c4426c4f087c32d75edf1d0fb98 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Wed, 7 Feb 2024 18:31:38 +0000 Subject: 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 --- libnativeloader/library_namespaces.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libnativeloader/library_namespaces.cpp') 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 #include +#include #include #include #include @@ -356,12 +357,12 @@ Result LibraryNamespaces::Create(JNIEnv* env, } for (const std::string& each_jar_path : android::base::Split(dex_path, ":")) { - Result 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 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 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 FindApexNamespaceName(const std::string& location) { +std::optional 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 FindApexNamespaceName(const std::string& location) { std::replace(name.begin(), name.end(), '.', '_'); return name; } - return base::Error(); + return std::nullopt; } } // namespace android::nativeloader -- cgit v1.2.3-59-g8ed1b