Merge "Only do the ble scan if association isNotifyOnDeviceNearby" into tm-dev am: 6ad21dae20

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

Change-Id: I938a3a7ab6d04b23c41e714580e6aea9ed80fc04
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-04-14 21:18:24 +00:00
committed by Automerger Merge Worker
2 changed files with 5 additions and 0 deletions

View File

@@ -671,6 +671,9 @@ public class CompanionDeviceManagerService extends SystemService {
association = AssociationInfo.builder(association)
.setNotifyOnDeviceNearby(active)
.build();
// Do not need to call {@link BleCompanionDeviceScanner#restartScan()} since it will
// trigger {@link BleCompanionDeviceScanner#restartScan(int, AssociationInfo)} when
// an application sets/unsets the mNotifyOnDeviceNearby flag.
mAssociationStore.updateAssociation(association);
// TODO(b/218615198): correctly handle the case when the device is currently present.

View File

@@ -194,6 +194,8 @@ class BleCompanionDeviceScanner implements AssociationStore.OnChangeListener {
// Collect MAC addresses from all associations.
final Set<String> macAddresses = new HashSet<>();
for (AssociationInfo association : mAssociationStore.getAssociations()) {
if (!association.isNotifyOnDeviceNearby()) continue;
// Beware that BT stack does not consider low-case MAC addresses valid, while
// MacAddress.toString() return a low-case String.
final String macAddress = association.getDeviceMacAddressAsString();