Use sharedUserId as package name if there are collisions

Per-UID Summary (cpu_time, % of total cpu_time, call_count, exception_count, package/uid):
    13095032  43%    44663   0 shared:com.package.shareduid/u0a35
     8872156  29%     5831   0 com.package2/u0a75
     2379684   8%     1549   0 com.package3/u0a23

Test: manual dumpsys binder_calls_stats
Test: BinderCallsStatsTest + BinderCallsStatsPerfTest
Bug: 75318418
Change-Id: I9b122252d8f8d3d2297bc71d46d5944c4402fd5e
This commit is contained in:
Fyodor Kupolov
2018-07-02 16:12:58 -07:00
parent 0c40911ee6
commit b270fc2201

View File

@@ -106,7 +106,13 @@ public class BinderCallsStatsService extends Binder {
}
Map<Integer,String> map = new HashMap<>();
for (PackageInfo pkg : packages) {
map.put(pkg.applicationInfo.uid, pkg.packageName);
String name = pkg.packageName;
int uid = pkg.applicationInfo.uid;
// Use sharedUserId string as package name if there are collisions
if (pkg.sharedUserId != null && map.containsKey(uid)) {
name = "shared:" + pkg.sharedUserId;
}
map.put(uid, name);
}
return map;
}