openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.9k stars 3.59k forks source link

[androiddebugbridge] Port is set randomly bu android 11 and 12. Detect the port with nmap #14194

Open bertrandgodefroy opened 1 year ago

bertrandgodefroy commented 1 year ago

Unfortunately, when wireless adb debug is activated a random port is selected on android > version 10. Make the thing detect the port with nmap.

Example :

PHONE=192.168.19.19 adb connect ${PHONE}:$( nmap -sT ${PHONE} -p30000-49999 | awk -F/ '/tcp open/{print $1}' )

Solution from https://forum.xda-developers.com/t/adb-wifi-how-to-specify-port-and-have-it-fix.4321669/

morph166955 commented 1 year ago

This is potentially not the best way to fix this. Some android platforms open ports in those ranges for other things as well. E.g. the shieldtv (which is android 11 currently) opens a high number port as part of the remote control functions. It's not an adb interface. I'm not saying I know how to fix this specific issue, which definitely looks annoying, but scanning and grabbing may not solve this in all cases.