Skip to content

#2237 fix: set up and auto start Expert Mode on Android TV with network ADB - #2340

Open
arch-fan wants to merge 3 commits into
keymapperorg:developfrom
arch-fan:fix/2237-android-tv-pairing
Open

arch-fan wants to merge 3 commits into
keymapperorg:developfrom
arch-fan:fix/2237-android-tv-pairing

Conversation

@arch-fan

Copy link
Copy Markdown

Fixes #2237.

Problem

On Android TV the Expert Mode setup gets stuck at "Pair wireless debugging", so Expert Mode can only be started manually with adb shell and never auto starts after a reboot.

I looked into why on a Xiaomi TV Box S (3rd gen, Google TV, Android 14):

  • The pairing code can only be typed into a heads up notification, and Android TV has no way to reply to notifications.
  • The interactive assistant can't read the code either. It only looks at com.android.settings, and Android TV uses com.android.tv.settings. Even after adding that package, Google TV hides the developer options screens from accessibility services. rootInActiveWindow is null on both DevelopmentActivity and Xiaomi's MiDevelopmentActivity, while the main Settings screen is readable.
  • The pairing port closes as soon as the pairing screen is left (I checked the port before and after pressing Home), so typing the code into Key Mapper's own screen wouldn't work either.

Change

Android TV devices often keep network ADB (adb tcpip 5555) on, which is how Shizuku starts on TV ("5555" button). AdbClient already supports the non-TLS handshake with RSA auth, so on Android TV Key Mapper now uses 127.0.0.1:5555 when that port is open:

  • AdbManager.executeCommand connects to port 5555 instead of discovering the wireless debugging port. The first connection shows the system "Allow debugging?" prompt with Key Mapper's key, and the user accepts it with the remote ("Always allow"). Expert Mode already sets adb_allowed_connection_time to 0, so the authorization doesn't expire.
  • The setup wizard skips the wireless debugging and pairing steps and goes straight to "Start service".
  • Auto start doesn't turn wireless debugging on or off when it uses network ADB.
  • This is limited to TV devices (UI_MODE_TYPE_TELEVISION), so phones that have adb tcpip turned on behave the same as before.

Separate small fix: after booting, auto start ran before shared storage was mounted (Not auto starting with ADB because the storage is unavailable) and never retried, because the eligibility flow doesn't emit again. SystemBridgeAutoStarter now waits for storage with the same 6 × 10 s retry that SystemBridgeConnectionManager already uses to refresh the starter script.

Testing

On a Xiaomi TV Box S (3rd gen), Android 14, ci build:

CHANGELOG updated.

🤖 Generated with Claude Code

arch-fan and others added 3 commits November 30, 2026 15:43
…V with network ADB

Android TV can not pair wireless debugging: the pairing code can only be
typed into a heads up notification, Google TV hides developer options from
accessibility services, and the pairing port closes when leaving the
pairing screen. Use network ADB on port 5555 instead when it is open on a
TV. The first connection shows the system "Allow debugging?" prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Auto start gave up straight away if the shared storage was not mounted
yet and nothing triggered it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Pair wireless debugging does not function on Android TV/LineageOS TV

1 participant