GrantAndServiceChecker

class GrantAndServiceChecker(grantManager: GrantManager, serviceManager: ServiceManager)

A utility that combines OS permission checks and hardware service monitoring into a single unified API.

In production mobile development, a permission being GrantStatus.GRANTED is often insufficient to use a feature. For example, Location features require BOTH the permission and the system GPS toggle to be enabled.

GrantAndServiceChecker is considered the Best Practice for verifying full feature readiness.

Usage Example

val checker = GrantAndServiceChecker(grantManager, serviceManager)

suspend fun startLocationFeature() {
when (val status = checker.checkLocationReady()) {
LocationReadyStatus.Ready -> sensor.start()
LocationReadyStatus.ServiceDisabled -> ui.showEnableGpsPrompt()
LocationReadyStatus.GrantDenied -> grantHandler.request { ... }
LocationReadyStatus.BothRequired -> ui.showTotalFailure()
}
}

Constructors

Link copied to clipboard
constructor(grantManager: GrantManager, serviceManager: ServiceManager)

Functions

Link copied to clipboard

Checks if Bluetooth features are fully ready (Permission + Radio hardware).

Link copied to clipboard
suspend fun checkLocationReady(grant: AppGrant = AppGrant.LOCATION): LocationReadyStatus

Checks if location features are fully ready (Permission + GPS hardware).

Link copied to clipboard
suspend fun checkReady(grant: AppGrant, serviceType: ServiceType): ReadyStatus

Performs a generic readiness check for any permission/service combination.

Link copied to clipboard
suspend fun isReady(grant: AppGrant): Boolean

A simplified convenience API to check if a feature is fully ready.