1

I would like to know is it possible to connect to multiple devices using TCP (adb connect x.x.x.x) and then send commands to all of them at same time?

For example get 3 devices, put them on same subnet, connect and then open settings screen on all of them at the same time using adb shell am start -n com.android.settings/.Settings.

I know you can do something like this using USB cables, you can even list both devices in eclipse but is this possible using wireless connection.

Igor Čordaš
  • 5,785
  • 4
  • 42
  • 54
  • possible duplicate of [How can I adb install an apk to multiple connected devices?](http://stackoverflow.com/questions/8610733/how-can-i-adb-install-an-apk-to-multiple-connected-devices) – EvZ Oct 17 '14 at 10:17
  • 1
    @EvZ Not a duplicate, it needs a additional step to connect to all the deices, before we can use the answer in the link you provide – Naveen Kumar Nov 17 '14 at 07:56
  • Did you get a way to do it? – MiguelHincapieC Apr 19 '16 at 22:21

1 Answers1

1

Firstly, store the below command in your bashprofile to ping all devices in parallel (all at once).

alias adball="adb devices | egrep '\t(device|emulator)' | cut -f 1 | xargs -t -J% -n1 -P5 adb -s % \"\$@\""

And now simply call adb commands.

For example, I have two devices connected (connected via Wifi in my case. But this logic also works for usb connection). And I wanted to know their window sizes. Then do:

adball shell wm size

Output:

adb -s 172.30.132.4:5555 shell wm size

adb -s 172.30.16.95:5555 shell wm size

Physical size: 1080x2400

Physical size: 1440x2960

Override size: 1080x2220

  • for me it's `grep -P '\t(device|emulator)'` but I'm still getting `xargs: invalid option -- 'J'` – mcExchange Sep 02 '21 at 08:55
  • found it. `-P` must be `-i` which places the argument at the position of `%` . Thus `alias adball="adb devices | grep -P '\t(device|emulator)' | cut -f 1 | xargs -t -i% -n1 -P5 adb -s % \"\$@\""` – mcExchange Sep 02 '21 at 09:06