Fix duplicate devices when multiple mediums scanning requested am: b8b53f3b39 am: 57a4676876
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12295535 Change-Id: I4da7bf1b954da8d5aab87ff4ff474f9e12344103
This commit is contained in:
@@ -141,6 +141,16 @@ public final class BluetoothDeviceFilter implements DeviceFilter<BluetoothDevice
|
|||||||
return Objects.hash(mNamePattern, mAddress, mServiceUuids, mServiceUuidMasks);
|
return Objects.hash(mNamePattern, mAddress, mServiceUuids, mServiceUuidMasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BluetoothDeviceFilter{"
|
||||||
|
+ "mNamePattern=" + mNamePattern
|
||||||
|
+ ", mAddress='" + mAddress + '\''
|
||||||
|
+ ", mServiceUuids=" + mServiceUuids
|
||||||
|
+ ", mServiceUuidMasks=" + mServiceUuidMasks
|
||||||
|
+ '}';
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -259,18 +259,19 @@ public class DeviceDiscoveryService extends Service {
|
|||||||
private void onDeviceFound(@Nullable DeviceFilterPair device) {
|
private void onDeviceFound(@Nullable DeviceFilterPair device) {
|
||||||
if (device == null) return;
|
if (device == null) return;
|
||||||
|
|
||||||
if (mDevicesFound.contains(device)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DEBUG) Log.i(LOG_TAG, "Found device " + device);
|
|
||||||
|
|
||||||
Handler.getMain().sendMessage(obtainMessage(
|
Handler.getMain().sendMessage(obtainMessage(
|
||||||
DeviceDiscoveryService::onDeviceFoundMainThread, this, device));
|
DeviceDiscoveryService::onDeviceFoundMainThread, this, device));
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainThread
|
@MainThread
|
||||||
void onDeviceFoundMainThread(@NonNull DeviceFilterPair device) {
|
void onDeviceFoundMainThread(@NonNull DeviceFilterPair device) {
|
||||||
|
if (mDevicesFound.contains(device)) {
|
||||||
|
Log.i(LOG_TAG, "Skipping device " + device + " - already among found devices");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i(LOG_TAG, "Found device " + device);
|
||||||
|
|
||||||
if (mDevicesFound.isEmpty()) {
|
if (mDevicesFound.isEmpty()) {
|
||||||
onReadyToShowUI();
|
onReadyToShowUI();
|
||||||
}
|
}
|
||||||
@@ -432,10 +433,10 @@ public class DeviceDiscoveryService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DeviceFilterPair{" +
|
return "DeviceFilterPair{"
|
||||||
"device=" + device +
|
+ "device=" + device + " " + getDisplayName()
|
||||||
", filter=" + filter +
|
+ ", filter=" + filter
|
||||||
'}';
|
+ '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user