Fix CDM association filtering

Null filter should match all associations

Bug: 181344542
Test: presubmit
Change-Id: Ib5c8e78177657e55113e0f9cca28b53d2fb5c002
This commit is contained in:
Eugene Susla
2021-03-12 17:40:47 -08:00
parent 70a30dabed
commit 351a6d7bd7

View File

@@ -963,7 +963,8 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
private Set<Association> 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<Association> 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<Association> readAllAssociations(int userId) {