mirror of
https://github.com/izzy2lost/WeeU.git
synced 2026-07-06 00:19:59 -07:00
Added logging of unhandled exception from java code
This commit is contained in:
@@ -11,6 +11,7 @@ add_library(CemuAndroid SHARED
|
||||
NativeGraphicPacks.cpp
|
||||
NativeInput.cpp
|
||||
NativeLib.cpp
|
||||
NativeLogging.cpp
|
||||
NativeSettings.cpp
|
||||
NativeSwkbd.cpp
|
||||
)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "Common/ExceptionHandler/ExceptionHandler.h"
|
||||
#include "JNIUtils.h"
|
||||
|
||||
extern "C" [[maybe_unused]] JNIEXPORT void JNICALL
|
||||
Java_info_cemu_Cemu_nativeinterface_NativeLogging_log(JNIEnv* env, [[maybe_unused]] jclass clazz, jstring message)
|
||||
{
|
||||
cemuLog_log(LogType::Force, JNIUtils::JStringToString(env, message));
|
||||
}
|
||||
|
||||
extern "C" [[maybe_unused]] JNIEXPORT void JNICALL
|
||||
Java_info_cemu_Cemu_nativeinterface_NativeLogging_crashLog(JNIEnv* env, [[maybe_unused]] jclass clazz, jstring stacktrace)
|
||||
{
|
||||
if (!CrashLog_Create())
|
||||
return; // give up if crashlog was already created
|
||||
CrashLog_WriteLine("Unhandled exception from java code");
|
||||
CrashLog_WriteLine(JNIUtils::JStringToString(env, stacktrace));
|
||||
}
|
||||
@@ -4,9 +4,12 @@ import android.app.Application;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import info.cemu.Cemu.nativeinterface.NativeEmulation;
|
||||
import info.cemu.Cemu.nativeinterface.NativeGraphicPacks;
|
||||
import info.cemu.Cemu.nativeinterface.NativeLogging;
|
||||
import info.cemu.Cemu.nativeinterface.NativeSwkbd;
|
||||
|
||||
public class CemuApplication extends Application {
|
||||
@@ -14,6 +17,7 @@ public class CemuApplication extends Application {
|
||||
System.loadLibrary("CemuAndroid");
|
||||
}
|
||||
|
||||
private static Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler;
|
||||
private static CemuApplication application;
|
||||
|
||||
public CemuApplication() {
|
||||
@@ -35,6 +39,17 @@ public class CemuApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if (defaultUncaughtExceptionHandler == null) {
|
||||
defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
}
|
||||
Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter printWriter = new PrintWriter(stringWriter);
|
||||
exception.printStackTrace(printWriter);
|
||||
String stacktrace = stringWriter.toString();
|
||||
NativeLogging.crashLog(stacktrace);
|
||||
defaultUncaughtExceptionHandler.uncaughtException(thread, exception);
|
||||
});
|
||||
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
|
||||
NativeEmulation.setDPI(displayMetrics.density);
|
||||
NativeEmulation.initializeActiveSettings(getInternalFolder().toString(), getInternalFolder().toString());
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package info.cemu.Cemu.nativeinterface;
|
||||
|
||||
public class NativeLogging {
|
||||
public static native void log(String message);
|
||||
|
||||
public static native void crashLog(String stacktrace);
|
||||
}
|
||||
Reference in New Issue
Block a user