AndroidViewClient icon indicating copy to clipboard operation
AndroidViewClient copied to clipboard

`ViewClient.connectToDeviceOrExit` does not connect to (remote?) devices, it only lists devices that are already connected and uses them

Open aentwist opened this issue 1 year ago • 1 comments

The only connecting AdbClient does is to the adb server, not any devices

https://github.com/dtmilano/AndroidViewClient/blob/8738d3af40921b861f25780b4a92b5b6d4990af1/src/com/dtmilano/android/adb/adbclient.py#L267

Then after not doing any connecting to devices, they are listed

https://github.com/dtmilano/AndroidViewClient/blob/8738d3af40921b861f25780b4a92b5b6d4990af1/src/com/dtmilano/android/adb/adbclient.py#L471-L473

This results in a blank list and failure

$ ./adb devices
List of devices attached

When I actually connect

$ ./adb connect 127.0.0.1:7555
connected to 127.0.0.1:7555
$ ./adb devices
List of devices attached
127.0.0.1:7555  device

Only then do I find immediate success with connectToDeviceOrExit

from com.dtmilano.android.viewclient import ViewClient


adb_client, _ = ViewClient.connectToDeviceOrExit()

What is the idea behind this? The method name is misleading without any context. Have I misunderstood something in trying to get to the bottom of things?

Note that I just switched emulators and the new one uses port 7555 instead of 5555. I did not have this issue with the old emulator - maybe it ran adb connect itself?

Any feedback is appreciated. I was not able to find a way to run adb connect before using connectToDeviceOrExit after reading the wiki and API docs. This leaves me thinking that this library is not right for me since my use case is simple.

Edit: it seems like maybe this usage falls under "remote" devices, so this issue might be specific to that

aentwist avatar Aug 09 '24 23:08 aentwist

The most used way to connect to a device using the default back-end is

vc = ViewClient(*ViewClient.connectToDeviceOrExit())

when you want an instance of ViewClient.

If you don't, as generated by culebra, you can get the device and serialno after connecting

kwargs1 = {'verbose': False, 'ignoresecuredevice': False, 'ignoreversioncheck': False}
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)

dtmilano avatar Aug 12 '24 02:08 dtmilano