Skip to content

fix: ask Shizuku for permission when Retry is tapped - #40

Open
kirtan05 wants to merge 1 commit into
aunchagaonkar:mainfrom
kirtan05:fix/request-shizuku-permission
Open

kirtan05 wants to merge 1 commit into
aunchagaonkar:mainfrom
kirtan05:fix/request-shizuku-permission

Conversation

@kirtan05

@kirtan05 kirtan05 commented Oct 25, 2026 •

Copy link
Copy Markdown

Problem

On a fresh install with Shizuku running, the app never gets Shizuku access. The main screen shows "Shizuku Access Denied", and tapping Retry only makes the card flash; the Shizuku permission dialog never opens.

Nothing in the app calls Shizuku.requestPermission(). SHIZUKU_PERMISSION_REQUEST_ID is declared in ShizukuNetworkControlDataSource but never used. Retry only re-runs checkCompatibility(), so the state goes Pending → PermissionDenied again, which is the "blink" reported in #36. It is not specific to One UI: I reproduced it on a Pixel 8 with stock Android 17.

Fixes #36

Change

  • NetworkControlDataSource.requestPermission(): the Shizuku version shows Shizuku's dialog and suspends until OnRequestPermissionResultListener answers. The listener is removed on every path (result, cancellation, exception). Binder errors count as "not granted" instead of crashing. If the user denied before (shouldShowRequestPermissionRationale()), it returns false, because Shizuku won't show the dialog again. The root version keeps the existing Utils.isRootGranted() check.
  • NetworkControlRepository.requestPermission(method) and a RequestPermissionUseCase, following the existing layering.
  • MainViewModel.retryCompatibilityCheck(): when the state is PermissionDenied(SHIZUKU), it asks for permission first and then re-checks. Extra taps while a request is open are ignored.
  • SettingsViewModel.retryCompatibilityCheck(): same, but only when Shizuku is the selected method, so a root user isn't shown a Shizuku dialog.
  • 3 tests in SettingsViewModelTest: requests when Shizuku is denied, doesn't request when root is selected, doesn't request when Shizuku is already compatible. ./gradlew test passes.

Testing

Pixel 8, Android 17 (CP3A.261005.005), Shizuku 13.7.0 (thedjchi fork, started over wireless debugging).

Before (v1.1.0) After (this branch)

Before: three taps on Retry, and no activity starts:

10-25 21:51:00.474 ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.supernova.networkswitch/.presentation.ui.activity.MainActivity}
10-25 21:51:00.633 ActivityTaskManager: Displayed com.supernova.networkswitch/.presentation.ui.activity.MainActivity for user 0: +167ms
10-25 21:51:04.068 adbd: adb shell: input tap 540 773
10-25 21:51:06.832 adbd: adb shell: input tap 540 773
10-25 21:51:09.592 adbd: adb shell: input tap 540 773

After: one tap on Retry opens Shizuku's dialog. After "Allow all the time", the app shows "Device Compatible":

10-25 21:51:52.727 ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.supernova.networkswitch.debug/com.supernova.networkswitch.presentation.ui.activity.MainActivity}
10-25 21:51:53.519 ActivityTaskManager: Displayed com.supernova.networkswitch.debug/com.supernova.networkswitch.presentation.ui.activity.MainActivity for user 0: +811ms
10-25 21:51:56.394 adbd: adb shell: input tap 540 773
10-25 21:51:56.598 ActivityTaskManager: START u0 {act=moe.shizuku.privileged.api.intent.action.REQUEST_PERMISSION flg=0x10080000 pkg=moe.shizuku.privileged.api cmp=moe.shizuku.privileged.api/moe.shizuku.manager.authorization.RequestPermissionActivity (has extras)}
10-25 21:51:56.682 ActivityTaskManager: Displayed moe.shizuku.privileged.api/moe.shizuku.manager.authorization.RequestPermissionActivity for user 0: +84ms
10-25 21:52:01.371 adbd: adb shell: input tap 540 1318

Notes

@kirtan05 kirtan05 mentioned this pull request Oct 25, 2026
3 tasks done
Nothing in the app called Shizuku.requestPermission(), so a fresh install
could never get Shizuku access: Retry only re-ran the compatibility check,
which flashed the loading state and went back to "Shizuku Access Denied".

Retry now shows Shizuku's permission dialog when the permission is missing,
waits for the answer, then checks again. Root keeps its existing check.
Repeated taps while a request is open are ignored, and a Shizuku binder
error while checking is treated as "not granted" instead of crashing.

Fixes aunchagaonkar#36
@kirtan05
kirtan05 force-pushed the fix/request-shizuku-permission branch from 180193d to 2c1c312 Compare October 25, 2026 16:26
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.

[BUG] Shizuku not connecting

1 participant