@Test public void testDefaultExceptionHanlder() { exceptionHanlder.uncaughtException(Thread.currentThread(), new Throwable()); verify(defaultExceptionHanlder, times(1)) .uncaughtException(any(Thread.class), any(Throwable.class)); }
@Override public void uncaughtException(Thread thread, Throwable throwable) { List<Throwable> causalChain; if (isEnabled.get() && isMapboxCrash(causalChain = getCausalChain(throwable))) { try { CrashReport report = CrashReportBuilder.setup(applicationContext, mapboxPackage, version) .addExceptionThread(thread) .addCausalChain(causalChain) .build(); ensureDirectoryWritable(applicationContext, mapboxPackage); File file = FileUtils.getFile(applicationContext, getReportFileName(mapboxPackage, report.getDateString())); FileUtils.writeToFile(file, report.toJson()); } catch (Exception ex) { Log.e(TAG, ex.toString()); } } if (defaultExceptionHandler != null) { defaultExceptionHandler.uncaughtException(thread, throwable); } else { Log.i(TAG, "Default exception handler is null"); } }
MapboxUncaughtExceptionHanlder implements Thread.UncaughtExceptionHandler,
  SharedPreferences.OnSharedPreferenceChangeListener { @Override public void uncaughtException(Thread thread, Throwable throwable) { List<Throwable> causalChain; if (isEnabled.get() && isMapboxCrash(causalChain = getCausalChain(throwable))) { try { CrashReport report = CrashReportBuilder.setup(applicationContext, mapboxPackage, version) .addExceptionThread(thread) .addCausalChain(causalChain) .build(); ensureDirectoryWritable(applicationContext, mapboxPackage); File file = FileUtils.getFile(applicationContext, getReportFileName(mapboxPackage, report.getDateString())); FileUtils.writeToFile(file, report.toJson()); } catch (Exception ex) { Log.e(TAG, ex.toString()); } } if (defaultExceptionHandler != null) { defaultExceptionHandler.uncaughtException(thread, throwable); } else { Log.i(TAG, "Default exception handler is null"); } } }
MapboxUncaughtExceptionHanlder implements Thread.UncaughtExceptionHandler,
  SharedPreferences.OnSharedPreferenceChangeListener { @Override public void uncaughtException(Thread thread, Throwable throwable) { List<Throwable> causalChain; if (isEnabled.get() && isMapboxCrash(causalChain = getCausalChain(throwable))) { try { CrashReport report = CrashReportBuilder.setup(applicationContext, mapboxPackage, version) .addExceptionThread(thread) .addCausalChain(causalChain) .build(); ensureDirectoryWritable(applicationContext, mapboxPackage); File file = FileUtils.getFile(applicationContext, getReportFileName(mapboxPackage, report.getDateString())); FileUtils.writeToFile(file, report.toJson()); } catch (Exception ex) { Log.e(TAG, ex.toString()); } } if (defaultExceptionHandler != null) { defaultExceptionHandler.uncaughtException(thread, throwable); } else { Log.i(TAG, "Default exception handler is null"); } } @VisibleForTesting  MapboxUncaughtExceptionHanlder(@NonNull Context applicationContext,
                                 @NonNull SharedPreferences sharedPreferences,
                                 @NonNull String mapboxPackage,
                                 @NonNull String version,
                                 Thread.UncaughtExceptionHandler defaultExceptionHandler); }
MapboxUncaughtExceptionHanlder implements Thread.UncaughtExceptionHandler,
  SharedPreferences.OnSharedPreferenceChangeListener { @Override public void uncaughtException(Thread thread, Throwable throwable) { List<Throwable> causalChain; if (isEnabled.get() && isMapboxCrash(causalChain = getCausalChain(throwable))) { try { CrashReport report = CrashReportBuilder.setup(applicationContext, mapboxPackage, version) .addExceptionThread(thread) .addCausalChain(causalChain) .build(); ensureDirectoryWritable(applicationContext, mapboxPackage); File file = FileUtils.getFile(applicationContext, getReportFileName(mapboxPackage, report.getDateString())); FileUtils.writeToFile(file, report.toJson()); } catch (Exception ex) { Log.e(TAG, ex.toString()); } } if (defaultExceptionHandler != null) { defaultExceptionHandler.uncaughtException(thread, throwable); } else { Log.i(TAG, "Default exception handler is null"); } } @VisibleForTesting  MapboxUncaughtExceptionHanlder(@NonNull Context applicationContext,
                                 @NonNull SharedPreferences sharedPreferences,
                                 @NonNull String mapboxPackage,
                                 @NonNull String version,
                                 Thread.UncaughtExceptionHandler defaultExceptionHandler); static void install(@NonNull Context context, @NonNull String mapboxPackage, @NonNull String version); @Override void uncaughtException(Thread thread, Throwable throwable); @Override void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key); }
MapboxUncaughtExceptionHanlder implements Thread.UncaughtExceptionHandler,
  SharedPreferences.OnSharedPreferenceChangeListener { @Override public void uncaughtException(Thread thread, Throwable throwable) { List<Throwable> causalChain; if (isEnabled.get() && isMapboxCrash(causalChain = getCausalChain(throwable))) { try { CrashReport report = CrashReportBuilder.setup(applicationContext, mapboxPackage, version) .addExceptionThread(thread) .addCausalChain(causalChain) .build(); ensureDirectoryWritable(applicationContext, mapboxPackage); File file = FileUtils.getFile(applicationContext, getReportFileName(mapboxPackage, report.getDateString())); FileUtils.writeToFile(file, report.toJson()); } catch (Exception ex) { Log.e(TAG, ex.toString()); } } if (defaultExceptionHandler != null) { defaultExceptionHandler.uncaughtException(thread, throwable); } else { Log.i(TAG, "Default exception handler is null"); } } @VisibleForTesting  MapboxUncaughtExceptionHanlder(@NonNull Context applicationContext,
                                 @NonNull SharedPreferences sharedPreferences,
                                 @NonNull String mapboxPackage,
                                 @NonNull String version,
                                 Thread.UncaughtExceptionHandler defaultExceptionHandler); static void install(@NonNull Context context, @NonNull String mapboxPackage, @NonNull String version); @Override void uncaughtException(Thread thread, Throwable throwable); @Override void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key); static final String MAPBOX_PREF_ENABLE_CRASH_REPORTER; static final String MAPBOX_CRASH_REPORTER_PREFERENCES; }