From 79cb1b98a5682171fa16894f218f161050e10674 Mon Sep 17 00:00:00 2001 From: lee Date: Thu, 19 Jun 2025 22:05:15 +0800 Subject: [PATCH] RemoveDuplicateFilters Signed-off-by: lee --- .../ipc/parcel/bluetooth_ble_scan_filter.cpp | 70 +++++++++++++++++++ .../ipc/parcel/bluetooth_ble_scan_filter.h | 3 + 2 files changed, 73 insertions(+) diff --git a/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.cpp b/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.cpp index 9f038da9..5f5c2c8c 100644 --- a/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.cpp +++ b/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.cpp @@ -137,6 +137,76 @@ bool BluetoothBleScanFilter::ReadFromParcel(Parcel &parcel) return true; } +bool BluetoothBleScanFilter::operator==(const BluetoothBleScanFilter& other) const +{ + if (deviceId_ != other.deviceId_) { + return false; + } + if (name_ != other.name_) { + return false; + } + if (serviceUuid_ != other.serviceUuid_) { + return false; + } + if (serviceUuidMask_ != other.serviceUuidMask_) { + return false; + } + if (serviceSolicitationUuid_ != other.serviceSolicitationUuid_) { + return false; + } + if (serviceSolicitationUuidMask_ != other.serviceSolicitationUuidMask_) { + return false; + } + if (hasServiceUuid_ != other.hasServiceUuid_) { + return false; + } + if (hasServiceUuidMask_ != other.hasServiceUuidMask_) { + return false; + } + if (hasSolicitationUuid_ != other.hasSolicitationUuid_) { + return false; + } + if (hasSolicitationUuidMask_ != other.hasSolicitationUuidMask_) { + return false; + } + if (serviceData_!= other.serviceData_) { + return false; + } + if (serviceDataMask_ != other.serviceDataMask_) { + return false; + } + if (manufacturerId_ != other.manufacturerId_) { + return false; + } + if (manufactureData_ != other.manufactureData_) { + return false; + } + if (manufactureDataMask_ != other.manufactureDataMask_) { + return false; + } + if (advIndReport_ != other.advIndReport_) { + return false; + } + if (filterIndex_ != other.filterIndex_) { + return false; + } + + return true; +} + +bool BluetoothBleScanFilter::operator<(const BluetoothBleScanFilter& other) const +{ + return std::tie(deviceId_, name_, serviceUuid_, serviceUuidMask_, serviceSolicitationUuid_, + serviceSolicitationUuidMask_, hasServiceUuid_, hasServiceUuidMask_, hasSolicitationUuid_, + hasSolicitationUuidMask_, serviceData_, serviceDataMask_, manufacturerId_, manufactureData_, + manufactureDataMask_, advIndReport_, filterIndex_) < + std::tie(other.deviceId_, other.name_, other.serviceUuid_, other.serviceUuidMask_, + other.serviceSolicitationUuid_, other.serviceSolicitationUuidMask_, other.hasServiceUuid_, + other.hasServiceUuidMask_, other.hasSolicitationUuid_, other.hasSolicitationUuidMask_, other.serviceData_, + other.serviceDataMask_, other.manufacturerId_, other.manufactureData_, other.manufactureDataMask_, + other.advIndReport_, other.filterIndex_); +} + bool BluetoothBleScanFilter::ReadUuidFromParcel(Parcel &parcel) { std::shared_ptr serviceUuid(parcel.ReadParcelable()); diff --git a/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.h b/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.h index c13a6e69..b370b629 100644 --- a/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.h +++ b/frameworks/inner/ipc/parcel/bluetooth_ble_scan_filter.h @@ -32,6 +32,9 @@ public: bool WriteToParcel(Parcel &parcel); bool ReadFromParcel(Parcel &parcel); + bool operator==(const BluetoothBleScanFilter& other) const; + bool operator<(const BluetoothBleScanFilter& other) const; + private: bool ReadUuidFromParcel(Parcel &parcel); }; -- Gitee