Skip to content

Instantly share code, notes, and snippets.

@kairusds
Last active December 22, 2024 00:22
Show Gist options
  • Save kairusds/1d4e32d3cf0d6ca44dc126c1a383a48d to your computer and use it in GitHub Desktop.
Save kairusds/1d4e32d3cf0d6ca44dc126c1a383a48d to your computer and use it in GitHub Desktop.
Instructions for connecting Termux's android-tools adb to the current device via Wireless debugging and fixing phantom process killing

Install android-tools if you haven't already:

pkg update ; pkg upgrade
pkg install android-tools

adb pair localhost:port

Where port is taken from the menu shown after clicking from Developer options > Wireless debugging > Pair device with pairing code. Use splitscreen to show the Wireless debugging setting below the Termux app when pairing.


After pairing successfully, run the following commands to either connect or disconnect:

adb connect localhost:port

adb disconnect

Where port is shown in the Wireless debugging menu as IP address & Port.


After you're done with adb, make sure to close the daemon:

adb kill-server

After Termux has connected via Wireless debugging, run the command below to fix phantom process killing. (Android 12L and above)

adb shell "settings put global settings_enable_monitor_phantom_procs false"
@kairusds
Copy link
Author

In Termux, all IP address can be set as 127.0.0.1. You can only focus on the port and pairing code information.

Oh ty for the tip, I wasn't aware of that.

@weskerty
Copy link

weskerty commented Oct 3, 2024

Thank you very much. Just what I needed.

@weskerty
Copy link

adb shell "/system/bin/device_config set_sync_disabled_for_tests persistent"

adb shell "/system/bin/device_config put activity_manager max_phantom_processes 2147483647"

adb shell settings put global settings_enable_monitor_phantom_procs false

adb shell cmd deviceidle whitelist +com.termux

adb shell cmd appops set com.termux RUN_IN_BACKGROUND allow

adb shell cmd appops set com.termux RUN_ANY_IN_BACKGROUND allow

adb shell cmd appops set com.termux SYSTEM_EXEMPT_FROM_ACTIVITY_BG_START_RESTRICTION allow

adb shell cmd appops set com.termux SYSTEM_EXEMPT_FROM_HIBERNATION allow

adb shell cmd appops set com.termux SYSTEM_EXEMPT_FROM_POWER_RESTRICTIONS allow

adb shell cmd appops set com.termux SYSTEM_EXEMPT_FROM_SUSPENSION allow

adb shell cmd appops set com.termux WAKE_LOCK allow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment