summaryrefslogtreecommitdiffstats
path: root/services/usage
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-03-02 22:23:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-02 22:23:44 +0000
commitf55187767ed06acd52ddbc0e8de19b4d69db97bd (patch)
treec16046853ea6d7c7e19a05ce8e054aa2a2cab394 /services/usage
parenta4005662c7a22b457a6db092426f16b240902732 (diff)
parent3a0831bfe6e69a2ad11b9f6fae04fb27daa40a88 (diff)
downloadframeworks_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')
-rw-r--r--services/usage/java/com/android/server/usage/UsageStatsDatabase.java29
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();
}
}