Loading services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +10 −13 Original line number Diff line number Diff line Loading @@ -455,7 +455,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind }, FgThread.getExecutor()).whenComplete(uncheckExceptions((association, err) -> { if (err == null) { addAssociation(association); addAssociation(association, userId); } else { Slog.e(LOG_TAG, "Failed to discover device(s)", err); callback.onFailure("No devices found: " + err.getMessage()); Loading Loading @@ -646,7 +646,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind } else { return association; } })); }), userId); restartBleScan(); } Loading @@ -664,7 +664,8 @@ public class CompanionDeviceManagerService extends SystemService implements Bind android.Manifest.permission.ASSOCIATE_COMPANION_DEVICES, "createAssociation"); addAssociation(new Association( userId, macAddress, packageName, null, false, System.currentTimeMillis())); userId, macAddress, packageName, null, false, System.currentTimeMillis()), userId); } private void checkCanCallNotificationApi(String callingPackage) throws RemoteException { Loading Loading @@ -738,9 +739,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind return Binder.getCallingUid() == Process.SYSTEM_UID; } void addAssociation(Association association) { void addAssociation(Association association, int userId) { updateSpecialAccessPermissionForAssociatedPackage(association); recordAssociation(association); recordAssociation(association, userId); } void removeAssociation(int userId, String pkg, String deviceMacAddress) { Loading @@ -752,7 +753,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind onAssociationPreRemove(association); } return notMatch; })); }), userId); restartBleScan(); } Loading Loading @@ -944,13 +945,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind }, getContext(), packageName, userId).recycleOnUse()); } private void recordAssociation(Association association) { private void recordAssociation(Association association, int userId) { Slog.i(LOG_TAG, "recordAssociation(" + association + ")"); updateAssociations(associations -> CollectionUtils.add(associations, association)); } private void updateAssociations(Function<Set<Association>, Set<Association>> update) { updateAssociations(update, getCallingUserId()); updateAssociations(associations -> CollectionUtils.add(associations, association), userId); } private void updateAssociations(Function<Set<Association>, Set<Association>> update, Loading Loading @@ -1515,7 +1512,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind String pkg = getNextArgRequired(); String address = getNextArgRequired(); addAssociation(new Association(userId, address, pkg, null, false, System.currentTimeMillis())); System.currentTimeMillis()), userId); } break; Loading Loading
services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +10 −13 Original line number Diff line number Diff line Loading @@ -455,7 +455,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind }, FgThread.getExecutor()).whenComplete(uncheckExceptions((association, err) -> { if (err == null) { addAssociation(association); addAssociation(association, userId); } else { Slog.e(LOG_TAG, "Failed to discover device(s)", err); callback.onFailure("No devices found: " + err.getMessage()); Loading Loading @@ -646,7 +646,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind } else { return association; } })); }), userId); restartBleScan(); } Loading @@ -664,7 +664,8 @@ public class CompanionDeviceManagerService extends SystemService implements Bind android.Manifest.permission.ASSOCIATE_COMPANION_DEVICES, "createAssociation"); addAssociation(new Association( userId, macAddress, packageName, null, false, System.currentTimeMillis())); userId, macAddress, packageName, null, false, System.currentTimeMillis()), userId); } private void checkCanCallNotificationApi(String callingPackage) throws RemoteException { Loading Loading @@ -738,9 +739,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind return Binder.getCallingUid() == Process.SYSTEM_UID; } void addAssociation(Association association) { void addAssociation(Association association, int userId) { updateSpecialAccessPermissionForAssociatedPackage(association); recordAssociation(association); recordAssociation(association, userId); } void removeAssociation(int userId, String pkg, String deviceMacAddress) { Loading @@ -752,7 +753,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind onAssociationPreRemove(association); } return notMatch; })); }), userId); restartBleScan(); } Loading Loading @@ -944,13 +945,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind }, getContext(), packageName, userId).recycleOnUse()); } private void recordAssociation(Association association) { private void recordAssociation(Association association, int userId) { Slog.i(LOG_TAG, "recordAssociation(" + association + ")"); updateAssociations(associations -> CollectionUtils.add(associations, association)); } private void updateAssociations(Function<Set<Association>, Set<Association>> update) { updateAssociations(update, getCallingUserId()); updateAssociations(associations -> CollectionUtils.add(associations, association), userId); } private void updateAssociations(Function<Set<Association>, Set<Association>> update, Loading Loading @@ -1515,7 +1512,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind String pkg = getNextArgRequired(); String address = getNextArgRequired(); addAssociation(new Association(userId, address, pkg, null, false, System.currentTimeMillis())); System.currentTimeMillis()), userId); } break; Loading