Created
February 14, 2022 15:06
-
-
Save loloof64/b5d151e4c0eaca55ccc3e8dd90fc308f to your computer and use it in GitHub Desktop.
Connect android device by WiFi - Linux (tested on Ubuntu 20.04 64 bit)
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
echo 'Connect your android device by WIFI' | |
echo '-----------------------------------' | |
echo 'You must first ensure that :' | |
echo '1) Your device enable USB connection in the developper settings,' | |
echo '2) adb (Android debug bridge) command is in your path,' | |
echo '3) your device and your computer are on the same Wifi network.' | |
echo "Also don't forget to disconnect device from adb, you can run script disconnect_android_wifi for that." | |
echo "Then plug your device by USB and press ENTER when you're ready:" | |
read dummy_variable | |
version_number=$(adb shell getprop | grep ro.build.version.sdk | sed -n 's/[^0-9]*\([0-9]*\)[^0-9]/\1/p') | |
adb tcpip 5555 > /dev/null | |
sleep 3 | |
if [ $version_number -lt 24 ]; then | |
ip_adress=$(adb shell netcfg | grep -o -P '192\.\d+\.\d+\.\d+' | sed -n 's/\(.*\)/\1/p') | |
else | |
ip_adress=$(adb shell ifconfig | grep -o -P '192\.\d+\.\d+\.\d+' | head -n 1) | |
fi | |
echo "Now unplug the device from the computer, and press ENTER when you're ready:" | |
read dummy_variable | |
adb connect $ip_adress > /dev/null | |
echo "Done !" | |
echo "Don't forget to disconnect when you're done !" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment