Merge "Fix adb command for multiple users" into sc-dev am: 38dfae8c31
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15129761 Change-Id: I64fb56895fb9e5b2750c1b7aecc2b253ab8efadd
This commit is contained in:
@@ -455,7 +455,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
|
|
||||||
}, FgThread.getExecutor()).whenComplete(uncheckExceptions((association, err) -> {
|
}, FgThread.getExecutor()).whenComplete(uncheckExceptions((association, err) -> {
|
||||||
if (err == null) {
|
if (err == null) {
|
||||||
addAssociation(association);
|
addAssociation(association, userId);
|
||||||
} else {
|
} else {
|
||||||
Slog.e(LOG_TAG, "Failed to discover device(s)", err);
|
Slog.e(LOG_TAG, "Failed to discover device(s)", err);
|
||||||
callback.onFailure("No devices found: " + err.getMessage());
|
callback.onFailure("No devices found: " + err.getMessage());
|
||||||
@@ -646,7 +646,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
} else {
|
} else {
|
||||||
return association;
|
return association;
|
||||||
}
|
}
|
||||||
}));
|
}), userId);
|
||||||
|
|
||||||
restartBleScan();
|
restartBleScan();
|
||||||
}
|
}
|
||||||
@@ -664,7 +664,8 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
android.Manifest.permission.ASSOCIATE_COMPANION_DEVICES, "createAssociation");
|
android.Manifest.permission.ASSOCIATE_COMPANION_DEVICES, "createAssociation");
|
||||||
|
|
||||||
addAssociation(new Association(
|
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 {
|
private void checkCanCallNotificationApi(String callingPackage) throws RemoteException {
|
||||||
@@ -738,9 +739,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
return Binder.getCallingUid() == Process.SYSTEM_UID;
|
return Binder.getCallingUid() == Process.SYSTEM_UID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addAssociation(Association association) {
|
void addAssociation(Association association, int userId) {
|
||||||
updateSpecialAccessPermissionForAssociatedPackage(association);
|
updateSpecialAccessPermissionForAssociatedPackage(association);
|
||||||
recordAssociation(association);
|
recordAssociation(association, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeAssociation(int userId, String pkg, String deviceMacAddress) {
|
void removeAssociation(int userId, String pkg, String deviceMacAddress) {
|
||||||
@@ -752,7 +753,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
onAssociationPreRemove(association);
|
onAssociationPreRemove(association);
|
||||||
}
|
}
|
||||||
return notMatch;
|
return notMatch;
|
||||||
}));
|
}), userId);
|
||||||
restartBleScan();
|
restartBleScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -944,13 +945,9 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
}, getContext(), packageName, userId).recycleOnUse());
|
}, getContext(), packageName, userId).recycleOnUse());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recordAssociation(Association association) {
|
private void recordAssociation(Association association, int userId) {
|
||||||
Slog.i(LOG_TAG, "recordAssociation(" + association + ")");
|
Slog.i(LOG_TAG, "recordAssociation(" + association + ")");
|
||||||
updateAssociations(associations -> CollectionUtils.add(associations, association));
|
updateAssociations(associations -> CollectionUtils.add(associations, association), userId);
|
||||||
}
|
|
||||||
|
|
||||||
private void updateAssociations(Function<Set<Association>, Set<Association>> update) {
|
|
||||||
updateAssociations(update, getCallingUserId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAssociations(Function<Set<Association>, Set<Association>> update,
|
private void updateAssociations(Function<Set<Association>, Set<Association>> update,
|
||||||
@@ -1515,7 +1512,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
|
|||||||
String pkg = getNextArgRequired();
|
String pkg = getNextArgRequired();
|
||||||
String address = getNextArgRequired();
|
String address = getNextArgRequired();
|
||||||
addAssociation(new Association(userId, address, pkg, null, false,
|
addAssociation(new Association(userId, address, pkg, null, false,
|
||||||
System.currentTimeMillis()));
|
System.currentTimeMillis()), userId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user