Finish service data scan filtering: tests and documentation#1217
Draft
twyatt wants to merge 3 commits into
Draft
Finish service data scan filtering: tests and documentation#1217twyatt wants to merge 3 commits into
twyatt wants to merge 3 commits into
Conversation
The androidUnitTest source set is no longer wired up since the migration to the com.android.kotlin.multiplatform.library plugin (which uses androidHostTest, enabled via withHostTest). ProfileTests and ScanFiltersTests were silently not being compiled nor run; move them to androidHostTest so they run again. Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
Covers Filter.ServiceData predicate matching (exact match, data masks, UUID-only matching when data is null, constructor validation) in common tests, and native ScanFilter conversion (including native/flow overlay) in Android host tests. Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
Adds ServiceData to the filter support tables in the README and Filter KDoc, and updates stale web comments that stated service data filtering was unsupported (Kable passes service data filters through to the browser since #882; actual filtering is subject to browser support). Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #857
The core
Filter.ServiceDataimplementation landed in #882 (commonFilter.ServiceDatatype, predicate matching, Android nativeScanFilter.setServiceData, Apple flow filtering, and Web BluetoothserviceDatafilter pass-through), but the feature was never covered by tests nor documented. This PR completes the remaining work so #857 can be closed:Tests
FilterPredicateTests): 20 new tests forFilter.ServiceDatamirroring the existingFilter.ManufacturerDatacoverage — exact match, UUID mismatch, data mask matching (including advertisement data longer/shorter than filter data), UUID-only matching whendataisnull(the service-data analogue of company-ID-only filtering from Allow filtering by company ID only #855), and constructor argument validation.FiltersTests): the complex multi-predicate test now includes aserviceDatapredicate, exercising thefilters { match { serviceData = ... } }DSL.ScanFiltersTests): new tests verifyingFilter.ServiceDataconverts to a nativeScanFilterviasetServiceData(ParcelUuid, byte[], byte[]), and that the native/flow overlay splits correctly when combined with a non-native filter (Name.Prefix).Fix: orphaned Android unit tests
While adding the Android tests, I found that
kable-core/src/androidUnitTest/is no longer a wired-up source set since the migration to thecom.android.kotlin.multiplatform.libraryplugin (which usesandroidHostTest, enabled viawithHostTest { }).ScanFiltersTestsandProfileTestswere silently not being compiled nor run. They have been moved toandroidHostTest/(as a puregit mvin its own commit) and both pass there.Documentation
ServiceDatarow to the filter support tables in the README and theFilterKDoc.Filter.ServiceDataKDoc platform table: on JavaScript the filter is passed through natively to the browser (there is no Kable flow filter on web), but actual filtering is subject to browser implementation status, where service data filtering is not yet shipped in Chromium.ScannerBuilder/OptionsBuilderthat still claimed service data filtering "is not supported because it is not implemented", and pointed the deprecatedFilterSetdocs atFilter.ServiceDatavia thefilters { match { ... } }DSL.Verification
:kable-core:jvmTest— passes (runs all common tests, including the newServiceDatapredicate tests):kable-core:testAndroidHostTest— passes (Robolectric; includes the moved and extendedScanFiltersTests):kable-core:lintKotlin— passesNo public API or runtime behavior changes; this PR is tests and documentation only.