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
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 d458911..66868a3
--- a/services/java/com/android/server/am/UsageStatsService.java
+++ b/services/java/com/android/server/am/UsageStatsService.java
@@ -695,7 +695,14 @@
if (NC > 0) {
for (Map.Entry<String, TimeStats> 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);