From 2f23f0bbda024efc48d4351c0d45cfb398dddbd3 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 14 Sep 2018 05:41:02 +0000 Subject: [PATCH] Skip remove exceptions when reporting crash --- .../java/eu/faircode/email/ApplicationEx.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index 850a23bb..7ff6b9a9 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -23,6 +23,7 @@ import android.app.Application; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; +import android.os.RemoteException; import android.util.Log; import java.io.File; @@ -41,23 +42,25 @@ public class ApplicationEx extends Application { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable ex) { - Log.e(Helper.TAG, ex + "\r\n" + Log.getStackTraceString(ex)); - - File file = new File(getCacheDir(), "crash.log"); - Log.w(Helper.TAG, "Writing exception to " + file); - - FileWriter out = null; - try { - out = new FileWriter(file); - out.write(ex.toString() + "\n" + Log.getStackTraceString(ex)); - } catch (IOException e) { - Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException e) { - Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); + if (!(ex instanceof RemoteException) /* DeadSystemException */) { + Log.e(Helper.TAG, ex + "\r\n" + Log.getStackTraceString(ex)); + + File file = new File(getCacheDir(), "crash.log"); + Log.w(Helper.TAG, "Writing exception to " + file); + + FileWriter out = null; + try { + out = new FileWriter(file); + out.write(ex.toString() + "\n" + Log.getStackTraceString(ex)); + } catch (IOException e) { + Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + Log.e(Helper.TAG, e + "\n" + Log.getStackTraceString(e)); + } } } }