Package 

Class PermissionManager


  • 
    public final class PermissionManager
    
                        

    SPEC-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). att has no Android equivalent (auto-granted no-op) and notification below 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 ActivityResultLauncher itself MUST be registered at composition (never lazily at button-tap, which throws IllegalStateException when RESUMED); the caller wires requestLauncher to it and completes the pending request via completePending.

    • 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 StartActivityForResult launcher 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) an alarm request 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 StartActivityForResult launcher 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) an alarm request safe-falls-back to the current grant state without launching.

      • 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).

        • notification below API 33 → auto-granted (returns true, no launch).

        • unsupported / no launcher wired → false.

      • 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 StartActivityForResult callback.

      • openAppSettings

         final Unit openAppSettings()

        Open the app's Settings details page so a permanently-denied permission can be flipped.