diff options
| author | Adam Lesinski <adamlesinski@google.com> | 2015-07-23 01:01:22 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-23 01:01:22 +0000 |
| commit | f90ed330a0c7f54b963ef651a53be946f6d463ce (patch) | |
| tree | 51582f340134cbf9bc32f5e40b20e7ba2efc9def | |
| parent | 4a368659baf8f86b522a6b2679bb2b2a9fd0a997 (diff) | |
| parent | 2dfb91412c27581d27b7eba172912d2893d69abe (diff) | |
| download | frameworks_base-f90ed330a0c7f54b963ef651a53be946f6d463ce.zip frameworks_base-f90ed330a0c7f54b963ef651a53be946f6d463ce.tar.gz frameworks_base-f90ed330a0c7f54b963ef651a53be946f6d463ce.tar.bz2 | |
Merge "UsageStats: Reduce log spam during time change" into mnc-dev
| -rw-r--r-- | services/usage/java/com/android/server/usage/UsageStatsDatabase.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/services/usage/java/com/android/server/usage/UsageStatsDatabase.java b/services/usage/java/com/android/server/usage/UsageStatsDatabase.java index 0a7091e..f8ae03f 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsDatabase.java +++ b/services/usage/java/com/android/server/usage/UsageStatsDatabase.java @@ -21,6 +21,7 @@ import android.app.usage.UsageStatsManager; import android.os.Build; import android.util.AtomicFile; import android.util.Slog; +import android.util.TimeUtils; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -277,14 +278,21 @@ class UsageStatsDatabase { public void onTimeChanged(long timeDiffMillis) { synchronized (mLock) { + StringBuilder logBuilder = new StringBuilder(); + logBuilder.append("Time changed by "); + TimeUtils.formatDuration(timeDiffMillis, logBuilder); + logBuilder.append("."); + + int filesDeleted = 0; + int filesMoved = 0; + for (TimeSparseArray<AtomicFile> files : mSortedStatFiles) { final int fileCount = files.size(); for (int i = 0; i < fileCount; i++) { final AtomicFile file = files.valueAt(i); final long newTime = files.keyAt(i) + timeDiffMillis; if (newTime < 0) { - Slog.i(TAG, "Deleting file " + file.getBaseFile().getAbsolutePath() - + " for it is in the future now."); + filesDeleted++; file.delete(); } else { try { @@ -299,14 +307,17 @@ class UsageStatsDatabase { } final File newFile = new File(file.getBaseFile().getParentFile(), newName); - Slog.i(TAG, "Moving file " + file.getBaseFile().getAbsolutePath() + " to " - + newFile.getAbsolutePath()); + filesMoved++; file.getBaseFile().renameTo(newFile); } } files.clear(); } + logBuilder.append(" files deleted: ").append(filesDeleted); + logBuilder.append(" files moved: ").append(filesMoved); + Slog.i(TAG, logBuilder.toString()); + // Now re-index the new files. indexFilesLocked(); } |
