Repository navigation
Automation and Intents
Nightzuku includes an authenticated control plane for starting, stopping, restarting, querying, and configuring the service from automation apps (Tasker, MacroDroid, Automate), ADB scripts, or third-party apps.
It is disabled by default. Enable and manage it in Settings → Automation & Intents.
- Open Settings → Automation & Intents and toggle the feature ON.
- Review the security options:
-
Broadcast Intents — disable this if you only want app-to-app
ContentProvidercontrol. - Require HMAC-SHA256 (recommended, on by default) — requires replay-protected signed requests and rejects raw keys.
- Strict sender check (Android 14+) — requires package-bound keys to match the actual sending app's package and signing certificate.
-
Broadcast Intents — disable this if you only want app-to-app
- Tap New key to create an isolated 256-bit key:
- Choose a profile name (for example,
Tasker). - Select only the scopes you need (
start,stop,restart,status,nightdog). - Optionally bind the key to a specific package name.
- Uncheck HMAC-SHA256 only only if your automation tool cannot compute HMAC-SHA256 and you also disabled Require HMAC-SHA256 globally.
- Choose a profile name (for example,
- Copy the generated secret immediately — Nightzuku stores it encrypted with Android Keystore and will not show it again. You can rotate or revoke any key at any time.
- Tap Reload after changing external state or to clear rate-limit lockouts and re-sync the broadcast receiver.
Action: kerneldroid.nightzuku.action.CONTROL
Component: kerneldroid.nightzuku/moe.shizuku.manager.control.NightControlReceiver
Supported command values: start, stop, restart, toggle, status, nightdog_enable, nightdog_disable.
Optional extras:
-
mode:auto(default),root, oradb -
pause_nightdog:true(default) orfalse— pauses NightDog when stopping so the watchdog does not fight manual stops.
ADB example (scoped-key mode, when HMAC-only is disabled):
adb shell am broadcast \
-a kerneldroid.nightzuku.action.CONTROL \
-n kerneldroid.nightzuku/moe.shizuku.manager.control.NightControlReceiver \
--es command status \
--es key_id nk_xxxxxxxxxxxx \
--es key <your_secret>Prefer the Control ContentProvider (content://kerneldroid.nightzuku.control) over broadcast intents. Binder enforces your app's UID and package name at the kernel level, and Nightzuku pins your grant to your APK signing certificate SHA-256.
Launch the consent Activity:
val intent = Intent("kerneldroid.nightzuku.intent.action.REQUEST_CONTROL_ACCESS").apply {
putStringArrayListExtra("scopes", arrayListOf("start", "stop", "status"))
putExtra("request_key", true) // optional: also issue a one-time 256-bit HMAC key
putExtra("reason", "Start Nightzuku automatically when needed")
}
launcher.launch(intent)When the user approves (RESULT_OK), the result Intent contains:
-
granted(Boolean) -
key_id(String) -
scopes(ArrayList<String>) -
provider_authority("kerneldroid.nightzuku.control") -
action_control("kerneldroid.nightzuku.action.CONTROL") -
client_key(String, returned once ifrequest_key = truewas approved)
val uri = Uri.parse("content://kerneldroid.nightzuku.control")
// Inspect authorization state
val info = contentResolver.call(uri, "describe", null, null)
// Execute a command
val extras = Bundle().apply {
putString("command", "start")
putString("mode", "auto")
}
val reply = contentResolver.call(uri, "execute", null, extras)
val ok = reply?.getBoolean("ok") == true
val code = reply?.getString("code")
val running = reply?.getBoolean("running") == trueFor challenge-response HMAC via Provider:
- Call
"challenge"→ receivenonce(single-use, 30 s TTL) andexpires_at. - Sign canonical payload
"<command>|<timestamp>|<nonce>|<mode>"withHMAC-SHA256(client_key). - Call
"execute"withcommand,mode,key_id,timestamp,nonce, and lowercase hexsignature.
For apps or scripts sending kerneldroid.nightzuku.action.CONTROL:
- Extras:
command,mode(optional, defaultauto),key_id,timestamp(epoch seconds,±60 swindow),nonce(unique,≥ 8chars),signature(hexHMAC-SHA256). - Canonical string:
"${command.lowercase()}|$timestamp|$nonce|${mode.lowercase()}". - On Android 14+, call
BroadcastOptions.makeBasic().setShareIdentityEnabled(true)if using a package-bound key. - Use
sendOrderedBroadcastto receiveresultCode(RESULT_OK/RESULT_CANCELED) and structuredresultExtras(ok,code,message,running,uid,version,nightdog_enabled).
See the full protocol specification in docs/automation-and-intents.md.