Loading core/java/android/app/usage/EventList.java +14 −0 Original line number Diff line number Diff line Loading @@ -103,4 +103,18 @@ public class EventList { } return result; } /** * Merge the {@link UsageEvents.Event events} in the given {@link EventList list} into this * list while keeping the list sorted based on the event {@link * UsageEvents.Event#mTimeStamp timestamps}. * * @param events The event list to merge */ public void merge(EventList events) { final int size = events.size(); for (int i = 0; i < size; i++) { insert(events.get(i)); } } } services/usage/java/com/android/server/usage/IntervalStats.java +11 −5 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ public class IntervalStats { public final ArrayMap<String, UsageStats> packageStats = new ArrayMap<>(); public final ArrayMap<Configuration, ConfigurationStats> configurations = new ArrayMap<>(); public Configuration activeConfiguration; public EventList events = new EventList(); public final EventList events = new EventList(); // A string cache. This is important as when we're parsing XML files, we don't want to // keep hundreds of strings that have the same contents. We will read the string Loading @@ -82,7 +82,7 @@ public class IntervalStats { public void commitTime(long timeStamp) { if (curStartTime != 0) { duration += timeStamp - duration; duration += timeStamp - curStartTime; curStartTime = 0; } } Loading Loading @@ -305,8 +305,10 @@ public class IntervalStats { UsageStats usageStats = getOrCreateUsageStats(packageName); usageStats.update(className, timeStamp, eventType, instanceId); } if (timeStamp > endTime) { endTime = timeStamp; } } /** * @hide Loading @@ -328,6 +330,9 @@ public class IntervalStats { event.mNotificationChannelId = getCachedStringRef(event.mNotificationChannelId); } events.insert(event); if (event.mTimeStamp > endTime) { endTime = event.mTimeStamp; } } void updateChooserCounts(String packageName, String category, String action) { Loading Loading @@ -360,9 +365,10 @@ public class IntervalStats { configStats.mActivationCount += 1; activeConfiguration = configStats.mConfiguration; } if (timeStamp > endTime) { endTime = timeStamp; } } void incrementAppLaunchCount(String packageName) { UsageStats usageStats = getOrCreateUsageStats(packageName); Loading services/usage/java/com/android/server/usage/UsageStatsDatabase.java +2 −1 Original line number Diff line number Diff line Loading @@ -1166,7 +1166,8 @@ public class UsageStatsDatabase { if (beingRestored == null) return null; beingRestored.activeConfiguration = onDevice.activeConfiguration; beingRestored.configurations.putAll(onDevice.configurations); beingRestored.events = onDevice.events; beingRestored.events.clear(); beingRestored.events.merge(onDevice.events); return beingRestored; } Loading services/usage/java/com/android/server/usage/UserUsageStatsService.java +1 −1 Original line number Diff line number Diff line Loading @@ -334,7 +334,7 @@ class UserUsageStatsService { final IntervalStats diskStats = mDatabase.getLatestUsageStats( INTERVAL_DAILY); StringBuilder sb = new StringBuilder(256); sb.append("Last 24 hours of UsageStats missing! timeRange : "); sb.append("Recent UsageStats missing! timeRange : "); sb.append(beginTime); sb.append(", "); sb.append(endTime); Loading Loading
core/java/android/app/usage/EventList.java +14 −0 Original line number Diff line number Diff line Loading @@ -103,4 +103,18 @@ public class EventList { } return result; } /** * Merge the {@link UsageEvents.Event events} in the given {@link EventList list} into this * list while keeping the list sorted based on the event {@link * UsageEvents.Event#mTimeStamp timestamps}. * * @param events The event list to merge */ public void merge(EventList events) { final int size = events.size(); for (int i = 0; i < size; i++) { insert(events.get(i)); } } }
services/usage/java/com/android/server/usage/IntervalStats.java +11 −5 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ public class IntervalStats { public final ArrayMap<String, UsageStats> packageStats = new ArrayMap<>(); public final ArrayMap<Configuration, ConfigurationStats> configurations = new ArrayMap<>(); public Configuration activeConfiguration; public EventList events = new EventList(); public final EventList events = new EventList(); // A string cache. This is important as when we're parsing XML files, we don't want to // keep hundreds of strings that have the same contents. We will read the string Loading @@ -82,7 +82,7 @@ public class IntervalStats { public void commitTime(long timeStamp) { if (curStartTime != 0) { duration += timeStamp - duration; duration += timeStamp - curStartTime; curStartTime = 0; } } Loading Loading @@ -305,8 +305,10 @@ public class IntervalStats { UsageStats usageStats = getOrCreateUsageStats(packageName); usageStats.update(className, timeStamp, eventType, instanceId); } if (timeStamp > endTime) { endTime = timeStamp; } } /** * @hide Loading @@ -328,6 +330,9 @@ public class IntervalStats { event.mNotificationChannelId = getCachedStringRef(event.mNotificationChannelId); } events.insert(event); if (event.mTimeStamp > endTime) { endTime = event.mTimeStamp; } } void updateChooserCounts(String packageName, String category, String action) { Loading Loading @@ -360,9 +365,10 @@ public class IntervalStats { configStats.mActivationCount += 1; activeConfiguration = configStats.mConfiguration; } if (timeStamp > endTime) { endTime = timeStamp; } } void incrementAppLaunchCount(String packageName) { UsageStats usageStats = getOrCreateUsageStats(packageName); Loading
services/usage/java/com/android/server/usage/UsageStatsDatabase.java +2 −1 Original line number Diff line number Diff line Loading @@ -1166,7 +1166,8 @@ public class UsageStatsDatabase { if (beingRestored == null) return null; beingRestored.activeConfiguration = onDevice.activeConfiguration; beingRestored.configurations.putAll(onDevice.configurations); beingRestored.events = onDevice.events; beingRestored.events.clear(); beingRestored.events.merge(onDevice.events); return beingRestored; } Loading
services/usage/java/com/android/server/usage/UserUsageStatsService.java +1 −1 Original line number Diff line number Diff line Loading @@ -334,7 +334,7 @@ class UserUsageStatsService { final IntervalStats diskStats = mDatabase.getLatestUsageStats( INTERVAL_DAILY); StringBuilder sb = new StringBuilder(256); sb.append("Last 24 hours of UsageStats missing! timeRange : "); sb.append("Recent UsageStats missing! timeRange : "); sb.append(beginTime); sb.append(", "); sb.append(endTime); Loading