Use mAddressMap in cdm getAssociationsByAddress

This CL leverages the mAddressMap which was specifically introduces
for the kind of address-based lookup that is needed in the
getAssociationsByAddress method.

Test: atest CtsCompanionDeviceManagerCoreTestCases
Test: atest CtsCompanionDeviceManagerUiAutomationTestCases
Change-Id: Ifb00e184bd491e2385214b7c89d64da33dc36ee3
This commit is contained in:
Nikolas Havrikov
2022-01-20 17:08:34 +01:00
parent ce65b04d56
commit 1bcc8203bb

View File

@@ -213,11 +213,9 @@ class AssociationStoreImpl implements AssociationStore {
final Set<Integer> ids = mAddressMap.get(address);
if (ids == null) return Collections.emptyList();
final List<AssociationInfo> associations = new ArrayList<>();
for (AssociationInfo association : mIdMap.values()) {
if (address.equals(association.getDeviceMacAddress())) {
associations.add(association);
}
final List<AssociationInfo> associations = new ArrayList<>(ids.size());
for (Integer id : ids) {
associations.add(mIdMap.get(id));
}
return Collections.unmodifiableList(associations);