-
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>requestLauncher
-
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 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 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.
-
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.
-
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.
-
-
-
-