Merge pull request #2430 from Sonicadvance1/android_panic_handler

[Android] Add support for panic alerts to the JNI.
This commit is contained in:
Ryan Houdek 2015-05-25 23:37:48 -04:00
commit c88d6c804a
2 changed files with 46 additions and 2 deletions

View File

@ -217,6 +217,21 @@ public final class NativeLibrary
*/
public static native void WriteProfileResults();
/**
* @return If we have an alert
*/
public static native boolean HasAlertMsg();
/**
* @return The alert string
*/
public static native String GetAlertMsg();
/**
* Clears event in the JNI so we can continue onward
*/
public static native void ClearAlertMsg();
/** Native EGL functions not exposed by Java bindings **/
public static native void eglBindAPI(int api);

View File

@ -37,6 +37,11 @@ ANativeWindow* surf;
std::string g_filename;
std::string g_set_userpath = "";
// PanicAlert
static bool g_alert_available = false;
static std::string g_alert_message = "";
static Common::Event g_alert_event;
#define DOLPHIN_TAG "DolphinEmuNative"
void Host_NotifyMapLoaded() {}
@ -92,9 +97,13 @@ void Host_SetWiiMoteConnectionState(int _State) {}
void Host_ShowVideoConfig(void*, const std::string&, const std::string&) {}
static bool MsgAlert(const char* caption, const char* text, bool /*yes_no*/, int /*Style*/)
static bool MsgAlert(const char* caption, const char* text, bool yes_no, int /*Style*/)
{
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "%s:%s", caption, text);
g_alert_message = std::string(text);
g_alert_available = true;
// XXX: Uncomment next line when the Android UI actually handles messages
// g_alert_event.Wait()
g_alert_available = false;
return false;
}
@ -370,6 +379,11 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv *env, jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf);
// MsgAlert
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_HasAlertMsg(JNIEnv *env, jobject obj);
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetAlertMsg(JNIEnv *env, jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ClearAlertMsg(JNIEnv *env, jobject obj);
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmulation(JNIEnv *env, jobject obj)
{
PowerPC::Start();
@ -564,6 +578,21 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfile
JitInterface::WriteProfileResults(filename);
}
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_HasAlertMsg(JNIEnv *env, jobject obj)
{
return g_alert_available;
}
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetAlertMsg(JNIEnv *env, jobject obj)
{
return env->NewStringUTF(g_alert_message.c_str());
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ClearAlertMsg(JNIEnv *env, jobject obj)
{
g_alert_event.Set(); // Kick the alert
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *env, jobject obj, jobject _surf)
{
surf = ANativeWindow_fromSurface(env, _surf);