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

Commit dd0e2f32 authored by Evan Chen's avatar Evan Chen
Browse files

Only do the ble scan if association isNotifyOnDeviceNearby

We do not need to blescan the nearby devices if they are
not isNotifyOnDeviceNearby.

Bug: 223323702
Test: Manually test on CTS verifier test.

Change-Id: Ibfc87b78ed38de17595f07e4c8e7b362c0848257
parent 10af76b8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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.
+2 −0
Original line number Diff line number Diff line
@@ -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();