Merge "Fix BLE scan result filtering in CompanionDeviceManager." into rvc-dev am: d43f5fff78
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11733921 Change-Id: I933101a4d3d958b0a448cfe5945d9afbee5e3182
This commit is contained in:
@@ -51,13 +51,6 @@ public class BluetoothDeviceFilterUtils {
|
|||||||
return s == null ? null : Pattern.compile(s);
|
return s == null ? null : Pattern.compile(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean matches(ScanFilter filter, BluetoothDevice device) {
|
|
||||||
boolean result = matchesAddress(filter.getDeviceAddress(), device)
|
|
||||||
&& matchesServiceUuid(filter.getServiceUuid(), filter.getServiceUuidMask(), device);
|
|
||||||
if (DEBUG) debugLogMatchResult(result, device, filter);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean matchesAddress(String deviceAddress, BluetoothDevice device) {
|
static boolean matchesAddress(String deviceAddress, BluetoothDevice device) {
|
||||||
final boolean result = deviceAddress == null
|
final boolean result = deviceAddress == null
|
||||||
|| (device != null && deviceAddress.equals(device.getAddress()));
|
|| (device != null && deviceAddress.equals(device.getAddress()));
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.android.internal.util.BitUtils;
|
import com.android.internal.util.BitUtils;
|
||||||
import com.android.internal.util.ObjectUtils;
|
import com.android.internal.util.ObjectUtils;
|
||||||
import com.android.internal.util.Preconditions;
|
|
||||||
|
|
||||||
import libcore.util.HexEncoding;
|
import libcore.util.HexEncoding;
|
||||||
|
|
||||||
@@ -166,21 +165,18 @@ public final class BluetoothLeDeviceFilter implements DeviceFilter<ScanResult> {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(ScanResult device) {
|
public boolean matches(ScanResult scanResult) {
|
||||||
boolean result = matches(device.getDevice())
|
BluetoothDevice device = scanResult.getDevice();
|
||||||
|
boolean result = getScanFilter().matches(scanResult)
|
||||||
|
&& BluetoothDeviceFilterUtils.matchesName(getNamePattern(), device)
|
||||||
&& (mRawDataFilter == null
|
&& (mRawDataFilter == null
|
||||||
|| BitUtils.maskedEquals(device.getScanRecord().getBytes(),
|
|| BitUtils.maskedEquals(scanResult.getScanRecord().getBytes(),
|
||||||
mRawDataFilter, mRawDataFilterMask));
|
mRawDataFilter, mRawDataFilterMask));
|
||||||
if (DEBUG) Log.i(LOG_TAG, "matches(this = " + this + ", device = " + device +
|
if (DEBUG) Log.i(LOG_TAG, "matches(this = " + this + ", device = " + device +
|
||||||
") -> " + result);
|
") -> " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matches(BluetoothDevice device) {
|
|
||||||
return BluetoothDeviceFilterUtils.matches(getScanFilter(), device)
|
|
||||||
&& BluetoothDeviceFilterUtils.matchesName(getNamePattern(), device);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@Override
|
@Override
|
||||||
public int getMediumType() {
|
public int getMediumType() {
|
||||||
|
|||||||
Reference in New Issue
Block a user