Delete files properly when history disabled

Delete the files, then the directory

Test: turn history off, check folder on device
Bug: 137396965
Change-Id: Ic69adf6d08219cab186c131147192f5d1ea1ee91
This commit is contained in:
Julia Reynolds
2020-02-10 14:19:42 -05:00
parent e6fed50a1d
commit 004d45a945

View File

@@ -231,6 +231,9 @@ public class NotificationHistoryDatabase {
public void disableHistory() {
synchronized (mLock) {
for (AtomicFile file : mHistoryFiles) {
file.delete();
}
mHistoryDir.delete();
mHistoryFiles.clear();
}
@@ -249,6 +252,10 @@ public class NotificationHistoryDatabase {
final AtomicFile currentOldestFile = mHistoryFiles.get(i);
final long creationTime =
mFileAttrProvider.getCreationTime(currentOldestFile.getBaseFile());
if (DEBUG) {
Slog.d(TAG, "Pruning " + currentOldestFile.getBaseFile().getName()
+ " created on " + creationTime);
}
if (creationTime <= retentionBoundary.getTimeInMillis()) {
if (DEBUG) {
Slog.d(TAG, "Removed " + currentOldestFile.getBaseFile().getName());