From 351a6d7bd73256e6830acbb407a1e84bbae962e7 Mon Sep 17 00:00:00 2001 From: Eugene Susla Date: Fri, 12 Mar 2021 17:40:47 -0800 Subject: Fix CDM association filtering Null filter should match all associations Bug: 181344542 Test: presubmit Change-Id: Ib5c8e78177657e55113e0f9cca28b53d2fb5c002 --- .../android/server/companion/CompanionDeviceManagerService.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java index 4b5684511757..92af0804955f 100644 --- a/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +++ b/services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java @@ -963,7 +963,8 @@ public class CompanionDeviceManagerService extends SystemService implements Bind private Set getAllAssociations(int userId, @Nullable String packageFilter) { return CollectionUtils.filter( getAllAssociations(userId), - a -> Objects.equals(packageFilter, a.getPackageName())); + // Null filter == get all associations + a -> packageFilter == null || Objects.equals(packageFilter, a.getPackageName())); } private Set getAllAssociations() { @@ -983,8 +984,10 @@ public class CompanionDeviceManagerService extends SystemService implements Bind int userId, @Nullable String packageFilter, @Nullable String addressFilter) { return CollectionUtils.filter( getAllAssociations(userId), - a -> Objects.equals(packageFilter, a.getPackageName()) - && Objects.equals(addressFilter, a.getDeviceMacAddress())); + // Null filter == get all associations + a -> (packageFilter == null || Objects.equals(packageFilter, a.getPackageName())) + && (addressFilter == null + || Objects.equals(addressFilter, a.getDeviceMacAddress()))); } private Set readAllAssociations(int userId) { -- cgit v1.2.3-59-g8ed1b