Introducing a new way to review your PRs.

Read the announcement

rikkaapps / shizuku

Using system APIs directly with adb/root privileges from normal apps through a Java process started with app_process.

View on GitHub

12 documents · Updated Nov 16, 2026

docs / manager-startup-and-legacy-flows

Manager startup and legacy flows

Overview

This area covers the manager app paths that help users start Shizuku, expose the Rish shell helper, and keep old external request entry points from silently failing.

The start command itself is centralized in manager/…/Starter.kt. It points at the packaged native executable libshizuku.so under application.applicationInfo.nativeLibraryDir; the command shown to users is the raw executable path, the ADB command prepends adb shell, and the internal command appends --apk=${application.applicationInfo.sourceDir} so the starter can locate the current manager APK.

manager/…/StarterActivity.kt is the UI and executor for both root and wireless ADB startup. Callers choose the mode with StarterActivity.EXTRA_IS_ROOT; root startup runs Starter.internalCommand through com.topjohnwu.superuser.Shell, retrying once if the first cached shell is not root. Wireless ADB startup requires EXTRA_HOST and EXTRA_PORT, loads/generates the shizuku ADB key from PreferenceAdbKeyStore(ShizukuSettings.getPreferences()), connects through AdbClient, and streams Starter.internalCommand output back into the activity. Both modes append command output into a LiveData<Resource<StringBuilder>>; when output ends with info: shizuku_starter exit with 0, the activity waits for Shizuku to deliver a binder and then closes itself after three seconds. Startup errors are mapped to user dialogs for ADB key storage, root shell failure, connection failure, and missing wireless-ADB pairing.

The user-facing entry points for StarterActivity live outside these covered packages but are part of this flow: manager/…/StartRootViewHolder.kt starts it with EXTRA_IS_ROOT=true; manager/…/StartWirelessAdbViewHolder.kt starts it for pre-Android 11 TCP ADB when EnvironmentUtils.getAdbTcpPort() returns a port; and manager/…/AdbDialogFragment.kt discovers Android 11+ wireless ADB ports with AdbMdns.TLS_CONNECT, optionally enables wireless debugging when WRITE_SECURE_SETTINGS is granted, and launches StarterActivity with host 127.0.0.1.

Shell support has two halves. manager/…/Shell.java is the in-app Rish entry point: it initializes RishConfig from a Shizuku binder, registers that binder with Shizuku.onBinderReceived, requires server version 12 or newer, then starts a Rish shell. Its permission path first uses existing Shizuku permission, otherwise requests permission and exits the shell process with Permission denied if the request is denied or rationale indicates the user should not be asked again. manager/…/ShellTutorialActivity.kt is the terminal tutorial/export screen opened from manager/…/TerminalViewHolder.kt only when the service is running. It lets the user choose a document-tree destination, removes existing rish and rish_shizuku.dex children in that tree, and writes fresh copies from app assets; it also links to the Rish help page through CustomTabsHelper.

External shell binder requests are handled by manager/…/ShellBinderRequestHandler.kt. It only accepts the legacy action rikka.shizuku.intent.action.REQUEST_BINDER, reads the caller-provided callback binder from the data bundle under key binder, writes the current Shizuku binder plus the manager APK path into a Parcel, and sends transaction code 1 as IBinder.FLAG_ONEWAY. The same handler is reachable through the exported legacy activity manager/…/ShellRequestHandlerActivity.kt and through manager/…/ShizukuReceiver.kt; manager/…/AndroidManifest.xml declares both for the same request action.

manager/…/LegacyIsNotSupportedActivity.kt is the compatibility screen for old authorization requests declared in manager/…/AndroidManifest.xml as ${applicationId}.intent.action.REQUEST_AUTHORIZATION. It requires a calling activity, looks up the caller app label and metadata, and always returns RESULT_ERROR after showing a non-cancelable Material dialog. Apps that declare moe.shizuku.client.V3_SUPPORT=true get a message saying they are using a legacy path plus a button to open MainActivity; other apps get the generic legacy-not-supported message. If there is no caller, the result is canceled instead of showing UI.

Coupling

Risks

  • manager/…/StarterActivity.kt treats a literal output suffix, info: shizuku_starter exit with 0, as the signal to wait for the service binder. If native starter logging changes without updating this string check, the service may start successfully while the UI never transitions to the waiting/auto-close state.
  • manager/…/ShellBinderRequestHandler.kt may write a null Shizuku binder into the callback parcel when Shizuku.getBinder() is null; it only logs Binder not received or Shizuku service not running and still transacts. Legacy callers that assume a non-null binder can fail later without the manager surfacing an error.
  • manager/…/ShellTutorialActivity.kt deletes existing rish and rish_shizuku.dex documents before writing replacements. The path history includes 9e7381b Show exception from writeSdcardFiles, which indicates export failures have needed debugging before; if asset reads or document writes fail, the selected folder can be left with one or both helper files missing.
  • Startup and shell compatibility paths have a history of targeted fixes, including 58e8bfd Fix start on boot for root is broken, c9ab793 RISH request binder with broadcast receiver, and 68287da Pass apk path when rooted since Samsung kernel doesn't like exec with uid 0. Changes to root execution, binder-request delivery, or APK-path passing should be tested on the affected startup and legacy request paths rather than only through the main UI.