Skip to content

Commit 4b49657

Browse files
committed
Log when /cache files are deleted.
Bug: 6362988 Change-Id: Ib8497453c45612be5b83035eeaf3abe6d716ccbf
1 parent 1b96594 commit 4b49657

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

services/java/com/android/server/DeviceStorageMonitorService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.content.pm.IPackageManager;
2727
import android.os.Binder;
2828
import android.os.Environment;
29+
import android.os.FileObserver;
2930
import android.os.Handler;
3031
import android.os.Message;
3132
import android.os.Process;
@@ -91,6 +92,7 @@ public class DeviceStorageMonitorService extends Binder {
9192
private Intent mStorageFullIntent;
9293
private Intent mStorageNotFullIntent;
9394
private CachePackageDataObserver mClearCacheObserver;
95+
private final CacheFileDeletedObserver mCacheFileDeletedObserver;
9496
private static final int _TRUE = 1;
9597
private static final int _FALSE = 0;
9698
private long mMemLowThreshold;
@@ -324,6 +326,9 @@ public DeviceStorageMonitorService(Context context) {
324326
mMemLowThreshold = getMemThreshold();
325327
mMemFullThreshold = getMemFullThreshold();
326328
checkMemory(true);
329+
330+
mCacheFileDeletedObserver = new CacheFileDeletedObserver();
331+
mCacheFileDeletedObserver.startWatching();
327332
}
328333

329334

@@ -419,4 +424,15 @@ public long getMemoryLowThreshold() {
419424
public boolean isMemoryLow() {
420425
return mLowMemFlag;
421426
}
427+
428+
public static class CacheFileDeletedObserver extends FileObserver {
429+
public CacheFileDeletedObserver() {
430+
super(Environment.getDownloadCacheDirectory().getAbsolutePath(), FileObserver.DELETE);
431+
}
432+
433+
@Override
434+
public void onEvent(int event, String path) {
435+
EventLogTags.writeCacheFileDeleted(path);
436+
}
437+
}
422438
}

services/java/com/android/server/EventLogTags.logtags

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ option java_package com.android.server
3636

3737

3838
# ---------------------------
39-
# DeviceStorageMonitoryService.java
39+
# DeviceStorageMonitorService.java
4040
# ---------------------------
4141
# The disk space free on the /data partition, in bytes
4242
2744 free_storage_changed (data|2|2)
4343
# Device low memory notification and disk space free on the /data partition, in bytes at that time
4444
2745 low_storage (data|2|2)
4545
# disk space free on the /data, /system, and /cache partitions in bytes
4646
2746 free_storage_left (data|2|2),(system|2|2),(cache|2|2)
47+
# file on cache partition was deleted
48+
2748 cache_file_deleted (path|3)
4749

4850

4951
# ---------------------------

0 commit comments

Comments
 (0)