Bug 733434 - Part 1: Register a global UncaughtExceptionHandler that calls Breakpad. r=blassey

This commit is contained in:
Chris Peterson 2012-03-07 11:19:05 -08:00
Родитель cfc4569fe5
Коммит a9eba18fa6
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -1608,6 +1608,8 @@ abstract public class GeckoApp
@Override
public void onCreate(Bundle savedInstanceState)
{
GeckoAppShell.registerGlobalExceptionHandler();
mAppContext = this;
// StrictMode is set by defaults resource flag |enableStrictMode|.

Просмотреть файл

@ -143,13 +143,27 @@ public class GeckoAppShell
public static native void loadSQLiteLibsNative(String apkName, boolean shouldExtract);
public static native void onChangeNetworkLinkStatus(String status);
public static void registerGlobalExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread thread, Throwable e) {
Log.e(LOGTAG, ">>> REPORTING UNCAUGHT EXCEPTION FROM THREAD "
+ thread.getId() + " (\"" + thread.getName() + "\")", e);
reportJavaCrash(getStackTraceString(e));
}
});
}
public static void reportJavaCrash(Throwable e) {
Log.e(LOGTAG, "top level exception", e);
reportJavaCrash(getStackTraceString(e));
}
private static String getStackTraceString(Throwable e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.flush();
reportJavaCrash(sw.toString());
return sw.toString();
}
private static native void reportJavaCrash(String stackTrace);