diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index b8c34df1a5aa..93704d2e6df9 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -351,6 +351,7 @@ #if MOZ_CRASHREPORTER PENDING_EVENTS = new ConcurrentLinkedQueue(); private static final Map ALERT_COOKIES = new ConcurrentHashMap(); @@ -206,27 +263,6 @@ public class GeckoAppShell public static native void onSurfaceTextureFrameAvailable(Object surfaceTexture, int id); public static native void dispatchMemoryPressure(); - public static void registerGlobalExceptionHandler() { - if (systemUncaughtHandler == null) { - systemUncaughtHandler = Thread.getDefaultUncaughtExceptionHandler(); - } - - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread thread, Throwable e) { - handleUncaughtException(thread, e); - } - }); - } - - private static String getStackTraceString(Throwable e) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - e.printStackTrace(pw); - pw.flush(); - return sw.toString(); - } - private static native void reportJavaCrash(String stackTrace); public static void notifyUriVisited(String uri) { @@ -415,57 +451,7 @@ public class GeckoAppShell @WrapElementForJNI(allowMultithread = true, noThrow = true) public static void handleUncaughtException(Thread thread, Throwable e) { - if (GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoExited)) { - // We've called System.exit. All exceptions after this point are Android - // berating us for being nasty to it. - return; - } - - if (thread == null) { - thread = Thread.currentThread(); - } - // If the uncaught exception was rethrown, walk the exception `cause` chain to find - // the original exception so Socorro can correctly collate related crash reports. - Throwable cause; - while ((cause = e.getCause()) != null) { - e = cause; - } - - try { - Log.e(LOGTAG, ">>> REPORTING UNCAUGHT EXCEPTION FROM THREAD " - + thread.getId() + " (\"" + thread.getName() + "\")", e); - - Thread mainThread = ThreadUtils.getUiThread(); - if (mainThread != null && thread != mainThread) { - Log.e(LOGTAG, "Main thread stack:"); - for (StackTraceElement ste : mainThread.getStackTrace()) { - Log.e(LOGTAG, ste.toString()); - } - } - - if (e instanceof OutOfMemoryError) { - SharedPreferences prefs = getSharedPreferences(); - SharedPreferences.Editor editor = prefs.edit(); - editor.putBoolean(GeckoApp.PREFS_OOM_EXCEPTION, true); - - // Synchronously write to disk so we know it's done before we - // shutdown - editor.commit(); - } - } catch (final Throwable exc) { - // Report the Java crash below, even if we encounter an exception here. - } - - try { - reportJavaCrash(getStackTraceString(e)); - } finally { - // reportJavaCrash should have caused us to hard crash. If we're still here, - // it probably means Gecko is not loaded, and we should do something else. - // Bring up the app crashed dialog so we don't crash silently. - if (systemUncaughtHandler != null) { - systemUncaughtHandler.uncaughtException(thread, e); - } - } + CRASH_HANDLER.uncaughtException(thread, e); } @WrapElementForJNI