diff options
| author | 2024-02-27 16:36:27 +0000 | |
|---|---|---|
| committer | 2024-02-27 16:36:27 +0000 | |
| commit | 17688475c25c5a1b1df0d9fe6b3ec765620407f2 (patch) | |
| tree | 0b531478551a440a0bb881e040584ccf94b719ac | |
| parent | 465f3a4fbe997b04bd8380efd1c7655353e121ee (diff) | |
| parent | 019f26298f4b8c3b83aa94cbe3c760d2238de8f4 (diff) | |
Merge "[LayoutlibLoader] Print exception when FindClassOrDie, etc fail" into main
| -rw-r--r-- | core/jni/LayoutlibLoader.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/jni/LayoutlibLoader.cpp b/core/jni/LayoutlibLoader.cpp index 01e9f437a79f..06d5eb305ff0 100644 --- a/core/jni/LayoutlibLoader.cpp +++ b/core/jni/LayoutlibLoader.cpp @@ -362,6 +362,22 @@ static void init_keyboard(JNIEnv* env, const vector<string>& keyboardPaths) { using namespace android; +// Called right before aborting by LOG_ALWAYS_FATAL. Print the pending exception. +void abort_handler(const char* abort_message) { + ALOGE("Abort to abort the process..."); + + JNIEnv* env = NULL; + if (javaVM->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { + ALOGE("vm->GetEnv() failed"); + return; + } + if (env->ExceptionOccurred() != NULL) { + ALOGE("Pending exception:"); + env->ExceptionDescribe(); + } + ALOGE("Aborting because: %s", abort_message); +} + JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) { javaVM = vm; JNIEnv* env = nullptr; @@ -369,6 +385,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) { return JNI_ERR; } + __android_log_set_aborter(abort_handler); + init_android_graphics(); // Configuration is stored as java System properties. |