Log the reason and tag for dropbox dropped entries.

Test: manual
Bug: 215516219
Change-Id: Ia427df02ef53b09852298d0d5b29414562efe96c
This commit is contained in:
Siim Sammul
2022-03-14 10:30:46 +00:00
parent fdf328c2b5
commit d9249c2b5e

View File

@@ -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;