summaryrefslogtreecommitdiff
path: root/packages/CompanionDeviceManager/src
diff options
context:
space:
mode:
author Priyanka Advani <padvani@google.com> 2024-04-19 20:45:34 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-19 20:45:34 +0000
commita2a7dbaf135e856bdeaab839adea33259f59a1ad (patch)
tree6a575f6e45045c89c6caff306811a7bdbb3d48f6 /packages/CompanionDeviceManager/src
parent7d692662b90a68a1c54038dec88cd91d1c6bb553 (diff)
parentdc07a3c90a08bc932541ee4335b5d1bf4718e5be (diff)
Merge "Revert "Do not need to startDiscovery if a bound device need to be assoicated."" into main
Diffstat (limited to 'packages/CompanionDeviceManager/src')
-rw-r--r--packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java29
1 files changed, 10 insertions, 19 deletions
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java
index a5bb34f4422b..c8801bb5ded2 100644
--- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java
+++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/CompanionDeviceDiscoveryService.java
@@ -188,12 +188,7 @@ public class CompanionDeviceDiscoveryService extends Service {
filter(allFilters, BluetoothLeDeviceFilter.class);
final List<WifiDeviceFilter> wifiFilters = filter(allFilters, WifiDeviceFilter.class);
- // No need to startDiscovery if the device is already bound or connected for
- // singleDevice dialog.
- if (checkBoundDevicesIfNeeded(request, btFilters)) {
- stopSelf();
- return;
- }
+ checkBoundDevicesIfNeeded(request, btFilters);
// If no filters are specified: look for everything.
final boolean forceStartScanningAll = isEmpty(allFilters);
@@ -253,37 +248,33 @@ public class CompanionDeviceDiscoveryService extends Service {
stopSelf();
}
- private boolean checkBoundDevicesIfNeeded(@NonNull AssociationRequest request,
+ private void checkBoundDevicesIfNeeded(@NonNull AssociationRequest request,
@NonNull List<BluetoothDeviceFilter> btFilters) {
// If filtering to get single device by mac address, also search in the set of already
// bonded devices to allow linking those directly
- if (btFilters.isEmpty() || !request.isSingleDevice()) return false;
+ if (btFilters.isEmpty() || !request.isSingleDevice()) return;
final BluetoothDeviceFilter singleMacAddressFilter =
find(btFilters, filter -> !TextUtils.isEmpty(filter.getAddress()));
- if (singleMacAddressFilter == null) return false;
+ if (singleMacAddressFilter == null) return;
- return findAndReportMatches(mBtAdapter.getBondedDevices(), btFilters)
- || findAndReportMatches(mBtManager.getConnectedDevices(
- BluetoothProfile.GATT), btFilters)
- || findAndReportMatches(mBtManager.getConnectedDevices(
- BluetoothProfile.GATT_SERVER), btFilters);
+ findAndReportMatches(mBtAdapter.getBondedDevices(), btFilters);
+ findAndReportMatches(mBtManager.getConnectedDevices(BluetoothProfile.GATT), btFilters);
+ findAndReportMatches(
+ mBtManager.getConnectedDevices(BluetoothProfile.GATT_SERVER), btFilters);
}
- private boolean findAndReportMatches(@Nullable Collection<BluetoothDevice> devices,
+ private void findAndReportMatches(@Nullable Collection<BluetoothDevice> devices,
@NonNull List<BluetoothDeviceFilter> filters) {
- if (devices == null) return false;
+ if (devices == null) return;
for (BluetoothDevice device : devices) {
final DeviceFilterPair<BluetoothDevice> match = findMatch(device, filters);
if (match != null) {
onDeviceFound(match);
- return true;
}
}
-
- return false;
}
private BluetoothBroadcastReceiver startBtScanningIfNeeded(