diff options
author | 2025-02-19 13:35:56 -0800 | |
---|---|---|
committer | 2025-02-21 07:01:54 -0800 | |
commit | 51cf245d2dd2ce4e2d8412d3576b1f370d07695f (patch) | |
tree | fc57e2323c39c39da55197dc88acb697df89143e | |
parent | c1794771c418f0ac540b08f7d2a5054aa739763c (diff) |
Catch and log NetworkWatchlist database corruption
This appears rare, but better to catch and log than throw.
Bug: 374361309
Change-Id: I6dedd14bcd2266c18c0dc7e991d75da573554b66
Test: N/A
Flag: EXEMPT simple bug fix
-rw-r--r-- | services/core/java/com/android/server/net/watchlist/WatchlistReportDbHelper.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/net/watchlist/WatchlistReportDbHelper.java b/services/core/java/com/android/server/net/watchlist/WatchlistReportDbHelper.java index 7a96195528d5..993704988d86 100644 --- a/services/core/java/com/android/server/net/watchlist/WatchlistReportDbHelper.java +++ b/services/core/java/com/android/server/net/watchlist/WatchlistReportDbHelper.java @@ -21,6 +21,7 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteDatabaseCorruptException; import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteOpenHelper; import android.os.Environment; @@ -204,6 +205,11 @@ class WatchlistReportDbHelper extends SQLiteOpenHelper { return false; } final String clause = WhiteListReportContract.TIMESTAMP + "< " + untilTimestamp; - return db.delete(WhiteListReportContract.TABLE, clause, null) != 0; + try { + return db.delete(WhiteListReportContract.TABLE, clause, null) != 0; + } catch (SQLiteDatabaseCorruptException e) { + Slog.e(TAG, "Error deleting records", e); + return false; + } } } |