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

Commit 38dfae8c authored by Evan Chen's avatar Evan Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix adb command for multiple users" into sc-dev

parents 47aa9f15 10de883c
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -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());
@@ -646,7 +646,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                } else {
                    return association;
                }
            }));
            }), userId);

            restartBleScan();
        }
@@ -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 {
@@ -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) {
@@ -752,7 +753,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                onAssociationPreRemove(association);
            }
            return notMatch;
        }));
        }), userId);
        restartBleScan();
    }

@@ -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,
@@ -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;