Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6639bb65 authored by Christian Sonntag's avatar Christian Sonntag Committed by Christian Sonntag
Browse files

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
parent 0867e691
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -695,7 +695,14 @@ public final class UsageStatsService extends IUsageStats.Stub {
                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);