diff --git a/embedding/android/GeckoApp.java b/embedding/android/GeckoApp.java index 604d2654d89..e06319ae133 100644 --- a/embedding/android/GeckoApp.java +++ b/embedding/android/GeckoApp.java @@ -406,7 +406,8 @@ abstract public class GeckoApp Log.i(LOG_FILE_NAME, "pleaseKillMe"); if (surfaceView != null) surfaceView.saveLast(true); - System.exit(0); + GeckoAppShell.nativeQuit(); + finish(); } void handleLocationChange(final int tabId, final String uri) { diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index 7d25bcc5ff6..8881fefb9d7 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -110,6 +110,7 @@ public class GeckoAppShell // Initialization methods public static native void nativeInit(); public static native void nativeRun(String args); + public static native void nativeQuit(); // helper methods public static native void setSurfaceView(GeckoSurfaceView sv); diff --git a/other-licenses/android/APKOpen.cpp b/other-licenses/android/APKOpen.cpp index b6e8f31d774..1bd89ec5e8b 100644 --- a/other-licenses/android/APKOpen.cpp +++ b/other-licenses/android/APKOpen.cpp @@ -230,6 +230,7 @@ Java_org_mozilla_gecko_GeckoAppShell_ ## name(JNIEnv *jenv, jclass jc, type1 one SHELL_WRAPPER0(nativeInit) SHELL_WRAPPER1(nativeRun, jstring) +SHELL_WRAPPER0(nativeQuit) SHELL_WRAPPER1(notifyGeckoOfEvent, jobject) SHELL_WRAPPER0(processNextNativeEvent) SHELL_WRAPPER1(setSurfaceView, jobject) @@ -635,6 +636,7 @@ loadLibs(const char *apkName) #define GETFUNC(name) f_ ## name = (name ## _t) __wrap_dlsym(xul_handle, "Java_org_mozilla_gecko_GeckoAppShell_" #name) GETFUNC(nativeInit); GETFUNC(nativeRun); + GETFUNC(nativeQuit); GETFUNC(notifyGeckoOfEvent); GETFUNC(processNextNativeEvent); GETFUNC(setSurfaceView); diff --git a/toolkit/xre/nsAndroidStartup.cpp b/toolkit/xre/nsAndroidStartup.cpp index ca0c09a5a4f..53168ba5605 100644 --- a/toolkit/xre/nsAndroidStartup.cpp +++ b/toolkit/xre/nsAndroidStartup.cpp @@ -54,6 +54,8 @@ #include "AndroidBridge.h" #include "APKOpen.h" #include "nsExceptionHandler.h" +#include "nsIAppStartup.h" +#include "nsToolkitCompsCID.h" #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, MOZ_APP_NAME, args) @@ -168,3 +170,11 @@ Java_org_mozilla_gecko_GeckoAppShell_nativeRun(JNIEnv *jenv, jclass jc, jstring GeckoStart(args); } +extern "C" NS_EXPORT void JNICALL +Java_org_mozilla_gecko_GeckoAppShell_nativeQuit(JNIEnv*, jclass) +{ + nsCOMPtr appStartup = + do_GetService(NS_APPSTARTUP_CONTRACTID); + if (appStartup) + appStartup->Quit(nsIAppStartup::eAttemptQuit); +}