From 9a05dd2eb5dc37a72ba2f60f578fec255af67646 Mon Sep 17 00:00:00 2001 From: Ethan_Hu Date: Tue, 23 Apr 2019 14:17:11 +0800 Subject: [PATCH] Catch the SQLiteFullException in NotificationUsageStats. Bug: 132688596 Test: writeEvent when disk is full. Change-Id: I42f1c528763e5297c720e93d0789f83b9929f15d Signed-off-by: Ethan_Hu --- .../server/notification/NotificationUsageStats.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationUsageStats.java b/services/core/java/com/android/server/notification/NotificationUsageStats.java index e40dad6e83f17..e839616079398 100644 --- a/services/core/java/com/android/server/notification/NotificationUsageStats.java +++ b/services/core/java/com/android/server/notification/NotificationUsageStats.java @@ -23,6 +23,7 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; +import android.database.sqlite.SQLiteFullException; import android.database.sqlite.SQLiteOpenHelper; import android.os.Handler; import android.os.HandlerThread; @@ -1265,9 +1266,13 @@ public class NotificationUsageStats { sNumWrites = 0; sLastPruneMs = nowMs; long horizonStartMs = nowMs - HORIZON_MS; - int deletedRows = db.delete(TAB_LOG, COL_EVENT_TIME + " < ?", - new String[] { String.valueOf(horizonStartMs) }); - Log.d(TAG, "Pruned event entries: " + deletedRows); + try { + int deletedRows = db.delete(TAB_LOG, COL_EVENT_TIME + " < ?", + new String[]{String.valueOf(horizonStartMs)}); + Log.d(TAG, "Pruned event entries: " + deletedRows); + } catch (SQLiteFullException e) { + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + } } }