app: make the Shizuku banner actionable (open Shizuku / request permission)

A third-party app cannot start Shizuku — the wireless-debugging pairing
flow is privileged and lives in Shizuku's own app — so the banner
deep-links there when it is installed but stopped, and fires the
permission request directly when it is running but unauthorised. The hint
line says which.

Verified on-device together with the earlier UX work: progress bar showing
"test 4 of 8 · icmp.ping6 · ~33s left", Cancel beside the disabled Run
button, cutout-safe title, and the banner live-updating from
not-running to needs-permission via the binder listener.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
mrambossek
2026-08-01 09:58:39 +02:00
co-authored by Claude Opus 5
parent d7dda40e4e
commit 1d9e2063bf
4 changed files with 65 additions and 5 deletions
@@ -58,6 +58,28 @@ object ShizukuAvailability {
State.NOT_INSTALLED -> null
}
/**
* Intent that opens the Shizuku manager, where the user starts the service ("Start with
* wireless debugging" / root). A third-party app cannot start Shizuku itself — the pairing
* flow lives inside that app — so the best we can do is take the user straight there.
* Null when Shizuku isn't installed or exposes no launcher activity.
*/
fun launchIntent(context: Context): android.content.Intent? =
context.packageManager.getLaunchIntentForPackage(SHIZUKU_PACKAGE)
?.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK)
/** Asks Shizuku for permission (only meaningful while it is running). */
fun requestPermission(requestCode: Int = 0xE1) {
runCatching { Shizuku.requestPermission(requestCode) }
}
/** What tapping the notice should do, so the UI can label it honestly. */
fun actionHint(s: State): String? = when (s) {
State.INSTALLED_NOT_RUNNING -> "Tap to open Shizuku and start it"
State.NEEDS_PERMISSION -> "Tap to grant permission"
else -> null
}
/**
* Reports the state now and on every binder transition. Returns a function that removes the
* listeners again (call it from onCleared).