diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java b/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java index 102bc770f7..4f44dc1358 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java +++ b/app/src/main/java/org/thoughtcrime/securesms/util/SignalUncaughtExceptionHandler.java @@ -1,10 +1,14 @@ package org.thoughtcrime.securesms.util; +import android.database.sqlite.SQLiteDatabaseCorruptException; + import androidx.annotation.NonNull; import org.signal.core.util.ExceptionUtil; import org.signal.core.util.logging.Log; import org.thoughtcrime.securesms.database.LogDatabase; +import org.thoughtcrime.securesms.database.SearchTable; +import org.thoughtcrime.securesms.database.SignalDatabase; import org.thoughtcrime.securesms.dependencies.ApplicationDependencies; import org.thoughtcrime.securesms.keyvalue.SignalStore; @@ -36,6 +40,15 @@ public class SignalUncaughtExceptionHandler implements Thread.UncaughtExceptionH return; } + if (e instanceof SQLiteDatabaseCorruptException) { + if (e.getMessage().indexOf("message_fts") >= 0) { + Log.w(TAG, "FTS corrupted! Resetting FTS index."); + SignalDatabase.messageSearch().fullyResetTables(); + } else { + Log.w(TAG, "Some non-FTS related corruption?"); + } + } + if (e instanceof OnErrorNotImplementedException && e.getCause() != null) { e = e.getCause(); }