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

Commit c88bc262 authored by Eugene Susla's avatar Eugene Susla Committed by Automerger Merge Worker
Browse files

Fix duplicate devices when multiple mediums scanning requested am: b8b53f3b am: 57a46768

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

Change-Id: I4da7bf1b954da8d5aab87ff4ff474f9e12344103
parents 8bfda849 57a46768
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -141,6 +141,16 @@ public final class BluetoothDeviceFilter implements DeviceFilter<BluetoothDevice
        return Objects.hash(mNamePattern, mAddress, mServiceUuids, mServiceUuidMasks);
    }

    @Override
    public String toString() {
        return "BluetoothDeviceFilter{"
                + "mNamePattern=" + mNamePattern
                + ", mAddress='" + mAddress + '\''
                + ", mServiceUuids=" + mServiceUuids
                + ", mServiceUuidMasks=" + mServiceUuidMasks
                + '}';
    }

    @Override
    public int describeContents() {
        return 0;
+11 −10
Original line number Diff line number Diff line
@@ -259,18 +259,19 @@ public class DeviceDiscoveryService extends Service {
    private void onDeviceFound(@Nullable DeviceFilterPair device) {
        if (device == null) return;

        if (mDevicesFound.contains(device)) {
            return;
        }

        if (DEBUG) Log.i(LOG_TAG, "Found device " + device);

        Handler.getMain().sendMessage(obtainMessage(
                DeviceDiscoveryService::onDeviceFoundMainThread, this, device));
    }

    @MainThread
    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()) {
            onReadyToShowUI();
        }
@@ -432,10 +433,10 @@ public class DeviceDiscoveryService extends Service {

        @Override
        public String toString() {
            return "DeviceFilterPair{" +
                    "device=" + device +
                    ", filter=" + filter +
                    '}';
            return "DeviceFilterPair{"
                    + "device=" + device + " " + getDisplayName()
                    + ", filter=" + filter
                    + '}';
        }
    }