A11yScannerController

class A11yScannerController(nodeProvider: () -> List<A11yNode>, screenDensity: Float)

Public SDK entry point for running accessibility scans.

Typical usage:

val controller = A11yScannerController(
nodeProvider = { A11yNodeExtractor().extract(semanticsOwner) },
screenDensity = resources.displayMetrics.density,
)
.configure(ScannerConfig(enabledRules = ScannerRules.allRuleIds().toSet()))
.withRules(MyCustomRule())

lifecycleScope.launch {
controller.startScan().collect { state -> /* update UI */}
}
// ...
controller.stopScan()
// ...
controller.destroy() // cancel the internal scope when the host is destroyed

Parameters

nodeProvider

Called once per startScan invocation to produce the node list. Must be safe to call on Dispatchers.Default.

screenDensity

DisplayMetrics.density, forwarded to density-dependent rules.

Constructors

Link copied to clipboard
constructor(nodeProvider: () -> List<A11yNode>, screenDensity: Float)

Properties

Link copied to clipboard

Hot Flow backed by the internal MutableSharedFlow.

Functions

Link copied to clipboard

Stops any active scan and emits ScannerState.Idle.

Link copied to clipboard

Replaces the active scanner configuration.

Link copied to clipboard
fun destroy()

Cancels the internal CoroutineScope. Call when the host (Activity/Fragment/ViewModel) is destroyed.

Link copied to clipboard
fun startScan(): Flow<ScannerState>

Cancels any in-progress scan, then starts a new one.

Link copied to clipboard
fun stopScan()

Cancels the current scan if one is running. The Flow returned by startScan stops emitting.

Link copied to clipboard

Appends rules to the set that will run alongside the standard rule set. Custom rules are automatically added to ScannerConfig.enabledRules so the engine never filters them out. Returns this controller for chaining.