Pure Refactor: move filtering logic into AdvertisementFilter class

- this decouples filtering logic from advertisement decoding logic
   in preparation for introducing a Rust backed impl of
   AdvertisementDecoder
 - this change is only a refactor and does not change functionality
   in any way

PiperOrigin-RevId: 618978564
This commit is contained in:
hai007
2024-03-25 15:33:20 -07:00
committed by Copybara-Service
parent 0b711e91e9
commit 5bc1c83472
9 changed files with 355 additions and 226 deletions
@@ -57,19 +57,12 @@ class AdvertisementDecoder {
AddBannedDataTypes();
}
static std::vector<CredentialSelector> GetCredentialSelectors(
const ScanRequest& scan_request);
// Returns a list of Data Elements decoded from the advertisement.
// Returns an error if the advertisement is misformatted or if it couldn't be
// decrypted.
absl::StatusOr<Advertisement> DecodeAdvertisement(
absl::string_view advertisement);
// Returns true if the decoded advertisement in `data_elements` matches the
// filters in `scan_request`.
bool MatchesScanFilter(const std::vector<DataElement>& data_elements);
private:
// Decrypts data elements stored inside encrypted `elem` and appends them to
// `decoded_advertisement_`.
@@ -81,10 +74,6 @@ class AdvertisementDecoder {
const std::vector<internal::SharedCredential>& credentials,
absl::string_view salt, absl::string_view data_elements);
void AddBannedDataTypes();
bool MatchesScanFilter(const std::vector<DataElement>& data_elements,
const PresenceScanFilter& filter);
bool MatchesScanFilter(const std::vector<DataElement>& data_elements,
const LegacyPresenceScanFilter& filter);
ScanRequest scan_request_;
absl::flat_hash_map<IdentityType, std::vector<internal::SharedCredential>>*