Skip to content

ADFA-6650: Keep Shizuku entry points and callbacks through R8 - #2166

Merged
itsaky-adfa merged 3 commits into
stagefrom
fix/ADFA-6650
Oct 20, 2026
Merged

itsaky-adfa merged 3 commits into
stagefrom
fix/ADFA-6650

Conversation

@itsaky-adfa

@itsaky-adfa itsaky-adfa commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

ADFA-6650

Wireless-debugging pairing has been broken in every release build since 26.36: pairing succeeds, but the Shizuku server dies on startup, so Debug keeps showing the pairing dialog. The experimental profiler is broken the same way. Debug builds are unaffected because they are not minified.

Cause

ADFA-5195 (#1701, 8d526ac586) removed -dontshrink, turning R8 shrinking back on for the whole app. Shizuku runs code R8 can't trace from the app, so it was stripped or rewritten:

What Why R8 can't see it Symptom
ShizukuService.main, ServiceStarter.main started by class name through app_process ClassNotFoundException in the server
ProfilerUserService constructors instantiated reflectively from the ComponentName class name class emptied to an abstract shell
Process/UID observer callbacks called by the framework over binder AbstractMethodError on the first callback
Calls through hidden framework interfaces (IPackageManager, ...) profiler and privileged-services packaged the hidden-API stubs, so R8 saw interfaces with no implementations and rewrote the calls to throw null server exits with MANAGER_APP_NOT_FOUND (status 50); 11 other hidden-API calls also became throws

Bisected via the shipped APKs (26.35 has the server classes, 26.36 does not) and local R8 builds of 8d526ac586 and its parent.

Changes

  • profiler and privileged-services: hidden-API stubs implementation -> compileOnly, matching every other Shizuku module.
  • New consumer-rules.pro in shizuku-server and shizuku-starter, and rules in the previously empty one in privileged-services:
    • keep the two app_process entry points and ProfilerUserService's constructors;
    • keep rikka.hidden.compat.adapter.** public members and their subclasses' overrides. The rules name the adapters because their hidden-API superclasses are compile-only and invisible to R8.

Verification

Built :app:assembleV8Profileable (same R8 configuration as release) and checked the dex:

  • ShizukuService, ServiceStarter, UserService and a populated ProfilerUserService are present.
  • All 8 adapters keep every public method from the library; the observer overrides in BinderSender and ProfilerUserService are present.
  • No hidden-API stub classes are packaged. The only remaining rewritten call in Shizuku/hidden-API code is in Shizuku.scheduleBinderDeadListeners, which is unreachable: nothing registers a binder-dead listener.

No UI changes, so no font-scale check.

Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
…ir classes

Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
@itsaky-adfa itsaky-adfa self-assigned this Oct 19, 2026
@itsaky-adfa
itsaky-adfa requested a review from a team October 19, 2026 17:44

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot deleted a comment from atlassian Bot Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6b2a7051-3df9-497f-8268-9f02d21174df
📥 Commits

Reviewing files that changed from the base of the PR and between 21653d6 and fcef3d4.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b433097c-8976-4e9c-be6b-ee4d7a2e3962
📥 Commits

Reviewing files that changed from the base of the PR and between b305392 and 21653d6.

📒 Files selected for processing: 5
  • profiler/build.gradle.kts
  • subprojects/privileged-services/build.gradle.kts
  • subprojects/privileged-services/consumer-rules.pro
  • subprojects/shizuku-server/consumer-rules.pro
  • subprojects/shizuku-starter/consumer-rules.pro

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Summary
  • Change rikka.hidden.stub to compileOnly in profiler and privileged-services. This prevents the stub classes from being packaged as runtime dependencies.
  • Add consumer R8 rules to retain ShizukuService.main(String), ServiceStarter.main(String), ProfilerUserService constructors, and hidden-API adapter members and overrides needed by reflective calls, app_process, and framework callbacks.
  • Risk: The entry points and callbacks rely on keep rules matching the relevant classes and members. The supplied information reports one rewritten call in Shizuku.scheduleBinderDeadListeners; it says this call is unreachable because no binder-dead listener is registered.
  • Build and dex verification results are reported in the PR objectives, but no independent test results are provided here.

The profiler and privileged-services modules change rikka.hidden.stub from implementation to compileOnly. Consumer R8 rules preserve service entry points, public constructors, and adapter members in the privileged-services, shizuku-server, and shizuku-starter modules.

Changes: R8 Packaging and Keep Rules

Layer / File(s) Summary
Hidden stub dependency scope
profiler/build.gradle.kts, subprojects/privileged-services/build.gradle.kts
Both modules change rikka.hidden.stub from implementation to compileOnly.
Service entry-point keep rules
subprojects/privileged-services/consumer-rules.pro, subprojects/shizuku-server/consumer-rules.pro, subprojects/shizuku-starter/consumer-rules.pro
Consumer rules preserve ProfilerUserService public constructors and the main(String) entry points for ShizukuService and ServiceStarter.
Adapter member keep rules
subprojects/privileged-services/consumer-rules.pro, subprojects/shizuku-server/consumer-rules.pro
Consumer rules preserve public members of hidden-compatibility adapters and observer adapter subclasses.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 21653

The change keeps hidden stubs out of runtime packaging and preserves the intended service entry points in minified releases. No concrete merge-blocking regression is established.

Security architecture risk: 🔵 Low · up to 21653

The change restores existing privileged functionality without changing its caller checks or service permissions. No new unauthorized access path was established. Final minified behavior and failure-path cleanup remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relevant scope is the local device's Shizuku server and profiler user service, including platform-mediated process inspection and profiling. The inspected paths retain manager and package-ownership controls; no new cross-service, tenant, IAM, or secret authority is introduced by the dependency and retention declarations.

Trust Boundaries and Controls

  • observed — Application attachment verifies that the claimed package belongs to the Binder caller and matches the manager. User-service creation requires manager permission and verifies ownership of the requested component package. The manager permission comparison uses app ID, while package lookup uses the caller's user ID; these existing identity semantics are not strengthened or weakened by this PR.

Resilience and Maintainability Implications

  • observed — Normal disconnect requests service removal, and service exit aborts CPU work and unregisters observation. Last process-list client death stops observation and clears cached process state, but daemon mode intentionally permits the service process to survive connection death. These policies predate the PR; restoration makes their release-build behavior relevant again.
  • inferred — Existing observer attachment registers before seeding the snapshot. If seeding throws after successful registration, the failure branch unlinks the death recipient without unregistering the observer. Subsequent last-client teardown still attempts unregistration. This is an incomplete partial-startup rollback, but supported-device occurrence and a material security consequence were not established.

Hardening Proposals

  • proposed — As lifecycle hardening, make observer attachment rollback symmetric after snapshot failure and validate client-death cleanup and reconnection in the minified release variant. This is a proposal, not evidence of an exploitable regression.
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly summarizes the primary change: preserving Shizuku entry points and callbacks during R8 processing.
Description check Passed The description directly explains the R8-related failures, the dependency changes, the keep rules, and the verification results.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the build by moonlight,
Hidden stubs stay out of runtime sight.
Keep rules guard each service call,
Adapter members stand through all.
The carrots cheer; the rules are right.

Comment @coderabbitai help to get the list of available commands.

@itsaky-adfa
itsaky-adfa merged commit 97abdc3 into stage Oct 20, 2026
@itsaky-adfa
itsaky-adfa deleted the fix/ADFA-6650 branch October 20, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants