Merge "Log the reason and tag for dropbox dropped entries." into tm-dev
This commit is contained in:
@@ -60,6 +60,7 @@ import com.android.internal.annotations.GuardedBy;
|
|||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.os.IDropBoxManagerService;
|
import com.android.internal.os.IDropBoxManagerService;
|
||||||
import com.android.internal.util.DumpUtils;
|
import com.android.internal.util.DumpUtils;
|
||||||
|
import com.android.internal.util.FrameworkStatsLog;
|
||||||
import com.android.internal.util.ObjectUtils;
|
import com.android.internal.util.ObjectUtils;
|
||||||
import com.android.server.DropBoxManagerInternal.EntrySource;
|
import com.android.server.DropBoxManagerInternal.EntrySource;
|
||||||
|
|
||||||
@@ -501,12 +502,20 @@ public final class DropBoxManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "Can't write: " + tag, e);
|
Slog.e(TAG, "Can't write: " + tag, e);
|
||||||
|
logDropboxDropped(
|
||||||
|
FrameworkStatsLog.DROPBOX_ENTRY_DROPPED__DROP_REASON__WRITE_FAILURE,
|
||||||
|
tag,
|
||||||
|
0);
|
||||||
} finally {
|
} finally {
|
||||||
IoUtils.closeQuietly(entry);
|
IoUtils.closeQuietly(entry);
|
||||||
if (temp != null) temp.delete();
|
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) {
|
public boolean isTagEnabled(String tag) {
|
||||||
final long token = Binder.clearCallingIdentity();
|
final long token = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
@@ -1119,13 +1128,19 @@ public final class DropBoxManagerService extends SystemService {
|
|||||||
Settings.Global.DROPBOX_MAX_FILES,
|
Settings.Global.DROPBOX_MAX_FILES,
|
||||||
(ActivityManager.isLowRamDeviceStatic()
|
(ActivityManager.isLowRamDeviceStatic()
|
||||||
? DEFAULT_MAX_FILES_LOWRAM : DEFAULT_MAX_FILES));
|
? 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()) {
|
while (!mAllFiles.contents.isEmpty()) {
|
||||||
EntryFile entry = mAllFiles.contents.first();
|
EntryFile entry = mAllFiles.contents.first();
|
||||||
if (entry.timestampMillis > cutoffMillis && mAllFiles.contents.size() < mMaxFiles) {
|
if (entry.timestampMillis > cutoffMillis && mAllFiles.contents.size() < mMaxFiles) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logDropboxDropped(
|
||||||
|
FrameworkStatsLog.DROPBOX_ENTRY_DROPPED__DROP_REASON__AGED,
|
||||||
|
entry.tag,
|
||||||
|
curTimeMillis - entry.timestampMillis);
|
||||||
|
|
||||||
FileList tag = mFilesByTag.get(entry.tag);
|
FileList tag = mFilesByTag.get(entry.tag);
|
||||||
if (tag != null && tag.contents.remove(entry)) tag.blocks -= entry.blocks;
|
if (tag != null && tag.contents.remove(entry)) tag.blocks -= entry.blocks;
|
||||||
if (mAllFiles.contents.remove(entry)) mAllFiles.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;
|
if (mAllFiles.blocks < mCachedQuotaBlocks) break;
|
||||||
while (tag.blocks > tagQuota && !tag.contents.isEmpty()) {
|
while (tag.blocks > tagQuota && !tag.contents.isEmpty()) {
|
||||||
EntryFile entry = tag.contents.first();
|
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 (tag.contents.remove(entry)) tag.blocks -= entry.blocks;
|
||||||
if (mAllFiles.contents.remove(entry)) mAllFiles.blocks -= entry.blocks;
|
if (mAllFiles.contents.remove(entry)) mAllFiles.blocks -= entry.blocks;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user