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

Commit e3bd4fa0 authored by Evan Chen's avatar Evan Chen Committed by Automerger Merge Worker
Browse files

Merge "Fix adb command for multiple users" into sc-dev am: 38dfae8c am: 76c037c3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15129761

Change-Id: Ie11df986676e283fe9179aa0caf0fb06850e34fe
parents 78afc54f 76c037c3
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -463,7 +463,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());
@@ -654,7 +654,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                } else {
                    return association;
                }
            }));
            }), userId);

            restartBleScan();
        }
@@ -672,7 +672,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 {
@@ -774,9 +775,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) {
@@ -788,7 +789,7 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                onAssociationPreRemove(association);
            }
            return notMatch;
        }));
        }), userId);
        restartBleScan();
    }

@@ -980,13 +981,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,
@@ -1552,7 +1549,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;