Skip to content

Commit

Permalink
base: Reduce NotificationHistoryDatabase logspam
Browse files Browse the repository at this point in the history
If the file is not there, we do not need the whole stacktrace.

Change-Id: Ie727f678b72940f05d2c485f5ff43f4567415fb2
  • Loading branch information
SpiritCroc authored and Undying-yueyue committed Feb 27, 2022
1 parent d2f5db6 commit 21706a4
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ public NotificationHistory readNotificationHistory() {
try {
readLocked(
file, notifications, new NotificationHistoryFilter.Builder().build());
} catch (FileNotFoundException e) {
Slog.e(TAG, "error reading " + file.getBaseFile().getAbsolutePath() + ", " + e);
} catch (Exception e) {
Slog.e(TAG, "error reading " + file.getBaseFile().getAbsolutePath(), e);
}
Expand All @@ -225,6 +227,8 @@ public NotificationHistory readNotificationHistory(String packageName, String ch
// No need to read any more files
break;
}
} catch (FileNotFoundException e) {
Slog.e(TAG, "error reading " + file.getBaseFile().getAbsolutePath() + ", " + e);
} catch (Exception e) {
Slog.e(TAG, "error reading " + file.getBaseFile().getAbsolutePath(), e);
}
Expand Down Expand Up @@ -345,7 +349,7 @@ private static void readLocked(AtomicFile file, NotificationHistory notification
in = file.openRead();
NotificationHistoryProtoHelper.read(in, notificationsOut, filter);
} catch (FileNotFoundException e) {
Slog.e(TAG, "Cannot open " + file.getBaseFile().getAbsolutePath(), e);
Slog.e(TAG, "Cannot open " + file.getBaseFile().getAbsolutePath() + ", " + e);
throw e;
} finally {
if (in != null) {
Expand Down Expand Up @@ -438,6 +442,9 @@ public void run() {
new NotificationHistoryFilter.Builder().build());
notifications.removeNotificationsFromWrite(mPkg);
writeLocked(af, notifications);
} catch (FileNotFoundException e) {
Slog.e(TAG, "Cannot clean up file on pkg removal "
+ af.getBaseFile().getAbsolutePath() + ", " + e);
} catch (Exception e) {
Slog.e(TAG, "Cannot clean up file on pkg removal "
+ af.getBaseFile().getAbsolutePath(), e);
Expand Down Expand Up @@ -481,6 +488,9 @@ public void run() {
if(notificationHistory.removeNotificationFromWrite(mPkg, mPostedTime)) {
writeLocked(af, notificationHistory);
}
} catch (FileNotFoundException e) {
Slog.e(TAG, "Cannot clean up file on notification removal "
+ af.getBaseFile().getName() + ", " + e);
} catch (Exception e) {
Slog.e(TAG, "Cannot clean up file on notification removal "
+ af.getBaseFile().getName(), e);
Expand Down Expand Up @@ -525,6 +535,9 @@ public void run() {
mPkg, mConversationIds)) {
writeLocked(af, notificationHistory);
}
} catch (FileNotFoundException e) {
Slog.e(TAG, "Cannot clean up file on conversation removal "
+ af.getBaseFile().getName() + ", " + e);
} catch (Exception e) {
Slog.e(TAG, "Cannot clean up file on conversation removal "
+ af.getBaseFile().getName(), e);
Expand Down

0 comments on commit 21706a4

Please sign in to comment.