ADBScreen: getDevices: not implemented/removed --- workaround

Asked by Ngoc Le

**************************** workaround
devices = []
scr = ADBScreen()
while scr.isValid():
    devices.append(scr)
    scr = ADBScreen(len(devices))

print "attached devices:", len(devices)
n = 0
for scr in devices:
    print "%d = %s" % (n, scr)
    n += 1
---------------------------------------------------------------
Hi,

I am writing a PC application which allows to connect with multiple Android Emulator (I am using Nox player). Everything is just working well, except I cannot get the list of devices are connected to the PC. It is fine to get the first device by calling getDevice function from ADBScreen.
I saw that there is another function getDevices in this class but if it always return empty array. So my question is how can I get list of connected devices.

Thanks in advance,
Ngoc LE

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Ngoc Le (ngoclt) said :
#1

I actually see the issue in the code. And it seems like the implementation is not done yet.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

Sorry for the delay, other priorities.

--- it seems like the implementation is not done yet
yes, correct.
The problem with the current overall implementation is, that the access to the ADB bridge is hidden.
Simply returning the device list would not help much.

What is missing is a list of ADBScreen objects for every attached device (something like multimonitor support).
Another point is, that for special purposes there should be a better direct access to the ADB bridge via the established jadb.

Since I was unsure about the implementation of getDevices() at that time, I stopped it and lost it ;-)

Using
scr = ADBScreen(id)

you can select another attached device as a workaround.

Revision history for this message
RaiMan (raimund-hocke) said :
#3

I just had a look into the code:
- I have removed the getDevices() method (makes no sense in the SikuliX context)
- for now (other priorities) there will not be a feature to list the attached devices

workaround:
devices = []
scr = ADBScreen()
while scr.isValid():
    devices.append(scr)
    scr = ADBScreen(len(devices))

print "attached devices:", len(devices)
n = 0
for scr in devices:
    print "%d = %s" % (n, scr)
    n += 1

Revision history for this message
Ngoc Le (ngoclt) said :
#4

Thank you very much for your response,

So I actually have some idea for this implementation. I have just started to work on it, and want to implement this getDevices function, but it requires lots of refactoring work on ADBScreen class. And it may affect your plan.
My question is can I create a PR to contribute to this project? I would love to.

Revision history for this message
RaiMan (raimund-hocke) said :
#5

LOL, more than welcome.

Do what ever you think makes sense.

--- And it may affect your plan.
Not really - nothing cannot be affected ;-)
I do neither have the experience nor the resources, to move the ADB support one or more steps further.

One more thing:
Do you know the scrcpy project:
https://github.com/Genymobile/scrcpy

Some weeks ago, I checked, wether it could speed up getting shots from the device, but did not succeed to get it working for me.

Revision history for this message
Ngoc Le (ngoclt) said :
#6

I don't know that project. So is it similar to VNC? And what would you like to do with this?

Revision history for this message
RaiMan (raimund-hocke) said :
#7

--- So is it similar to VNC?
roughly yes, but a different approach.

--- And what would you like to do with this?
as mentioned: it looked like, that it could be faster getting screenshots from the device than with the current implementation.
But surely not a priority.

Can you help with this problem?

Provide an answer of your own, or ask Ngoc Le for more information if necessary.

To post a message you must log in.