#302

Android 17: normal Shizuku start path triggers repeated “Choose a device to connect” picker

Opengamer765opened 1mo ago

Before You Begin

  • I am reporting an issue with Shizuku itself, NOT an issue about compatibility with another app
  • I read the wiki and followed all relevant troubleshooting steps
  • I searched through all issues and confirmed that this is a new bug
  • I am using the latest version of Shizuku

Requirements

  • Shizuku is not running in a virtual environment or broken ROM (e.g., GrapheneOS)
  • Xposed is not installed/enabled for Shizuku

Mode

adb

Shizuku Version

13.7.0

Android Version

17

Device

Samsung Galaxy S24 Ultra

Issue Description

On Android 17, starting Shizuku through the normal already-paired wireless debugging flow causes Android to show a system dialog:

Choose a device to connect
Shizuku wants to connect to a device on your local network

The device shown is the phone's own wireless ADB endpoint, for example:

adb-R5CX20STHLV-IUWgV1

Wireless debugging is already paired and trusted, and Always allow on this network has already been selected. The prompt is therefore separate from the normal wireless-debugging trust prompt and appears to be related to Android 17's Local Network Protection.

What I found

The Android 17 support added in PR #226 requests the local-network runtime permission in AdbPairingTutorialActivity:

  • android.permission.ACCESS_LOCAL_NETWORK on SDK 37
  • android.permission.NEARBY_WIFI_DEVICES on SDK 36

However, the normal already-paired start path appears to go through:

manager/src/main/java/moe/shizuku/manager/home/AdbDialogFragment.kt

where onDialogShow() currently starts mDNS discovery directly:

private fun onDialogShow(dialog: AlertDialog) {
    adbMdns.start()
    ...
}

There does not appear to be an ACCESS_LOCAL_NETWORK runtime permission check/request before adbMdns.start() on this path. On Android 17, that seems to cause the OS to intercept the local-network connection and display the per-device picker.

Expected behavior

After granting local-network access once, starting Shizuku through wireless ADB should work without requiring the user to select the local ADB endpoint each time.

Actual behavior

Each time Shizuku is started through the normal wireless ADB path, Android displays Choose a device to connect, and the local ADB endpoint must be selected manually.

Possible fix

The same local-network permission request used by AdbPairingTutorialActivity may also need to run before adbMdns.start() in AdbDialogFragment.

For example:

private val localNetworkPermissionLauncher =
    registerForActivityResult(
        ActivityResultContracts.RequestPermission()
    ) { granted ->
        if (granted) {
            adbMdns.start()
        }
    }

private fun startMdnsWithPermission() {
    val permission = when {
        Build.VERSION.SDK_INT >= 37 ->
            "android.permission.ACCESS_LOCAL_NETWORK"

        Build.VERSION.SDK_INT >= 36 ->
            Manifest.permission.NEARBY_WIFI_DEVICES

        else -> null
    }

    if (
        permission == null ||
        requireContext().checkSelfPermission(permission) ==
            PackageManager.PERMISSION_GRANTED
    ) {
        adbMdns.start()
    } else {
        localNetworkPermissionLauncher.launch(permission)
    }
}

Then onDialogShow() could call:

startMdnsWithPermission()

instead of calling adbMdns.start() directly.

Steps To Reproduce

  1. Run Android 17 on a Samsung Galaxy S24 Ultra.
  2. Install Shizuku 13.7.0 from this fork.
  3. Pair Shizuku with Wireless debugging normally.
  4. Enable Wireless debugging and select Always allow on this network when prompted.
  5. Stop Shizuku if it is already running.
  6. Start Shizuku again using the normal Wireless debugging / ADB start path.
  7. Observe Android displaying Choose a device to connect for the phone's own adb-* endpoint.
  8. Select the endpoint; Shizuku then starts normally.

Activity

0

No activity yet.