CollectorRuntime

Shared runtime scaffolding used by collectors: concurrency limits, per-category timeouts, API-level guards, safe Settings readers and a bounded/timed collect wrapper.

Centralizing these concerns keeps individual collectors small and ensures every probe runs under consistent timeout, concurrency and error-handling policies.

Properties

Link copied to clipboard

Default per-collector collection timeout in milliseconds.

Link copied to clipboard

Timeout for the OpenGL ES fingerprint probe, which creates a GL context.

Link copied to clipboard
val passiveSemaphore: Semaphore

Max concurrent passive collectors — limits CPU/IO spikes on refresh.

Link copied to clipboard

Timeout for the WebView fingerprint collector, which spins up a WebView.

Functions

Link copied to clipboard
fun apiAtLeast(level: Int): Boolean

Returns true if the running platform is at least the given SDK level.

Link copied to clipboard
suspend fun collectBounded(collector: SignalCollector, context: Context, timeoutMs: Long = DEFAULT_COLLECT_TIMEOUT_MS): Result<List<FingerprintSignal>>

Runs a collector on the bounded IO dispatcher, wrapped in a trace slice, a timeout and a runCatching guard so a slow or failing probe cannot stall the app.

Link copied to clipboard
inline fun <T> ifApi(level: Int, fallback: T, block: () -> T): T

Runs block only when the platform is at least SDK level, returning fallback otherwise or if block throws.

Link copied to clipboard
fun safeGlobalInt(context: Context, key: String, default: Int = 0): String

Safely reads an integer from Settings.Global as a string.

Link copied to clipboard
fun safeGlobalString(context: Context, key: String): String?

Safely reads a value from Settings.Global, swallowing any exception.

Link copied to clipboard
fun safeSecureString(context: Context, key: String): String?

Safely reads a value from Settings.Secure, swallowing any exception.

Link copied to clipboard
suspend fun <T> withPassivePermit(block: suspend () -> T): T

Executes block while holding a permit from passiveSemaphore, capping concurrent passive collection.