XPost: alt.comp.os.windows-10, comp.mobile.android, alt.msdos.batch   
   From: cris@removespam.me.com   
      
   Andy Burnelli wrote:   
      
   > How do we find the random Android wireless debugging port from a Windows PC?   
   >   
   > Or, if we can't find the exact port, maybe we can search a set of ports?   
      
   You and everyone else since Android 11 wants to know the same answer.   
   https://medium.com/@amanshuraikwar.in/connecting-to-android-devi   
   e-with-adb-over-wifi-made-a-little-easy-39439d69b86b   
      
   If you can port this to Windows command line it might work but you might need   
   to be an admin.   
   https://gist.githubusercontent.com/amanshuraikwar/384ed1a77b1c5b   
   e577c219297b5882e/raw/4d80e2e1f25d017276c298f076d4f7c86c442728/a   
   bwificonnect.sh   
      
    # Purpose: Shell script to connect a USB connected device via adb over WiFi   
    #   
    # Author: Amanshu Raikwar   
    #   
    # Assumptions:   
    # 1. USB debugging is enabled in the Android device   
    # 2. The Android device is connected to the computer via USB   
    # 3. The Android device is connected to the same wifi as the computer   
    # 4. The Android device is accessible through port 5555 over the wifi   
   network   
    #   
    # How To Use (without any options):   
    # 1. Paste the file where adb resides, for mac it is ~/Librar   
   /Android/sdk/platform-tools/   
    # 2. Run ./adbwificonnect   
    # 3. Choose the device by typing X in [X] --> ... when prompted   
    # 4. Wait around 6-7 seconds   
    # 5. Connected!   
    #   
    # Options:   
    # -a   
    # To connect to all available devices   
    #   
    # -d device_id   
    # Specifies the device id to be connected to   
      
    # if no command line params provided   
    if [ -z "$1" ]; then   
      
    clear   
      
    # list available devices   
    echo "Available devices:"   
    devices="$(./adb devices)"   
      
    export IFS=$'\n'   
      
    declare -a devicemap   
      
    i=0   
      
    # save device info in an array   
    for word in $devices; do   
    devicemap+=("$(echo $word | awk '{print $1}')")   
    echo "[$i] --> $word"   
    i=$((i+1))   
    done   
      
    # wait for user input to choose device   
    read -p "Choose device: " choice   
      
    # chosen device id   
    device=${devicemap[choice]}   
      
    devicename="$(./adb devices -l | grep $device | awk '{print $4}' | cut -d:   
   -f2)"   
    devicemodel="$(./adb devices -l | grep $device | awk '{print $5}' | cut -d:   
   -f2)"   
      
    echo "Connecting to device $device $devicename $devicemodel..."   
      
    # restart adb in tcpip mode for the device   
    ./adb -s $device tcpip 5555   
      
    # wait for adb to restart   
    # note: this may change depending on the computer   
    sleep 5s   
      
    # find out the wlan0 ip of the device by running ifconfig in device's shell   
    ip="$(./adb -s $device shell ifconfig wlan0 | grep 'inet addr' | cut -d:   
   -f2 | awk '{print $1}')"   
    echo "Connecting to $ip..."   
      
    # connect to the device   
    ./adb connect $ip:5555   
      
    # connect to all available devices   
    elif [ $1 == "-a" ]; then   
       
    # list available devices   
    echo "Connecting to all available devices..."   
    devices="$(./adb devices)"   
      
    export IFS=$'\n'   
      
    declare -a devicemap   
      
    i=0   
      
    # iterate for each device and connect   
    for word in $devices; do   
       
    # device id   
    device=("$(echo $word | awk '{print $1}')")   
       
    # skip the first line   
    if [ "$i" != "0" ]; then   
      
    echo "---"   
      
    devicename="$(./adb devices -l | grep $device | awk '{print $4}' | cut   
   -d: -f2)"   
    devicemodel="$(./adb devices -l | grep $device | awk '{print $5}' | cut   
   -d: -f2)"   
      
    echo "Connecting to device $device $devicename $devicemodel..."   
      
    # restart adb in tcpip mode for the device   
    ./adb -s $device tcpip 5555   
      
    # wait for adb to restart   
    # note: this may change depending on the machine   
    sleep 5s   
      
    # find out the wlan ip of the device by running ifconfig in device's shell   
    ip="$(./adb -s $device shell ifconfig wlan0 | grep 'inet addr' | cut -d:   
   -f2 | awk '{print $1}')"   
    echo "Connecting to $ip..."   
      
    # connect to the device   
    ./adb connect $ip:5555   
      
    fi   
       
    i=$((i+1))   
    done   
      
    # connect to a specific device   
    elif [ $1 == "-d" ]; then   
      
    if [ -z "$2" ]; then   
    echo "-d expects device id as the second parameter"   
    exit 1   
    fi   
      
    device="$2"   
      
    devicename="$(./adb devices -l | grep $device | awk '{print $4}' | cut -d:   
   -f2)"   
    devicemodel="$(./adb devices -l | grep $device | awk '{print $5}' | cut -d:   
   -f2)"   
      
    echo "Connecting to device $device $devicename $devicemodel..."   
      
    # restart adb in tcpip mode for the device   
    ./adb -s $device tcpip 5555   
      
    # wait for adb to restart   
    # note: this may change depending on the machine   
    sleep 5s   
      
    # find out the wlan ip of the device by running ifconfig in device's shell   
    ip="$(./adb -s $device shell ifconfig wlan0 | grep 'inet addr' | cut -d:   
   -f2 | awk '{print $1}')"   
    echo "Connecting to $ip..."   
      
    # connect to the device   
    ./adb connect $ip:5555   
      
    else   
    echo "Flag '$1' is not supported!"   
    fi   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|