-
public final class PermissionManagerSPEC-421 — runtime permission manager for onboarding permission steps (Android mirror of the iOS
PermissionManager).Two responsibilities:
status — read the current authorization via
ContextCompat.checkSelfPermission. Applies the manifest guard: a type whose runtime permission is NOT declared in the host manifest returns PermissionStatus.UNAVAILABLE (we never launch → the request can't silently no-op).atthas no Android equivalent (auto-granted no-op) andnotificationbelow API 33 is auto-granted (no runtime permission exists there).request — fire the real OS prompt (via a ActivityResultLauncher bridge registered at composition by the caller) and return whether it was granted.
The
ActivityResultLauncheritself MUST be registered at composition (never lazily at button-tap, which throwsIllegalStateExceptionwhen RESUMED); the caller wires requestLauncher to it and completes the pending request via completePending.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classPermissionManager.Companion
-
Field Summary
Fields Modifier and Type Field Description private Function1<String, Unit>requestLauncherprivate Function0<Unit>exactAlarmSettingsLauncher
-
Constructor Summary
Constructors Constructor Description PermissionManager(Context context)
-
Method Summary
Modifier and Type Method Description final Function1<String, Unit>getRequestLauncher()Bridge to the composition-registered ActivityResultLauncher.final UnitsetRequestLauncher(Function1<String, Unit> requestLauncher)Bridge to the composition-registered ActivityResultLauncher.final Function0<Unit>getExactAlarmSettingsLauncher()Mrozu (alarmy s4. final UnitsetExactAlarmSettingsLauncher(Function0<Unit> exactAlarmSettingsLauncher)Mrozu (alarmy s4. final PermissionStatusstatus(String type)final Booleanrequest(String type)Fire the real OS prompt (via the composition-registered launcher) and return whether granted. final UnitcompletePending(Boolean granted)Completes the in-flight request with the launcher's result. final BooleancanScheduleExactAlarms()Whether this app can schedule exact alarms right now. final IntentexactAlarmSettingsIntent()The Settings intent that opens the per-app "Alarms & reminders" (exact-alarm) toggle. final UnitcompletePendingExactAlarm()Completes the in-flight requestExactAlarm by re-reading canScheduleExactAlarms once the user returns from the ACTION_REQUEST_SCHEDULE_EXACT_ALARM Settings screen. final BooleanshouldShowRationale(String type)Whether the OS would still show a rationale/prompt for type (false when permanently denied). final UnitopenAppSettings()Open the app's Settings details page so a permanently-denied permission can be flipped. -
-
Constructor Detail
-
PermissionManager
PermissionManager(Context context)
-
-
Method Detail
-
getRequestLauncher
final Function1<String, Unit> getRequestLauncher()
Bridge to the composition-registered
ActivityResultLauncher. Given a permission string, it launches the OS prompt; the result arrives asynchronously via completePending.
-
setRequestLauncher
final Unit setRequestLauncher(Function1<String, Unit> requestLauncher)
Bridge to the composition-registered
ActivityResultLauncher. Given a permission string, it launches the OS prompt; the result arrives asynchronously via completePending.
-
getExactAlarmSettingsLauncher
final Function0<Unit> getExactAlarmSettingsLauncher()
Mrozu (alarmy s4.1) — bridge to a composition-registered
StartActivityForResultlauncher that opens the ACTION_REQUEST_SCHEDULE_EXACT_ALARM Settings screen (SCHEDULE_EXACT_ALARM has no runtime-permission dialog). The result arrives via completePendingExactAlarm, which re-reads canScheduleExactAlarms once the user returns. When null (no launcher wired) analarmrequest safe-falls-back to the current grant state without launching.
-
setExactAlarmSettingsLauncher
final Unit setExactAlarmSettingsLauncher(Function0<Unit> exactAlarmSettingsLauncher)
Mrozu (alarmy s4.1) — bridge to a composition-registered
StartActivityForResultlauncher that opens the ACTION_REQUEST_SCHEDULE_EXACT_ALARM Settings screen (SCHEDULE_EXACT_ALARM has no runtime-permission dialog). The result arrives via completePendingExactAlarm, which re-reads canScheduleExactAlarms once the user returns. When null (no launcher wired) analarmrequest safe-falls-back to the current grant state without launching.
-
status
final PermissionStatus status(String type)
-
request
final Boolean request(String type)
Fire the real OS prompt (via the composition-registered launcher) and return whether granted.
att→ auto-granted no-op (returns true, no launch).notificationbelow API 33 → auto-granted (returns true, no launch).unsupported / no launcher wired → false.
-
completePending
final Unit completePending(Boolean granted)
Completes the in-flight request with the launcher's result. Called from the launcher callback.
-
canScheduleExactAlarms
final Boolean canScheduleExactAlarms()
Whether this app can schedule exact alarms right now. Below API 31 exact alarms are always permitted; on API 31+ it reflects the SCHEDULE_EXACT_ALARM Settings toggle (or a granted USE_EXACT_ALARM). Pure read — never launches anything.
-
exactAlarmSettingsIntent
final Intent exactAlarmSettingsIntent()
The Settings intent that opens the per-app "Alarms & reminders" (exact-alarm) toggle. Null below API 31 (exact alarms are allowed by default there, so no toggle exists). Built here — not in the composable — so the host layer stays a thin launcher registration.
-
completePendingExactAlarm
final Unit completePendingExactAlarm()
Completes the in-flight requestExactAlarm by re-reading canScheduleExactAlarms once the user returns from the ACTION_REQUEST_SCHEDULE_EXACT_ALARM Settings screen. Called from the composition-registered
StartActivityForResultcallback.
-
shouldShowRationale
final Boolean shouldShowRationale(String type)
Whether the OS would still show a rationale/prompt for type (false when permanently denied).
-
openAppSettings
final Unit openAppSettings()
Open the app's Settings details page so a permanently-denied permission can be flipped.
-
-
-
-