Swind / pure-python-adb

This is pure-python implementation of the ADB client.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does the abd support concurrent operations?

songyuc opened this issue · comments

Hi guys,
I am a learner of python-abd, and I want to know whether this support concurrent operations at the same time, for example, whether two input_swipe() operations are allowed to run in two separate processes, like human can use two fingers to swipe in two regions simultaneously.

Any idea or answer will be appreciated!

ppadb can be used in a multi-threaded setting. However, what you are trying to do is possibly a limitation in adb.

Easiest way to try what you are trying to do is by opening two terminals on your host computer and perform the input swipe command through 2 adb shell commands on both terminals.

If that works, I am certain that you can do it in ppadb as well.

Hi, @ebisek-logi , thanks for your information and sharing.
I have a similar feeling that adb might not be able to realize concurrent operations like real humans.
And there is another key point is whether adb communication is serial port communication. Because it is serial communication, even if 2 adb shells can work together, they still did the operations in the serial way instead of parallel way.

Hello @songyuc ,
That is not entirely correct. It really is about synchronous versus asynchronous support inside the Android framework. Simply put if you can send a touch-down, move, touch-up command in one shell and the same in another, then the serialization would not be a factor.
I am not a UI automation expert in Android (I focus more on hardware and embedded), but I am pretty sure that with the above approach you can make it work with ppadb and with regular adb.
-Edwin

commented

I have a question that kind of fits the title. I need to spawn a process (netcat) on the device without my Python program hanging up and waiting for the process to end (which it doesn't / shouldn't) which is what happens if I just use device.shell(xxx).

What would you recommend to achieve this? It is possible to do via ADB, that I know for sure because I used pwnlibs' ADB feature to do the same thing before.

commented

@unixb0y I needed something similar and wanted to run a binary "forever", so I implemented the following workaround:

https://github.com/Hamz-a/frida-android-helper/blob/787590bdfc3fb13474b90bd3e8faee567425a944/frida_android_helper/server.py#L32

Basically, your command will look like:

device.shell('/data/local/tmp/nc && sleep 2147483647 &', timeout=1)

Prepend the command with su -c if u need to run nc with root. The workaround consists of running the binary that needs to run forever, then right after it a "forever" sleep command and configure the shell function with a timeout of 1s.

commented

@Swind I think this issue can be closed.