Fixed forced crash reports

pull/215/head
M66B 1 year ago
parent a12a69ac6d
commit 254ea82a41

@ -420,8 +420,7 @@ public abstract class DB extends RoomDatabase {
Log.i("Disabled view invalidation");
} catch (ReflectiveOperationException ex) {
// Should never happen
Log.forceCrashReporting();
Log.e(ex);
Log.forceCrashReport(context, ex);
}
sInstance.getInvalidationTracker().addObserver(new InvalidationTracker.Observer(DB_TABLES) {
@ -462,8 +461,7 @@ public abstract class DB extends RoomDatabase {
}
} catch (Throwable ex) {
// Should never happen
Log.forceCrashReporting();
Log.e(ex);
Log.forceCrashReport(context, ex);
}
Log.i("DB critical section end");
}
@ -589,8 +587,7 @@ public abstract class DB extends RoomDatabase {
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:706)
*/
// Should never happen
Log.forceCrashReporting();
Log.e(ex);
Log.forceCrashReport(context, ex);
// FrameworkSQLiteOpenHelper.innerGetDatabase will delete the database
throw ex;
}

@ -312,14 +312,25 @@ public class Log {
static void setCrashReporting(boolean enabled) {
try {
if (enabled)
Bugsnag.startSession();
Bugsnag.resumeSession();
else
Bugsnag.pauseSession();
} catch (Throwable ex) {
Log.i(ex);
}
}
static void forceCrashReporting() {
Bugsnag.resumeSession();
static void forceCrashReport(Context context, Throwable fatal) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean crash_reports = prefs.getBoolean("crash_reports", false);
try {
prefs.edit().putBoolean("crash_reports", true).apply();
setCrashReporting(true);
Log.e(fatal);
} finally {
prefs.edit().putBoolean("crash_reports", crash_reports).apply();
setCrashReporting(crash_reports);
}
}
public static void breadcrumb(String name, Bundle args) {

Loading…
Cancel
Save