diff --git a/services/core/java/com/android/server/DropBoxManagerService.java b/services/core/java/com/android/server/DropBoxManagerService.java index a2a232d6f3ec4..1d457aa933d77 100644 --- a/services/core/java/com/android/server/DropBoxManagerService.java +++ b/services/core/java/com/android/server/DropBoxManagerService.java @@ -60,6 +60,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.os.IDropBoxManagerService; import com.android.internal.util.DumpUtils; +import com.android.internal.util.FrameworkStatsLog; import com.android.internal.util.ObjectUtils; import com.android.server.DropBoxManagerInternal.EntrySource; @@ -501,12 +502,20 @@ public final class DropBoxManagerService extends SystemService { } } catch (IOException e) { Slog.e(TAG, "Can't write: " + tag, e); + logDropboxDropped( + FrameworkStatsLog.DROPBOX_ENTRY_DROPPED__DROP_REASON__WRITE_FAILURE, + tag, + 0); } finally { IoUtils.closeQuietly(entry); if (temp != null) temp.delete(); } } + private void logDropboxDropped(int reason, String tag, long entryAge) { + FrameworkStatsLog.write(FrameworkStatsLog.DROPBOX_ENTRY_DROPPED, reason, tag, entryAge); + } + public boolean isTagEnabled(String tag) { final long token = Binder.clearCallingIdentity(); try { @@ -1119,13 +1128,19 @@ public final class DropBoxManagerService extends SystemService { Settings.Global.DROPBOX_MAX_FILES, (ActivityManager.isLowRamDeviceStatic() ? DEFAULT_MAX_FILES_LOWRAM : DEFAULT_MAX_FILES)); - long cutoffMillis = System.currentTimeMillis() - ageSeconds * 1000; + long curTimeMillis = System.currentTimeMillis(); + long cutoffMillis = curTimeMillis - ageSeconds * 1000; while (!mAllFiles.contents.isEmpty()) { EntryFile entry = mAllFiles.contents.first(); if (entry.timestampMillis > cutoffMillis && mAllFiles.contents.size() < mMaxFiles) { break; } + logDropboxDropped( + FrameworkStatsLog.DROPBOX_ENTRY_DROPPED__DROP_REASON__AGED, + entry.tag, + curTimeMillis - entry.timestampMillis); + FileList tag = mFilesByTag.get(entry.tag); if (tag != null && tag.contents.remove(entry)) tag.blocks -= entry.blocks; if (mAllFiles.contents.remove(entry)) mAllFiles.blocks -= entry.blocks; @@ -1194,6 +1209,11 @@ public final class DropBoxManagerService extends SystemService { if (mAllFiles.blocks < mCachedQuotaBlocks) break; while (tag.blocks > tagQuota && !tag.contents.isEmpty()) { EntryFile entry = tag.contents.first(); + logDropboxDropped( + FrameworkStatsLog.DROPBOX_ENTRY_DROPPED__DROP_REASON__CLEARING_DATA, + entry.tag, + curTimeMillis - entry.timestampMillis); + if (tag.contents.remove(entry)) tag.blocks -= entry.blocks; if (mAllFiles.contents.remove(entry)) mAllFiles.blocks -= entry.blocks;