Skip to content

Instantly share code, notes, and snippets.

@JakubMosakowski
Created May 28, 2021 08:28
Show Gist options
  • Save JakubMosakowski/082a1dddc2140333eea91f0c4b6ccfff to your computer and use it in GitHub Desktop.
Save JakubMosakowski/082a1dddc2140333eea91f0c4b6ccfff to your computer and use it in GitHub Desktop.

Revisions

  1. JakubMosakowski created this gist May 28, 2021.
    15 changes: 15 additions & 0 deletions adb-wifi.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/bin/bash

    # 1. Connect the phone using a USB cable.

    # 2. Restart adb listening on TCP on 5555 port.
    adb tcpip 5555

    # 3. Sleep for 1 second (not too clean but that's the simplest way to make sure that the previous command finished).
    sleep 1

    # 4. Find ip address.
    IP_ADDRESS=`adb shell "ip addr show wlan0 | grep -e wlan0$ | cut -d\" \" -f 6 | cut -d/ -f 1"`

    # 5. Connect to the device.
    adb connect $IP_ADDRESS:5555