GrantAndServiceChecker
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()
}
}Content copied to clipboard