From 6639bb65c5ebb9493afba6d701a22223ac45ba04 Mon Sep 17 00:00:00 2001 From: Christian Sonntag Date: Thu, 13 Aug 2009 11:51:13 -0700 Subject: [PATCH] Add a more compact representation of usage stats. We are replaceing the package name in the activity name with a * iff the activity is in the same package, otherwise the activity name is pritned out in full. This small change will remove a lot of bytes (in the order of kilobytes for a real log) from the logged data on the network and downstream processing, since the package name is repeated in almost all cases. An exampe of the new format is here: DUMP OF SERVICE usagestats: D:4,20090813 P:com.android.launcher,4,155456 A:*.Launcher,4,0,0,0,0,0,0,0,0,0,2 P:com.android.browser,1,6724 A:*.BrowserActivity,1,0,0,0,0,0,0,0,0,0,0 A:*.CombinedBookmarkHistoryActivity,1,0,0,0,0,0,0,0,0,0,1 P:com.google.android.apps.maps,1,2219 A:com.google.android.maps.MapsActivity,1,0,0,0,0,0,0,0,0,0,0 P:com.android.contacts,1,0 A:*.DialtactsActivity,1,0,0,0,0,0,0,0,0,0,1 --- .../java/com/android/server/am/UsageStatsService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100755 => 100644 services/java/com/android/server/am/UsageStatsService.java diff --git a/services/java/com/android/server/am/UsageStatsService.java b/services/java/com/android/server/am/UsageStatsService.java old mode 100755 new mode 100644 index d4589118d0d7f..66868a387bca4 --- a/services/java/com/android/server/am/UsageStatsService.java +++ b/services/java/com/android/server/am/UsageStatsService.java @@ -695,7 +695,14 @@ public final class UsageStatsService extends IUsageStats.Stub { if (NC > 0) { for (Map.Entry ent : pus.mLaunchTimes.entrySet()) { sb.append("A:"); - sb.append(ent.getKey()); + String activity = ent.getKey(); + if (activity.startsWith(pkgName)) { + sb.append('*'); + sb.append(activity.substring( + pkgName.length(), activity.length())); + } else { + sb.append(activity); + } TimeStats times = ent.getValue(); sb.append(','); sb.append(times.count);