diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2017-04-14 23:11:26 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-04-14 23:11:30 +0000 |
commit | 728ce604653853af047c30b78f2385a375f46b4f (patch) | |
tree | bf44566c2941ef9b5a7b632666eac231b332fe00 /packages/CompanionDeviceManager | |
parent | 5f9fde884b479645cb0d977c3a8fd8dd06f25e72 (diff) | |
parent | 3c9aa1767ca0ddc881f53c2ce7eb3135670efef3 (diff) |
Merge "[DO NOT MERGE] Fix a bug with filtering by raw bytes" into oc-dev
Diffstat (limited to 'packages/CompanionDeviceManager')
-rw-r--r-- | packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java index 1b6aca1ba65e..227d8048292a 100644 --- a/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java +++ b/packages/CompanionDeviceManager/src/com/android/companiondevicemanager/DeviceDiscoveryService.java @@ -110,6 +110,11 @@ public class DeviceDiscoveryService extends Service { private final ScanCallback mBLEScanCallback = new ScanCallback() { @Override public void onScanResult(int callbackType, ScanResult result) { + if (DEBUG) { + Log.i(LOG_TAG, + "BLE.onScanResult(callbackType = " + callbackType + ", result = " + result + + ")"); + } final DeviceFilterPair<ScanResult> deviceFilterPair = DeviceFilterPair.findMatch(result, mBLEFilters); if (deviceFilterPair == null) return; @@ -126,6 +131,10 @@ public class DeviceDiscoveryService extends Service { private BroadcastReceiver mBluetoothDeviceFoundBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { + if (DEBUG) { + Log.i(LOG_TAG, + "BL.onReceive(context = " + context + ", intent = " + intent + ")"); + } final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); final DeviceFilterPair<BluetoothDevice> deviceFilterPair = DeviceFilterPair.findMatch(device, mBluetoothFilters); @@ -191,7 +200,10 @@ public class DeviceDiscoveryService extends Service { mBLEScanFilters = CollectionUtils.map(mBLEFilters, BluetoothLEDeviceFilter::getScanFilter); reset(); - } + } else if (DEBUG) Log.i(LOG_TAG, "startDiscovery: duplicate request: " + request); + + + if (!ArrayUtils.isEmpty(mDevicesFound)) { onReadyToShowUI(); } @@ -221,6 +233,7 @@ public class DeviceDiscoveryService extends Service { } private void reset() { + if (DEBUG) Log.i(LOG_TAG, "reset()"); mDevicesFound.clear(); mSelectedDevice = null; mDevicesAdapter.notifyDataSetChanged(); @@ -369,8 +382,15 @@ public class DeviceDiscoveryService extends Service { public static <T extends Parcelable> DeviceFilterPair<T> findMatch( T dev, @Nullable List<? extends DeviceFilter<T>> filters) { if (isEmpty(filters)) return new DeviceFilterPair<>(dev, null); - final DeviceFilter<T> matchingFilter = CollectionUtils.find(filters, (f) -> f.matches(dev)); - return matchingFilter != null ? new DeviceFilterPair<>(dev, matchingFilter) : null; + final DeviceFilter<T> matchingFilter + = CollectionUtils.find(filters, f -> f.matches(dev)); + + DeviceFilterPair<T> result = matchingFilter != null + ? new DeviceFilterPair<>(dev, matchingFilter) + : null; + if (DEBUG) Log.i(LOG_TAG, "findMatch(dev = " + dev + ", filters = " + filters + + ") -> " + result); + return result; } public String getDisplayName() { |