-
-
Save junkblocker/1456dda9d48544ead8f32765997f9ecb to your computer and use it in GitHub Desktop.
Android debugging over WiFi (use adb)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This shell script is made by SyneArt <[email protected]> | |
# Android Studio default path on Mac | |
adb=~/Library/Android/sdk/platform-tools/adb | |
function connect() { | |
device_id=$1 | |
device_ip=`${adb} -s ${device_id} shell ip -f inet addr show wlan0 | grep -e "[0-9].*\/[0-9]*" | awk '{ print $2 }' | sed 's/\/[0-9]*//'` | |
echo "Android device id: ${device_id}" | |
${adb} -s ${device_id} tcpip 5555 | |
${adb} connect ${device_ip} | |
} | |
while IFS= read -r line; do results_device_id+=("$line"); done < <(${adb} devices | grep -v "devices\|:" | grep "device\|offline" | cut -f 1) | |
[[ "${#results_device_id[@]}" -eq "0" ]] && echo "No any android devices need to switch to WiFi debug mode!" | |
for ((k=0; k<"${#results_device_id[@]}"; k++)) | |
do | |
connect ${results_device_id[$k]} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment