private List<App> mApps = new ArrayList<App>();
/** Internal map to keep track of logging information by app name */
- HashMap<String, AppScanStats> mAppScanStats = new HashMap<String, AppScanStats>();
+ HashMap<Integer, AppScanStats> mAppScanStats = new HashMap<Integer, AppScanStats>();
/** Internal list of connected devices **/
Set<Connection> mConnections = new HashSet<Connection>();
* Add an entry to the application context list.
*/
void add(UUID uuid, WorkSource workSource, C callback, T info, GattService service) {
- String appName = service.getPackageManager().getNameForUid(
- Binder.getCallingUid());
+ int appUid = Binder.getCallingUid();
+ String appName = service.getPackageManager().getNameForUid(appUid);
if (appName == null) {
// Assign an app name if one isn't found
- appName = "Unknown App (UID: " + Binder.getCallingUid() + ")";
+ appName = "Unknown App (UID: " + appUid + ")";
}
synchronized (mApps) {
- AppScanStats appScanStats = mAppScanStats.get(appName);
+ AppScanStats appScanStats = mAppScanStats.get(appUid);
if (appScanStats == null) {
appScanStats = new AppScanStats(appName, workSource, this, service);
- mAppScanStats.put(appName, appScanStats);
+ mAppScanStats.put(appUid, appScanStats);
}
mApps.add(new App(uuid, callback, info, appName, appScanStats));
appScanStats.isRegistered = true;
}
/**
- * Get Logging info by application name
+ * Get Logging info by application UID
*/
- AppScanStats getAppScanStatsByName(String name) {
- return mAppScanStats.get(name);
+ AppScanStats getAppScanStatsByUid(int uid) {
+ return mAppScanStats.get(uid);
}
/**
void dump(StringBuilder sb) {
sb.append(" Entries: " + mAppScanStats.size() + "\n\n");
- Iterator<Map.Entry<String, AppScanStats>> it = mAppScanStats.entrySet().iterator();
+ Iterator<Map.Entry<Integer, AppScanStats>> it = mAppScanStats.entrySet().iterator();
while (it.hasNext()) {
- Map.Entry<String, AppScanStats> entry = it.next();
+ Map.Entry<Integer, AppScanStats> entry = it.next();
- String name = entry.getKey();
AppScanStats appScanStats = entry.getValue();
appScanStats.dumpToString(sb);
}