diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-03-02 22:23:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-02 22:23:44 +0000 |
commit | f55187767ed06acd52ddbc0e8de19b4d69db97bd (patch) | |
tree | c16046853ea6d7c7e19a05ce8e054aa2a2cab394 /services/usage/java/com/android/server | |
parent | a4005662c7a22b457a6db092426f16b240902732 (diff) | |
parent | 3a0831bfe6e69a2ad11b9f6fae04fb27daa40a88 (diff) | |
download | frameworks_base-f55187767ed06acd52ddbc0e8de19b4d69db97bd.zip frameworks_base-f55187767ed06acd52ddbc0e8de19b4d69db97bd.tar.gz frameworks_base-f55187767ed06acd52ddbc0e8de19b4d69db97bd.tar.bz2 |
Merge "Fix issue where pruned UsageStats files would not be removed from index"
Diffstat (limited to 'services/usage/java/com/android/server')
-rw-r--r-- | services/usage/java/com/android/server/usage/UsageStatsDatabase.java | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/services/usage/java/com/android/server/usage/UsageStatsDatabase.java b/services/usage/java/com/android/server/usage/UsageStatsDatabase.java index 26ced03..235567c 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsDatabase.java +++ b/services/usage/java/com/android/server/usage/UsageStatsDatabase.java @@ -378,26 +378,27 @@ class UsageStatsDatabase { } } - try { - IntervalStats stats = new IntervalStats(); - ArrayList<T> results = new ArrayList<>(); - for (int i = startIndex; i <= endIndex; i++) { - final AtomicFile f = intervalStats.valueAt(i); + final IntervalStats stats = new IntervalStats(); + final ArrayList<T> results = new ArrayList<>(); + for (int i = startIndex; i <= endIndex; i++) { + final AtomicFile f = intervalStats.valueAt(i); - if (DEBUG) { - Slog.d(TAG, "Reading stat file " + f.getBaseFile().getAbsolutePath()); - } + if (DEBUG) { + Slog.d(TAG, "Reading stat file " + f.getBaseFile().getAbsolutePath()); + } + try { UsageStatsXml.read(f, stats); if (beginTime < stats.endTime) { combiner.combine(stats, false, results); } + } catch (IOException e) { + Slog.e(TAG, "Failed to read usage stats file", e); + // We continue so that we return results that are not + // corrupt. } - return results; - } catch (IOException e) { - Slog.e(TAG, "Failed to read usage stats file", e); - return null; } + return results; } } @@ -450,6 +451,10 @@ class UsageStatsDatabase { mCal.addDays(-7); pruneFilesOlderThan(mIntervalDirs[UsageStatsManager.INTERVAL_DAILY], mCal.getTimeInMillis()); + + // We must re-index our file list or we will be trying to read + // deleted files. + indexFilesLocked(); } } |