Skip to content

Finish service data scan filtering: tests and documentation#1217

Draft
twyatt wants to merge 3 commits into
mainfrom
cursor/service-data-filter-tests-docs-d674
Draft

Finish service data scan filtering: tests and documentation#1217
twyatt wants to merge 3 commits into
mainfrom
cursor/service-data-filter-tests-docs-d674

Conversation

@twyatt

@twyatt twyatt commented Jul 16, 2026

Copy link
Copy Markdown
Member

Closes #857

The core Filter.ServiceData implementation landed in #882 (common Filter.ServiceData type, predicate matching, Android native ScanFilter.setServiceData, Apple flow filtering, and Web Bluetooth serviceData filter pass-through), but the feature was never covered by tests nor documented. This PR completes the remaining work so #857 can be closed:

Tests

  • Common (FilterPredicateTests): 20 new tests for Filter.ServiceData mirroring the existing Filter.ManufacturerData coverage — exact match, UUID mismatch, data mask matching (including advertisement data longer/shorter than filter data), UUID-only matching when data is null (the service-data analogue of company-ID-only filtering from Allow filtering by company ID only #855), and constructor argument validation.
  • Common (FiltersTests): the complex multi-predicate test now includes a serviceData predicate, exercising the filters { match { serviceData = ... } } DSL.
  • Android (ScanFiltersTests): new tests verifying Filter.ServiceData converts to a native ScanFilter via setServiceData(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 the com.android.kotlin.multiplatform.library plugin (which uses androidHostTest, enabled via withHostTest { }). ScanFiltersTests and ProfileTests were silently not being compiled nor run. They have been moved to androidHostTest/ (as a pure git mv in its own commit) and both pass there.

Documentation

  • Added a ServiceData row to the filter support tables in the README and the Filter KDoc.
  • Corrected the Filter.ServiceData KDoc 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.
  • Updated stale comments in web ScannerBuilder/OptionsBuilder that still claimed service data filtering "is not supported because it is not implemented", and pointed the deprecated FilterSet docs at Filter.ServiceData via the filters { match { ... } } DSL.

Verification

  • :kable-core:jvmTest — passes (runs all common tests, including the new ServiceData predicate tests)
  • :kable-core:testAndroidHostTest — passes (Robolectric; includes the moved and extended ScanFiltersTests)
  • :kable-core:lintKotlin — passes

No public API or runtime behavior changes; this PR is tests and documentation only.

Open in Web Open in Cursor 

cursoragent and others added 3 commits July 16, 2026 07:35
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support service data scan/requestDevice filtering

2 participants