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

Discover and create are hanging endlessly #21

Open
sharpordie opened this issue Jun 29, 2022 · 3 comments
Open

Discover and create are hanging endlessly #21

sharpordie opened this issue Jun 29, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@sharpordie
Copy link

sharpordie commented Jun 29, 2022

The discover and create functions are hanging as long as the allow button has not been clicked.
Internally this is the open function that blocks endlessly.
Is this the desired behavior? If so, why?

val dadb = Dadb.discover("192.168.1.62")

screen

It would be great to throw timeout exception after x seconds.
Or throwing something like AuthorizationRequiredException or FailedAuthenticationException would be even better.

It's trivial with the official binary, you just have to check the connect output.

adb connect 192.168.1.62
* daemon not running; starting now at tcp:5037
* daemon started successfully
failed to authenticate to 192.168.1.62:5555
@sharpordie
Copy link
Author

sharpordie commented Jul 5, 2022

I have edited the first post hoping to be more explicit about the problem and/or the possibility of improvement.

@sharpordie sharpordie changed the title How to know if connection requires approval? Discover and create are hanging endlessly Jul 5, 2022
@lanzorg
Copy link

lanzorg commented Jul 7, 2022

You can defer the discover call, wait a little bit and throw exception if it's still null.

var dadb: Dadb? = null
val running = async { dadb = Dadb.discover("192.168.1.62") }
Thread.sleep(5000L)
running.cancel()
if (dadb == null) throw AuthorizationRequiredException()

@dmitry-zaitsev dmitry-zaitsev added the enhancement New feature or request label Jul 14, 2022
@dmitry-zaitsev
Copy link
Contributor

@lanzorg a coroutine might not be the best choice in this case as canceling it won't interrupt underlying operations in Dadb (it is not cooperative). Starting a thread {} and then calling thread.interrupt() would be a better option.

Either way, I will discuss it with the team and see if this is something that should be a part of the library itself

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

No branches or pull requests

3 participants