diff options
author | 2024-07-18 14:56:11 +0100 | |
---|---|---|
committer | 2024-07-26 15:50:42 +0000 | |
commit | 7640dd1396d3343c4f65938171af45c5ff43c4bf (patch) | |
tree | d87361c44fef9b8a71086f59bc9768455c09af1c | |
parent | c7031c2acf7ecaa2054ee1cf78d3d23bf7c6a461 (diff) |
Fix for b/349878424
Avoid loading the libsobrige library.
Test: device boots after mainline update.
Bug: 349878424
Bug: 343621630
Change-Id: I19e1b9a9328eb5a39b9a91580f602a09d5366ae7
-rw-r--r-- | libnativeloader/native_loader.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp index 580d833d9d..231b3c5aea 100644 --- a/libnativeloader/native_loader.cpp +++ b/libnativeloader/native_loader.cpp @@ -31,6 +31,7 @@ #include "android-base/file.h" #include "android-base/macros.h" +#include <android-base/properties.h> #include "android-base/strings.h" #include "android-base/thread_annotations.h" #include "base/macros.h" @@ -40,6 +41,7 @@ #ifdef ART_TARGET_ANDROID #include "android-modules-utils/sdk_level.h" +#include "android/api-level.h" #include "library_namespaces.h" #include "log/log.h" #include "nativeloader/dlext_namespaces.h" @@ -269,6 +271,20 @@ jstring CreateClassLoaderNamespace(JNIEnv* env, return nullptr; } +#if defined(ART_TARGET_ANDROID) +static bool ShouldBypassLoadingLibSoBridge() { + struct stat st; + if (stat("/system/lib64/libsobridge.so", &st) != 0) { + return false; + } + std::string property = android::base::GetProperty("ro.product.build.fingerprint", ""); + return android_get_device_api_level() == 33 && + (property.starts_with("Xiaomi") || + property.starts_with("Redmi") || + property.starts_with("POCO")); +} +#endif + void* OpenNativeLibrary(JNIEnv* env, int32_t target_sdk_version, const char* path, @@ -317,6 +333,16 @@ void* OpenNativeLibrary(JNIEnv* env, } } + // Handle issue b/349878424. + static bool bypass_loading_libsobridge = ShouldBypassLoadingLibSoBridge(); + + if (bypass_loading_libsobridge && strcmp("libsobridge.so", path) == 0) { + // Load a different library to pretend the loading was successful. This + // allows the device to boot. + ALOGD("Loading libbase.so instead of libsobridge.so due to b/349878424"); + path = "libbase.so"; + } + // Fall back to the system namespace. This happens for preloaded JNI // libraries in the zygote. void* handle = OpenSystemLibrary(path, RTLD_NOW); |