Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aentwist opened this issue Aug 9, 2024 · 1 comment

Comments

@aentwist
Copy link

aentwist commented Aug 9, 2024

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

self.socket = connect(self.hostname, self.port, self.timeout)

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

devices = self.getDevices()
if len(devices) == 0 and timeout > 0:
print("Empty device list, will wait %s secs for devices to appear" % self.timeout, file=sys.stderr)

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 aentwist changed the title ViewClient.connectToDeviceOrExit does not connect to devices, it only lists devices that are already connected and uses them ViewClient.connectToDeviceOrExit does not connect to (remote?) devices, it only lists devices that are already connected and uses them Aug 9, 2024
@dtmilano
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants