Skip to content

Fix Dadb.list() throwing on host with unauthorized/offline devices (#…#98

Open
aditya711-code wants to merge 1 commit into
mobile-dev-inc:masterfrom
aditya711-code:fix-listdadbs-unauthorized-neighbor
Open

Fix Dadb.list() throwing on host with unauthorized/offline devices (#…#98
aditya711-code wants to merge 1 commit into
mobile-dev-inc:masterfrom
aditya711-code:fix-listdadbs-unauthorized-neighbor

Conversation

@aditya711-code
Copy link
Copy Markdown

…55, #62)

When host:devices returns a mix of device and unauthorized/offline entries, listDadbs previously took every serial and called createDadb for each, which immediately tries to open host:features over a transport the unauthorized device cannot service. The throw aborts the whole .map block and Dadb.list() returns nothing — even healthy devices on the same host become invisible to dadb-based callers.

Two changes:

  1. listDadbs filters by state (device only) and wraps each createDadb call in runCatching so a single failing entry can't kill the whole returned list.

  2. AdbServerDadb.supportedFeatures is made by lazy so simply constructing an instance no longer eagerly triggers host:features. This means a fresh Dadb for a healthy device can be constructed without being affected by the state of unrelated devices on the host.

Verified end-to-end against Maestro CLI on a host with one unauthorized Android phone and one healthy emulator: stock dadb 1.2.9 fails with "Device was requested, but it is not connected" for the healthy emulator; with this patch the same flow runs to completion. Same hardware state, only the library version changed.

Fixes #55
Fixes #62

…obile-dev-inc#55, mobile-dev-inc#62)

When `host:devices` returns a mix of `device` and `unauthorized`/`offline`
entries, `listDadbs` previously took every serial and called `createDadb`
for each, which immediately tries to open `host:features` over a transport
the unauthorized device cannot service. The throw aborts the whole `.map`
block and `Dadb.list()` returns nothing — even healthy devices on the same
host become invisible to dadb-based callers.

Two changes:

1. `listDadbs` filters by state (`device` only) and wraps each
   `createDadb` call in `runCatching` so a single failing entry can't
   kill the whole returned list.

2. `AdbServerDadb.supportedFeatures` is made `by lazy` so simply
   constructing an instance no longer eagerly triggers `host:features`.
   This means a fresh `Dadb` for a healthy device can be constructed
   without being affected by the state of unrelated devices on the host.

Verified end-to-end against Maestro CLI on a host with one
`unauthorized` Android phone and one healthy emulator: stock dadb
1.2.9 fails with "Device <serial> was requested, but it is not
connected" for the healthy emulator; with this patch the same flow
runs to completion. Same hardware state, only the library version
changed.

Fixes mobile-dev-inc#55
Fixes mobile-dev-inc#62
@aditya711-code
Copy link
Copy Markdown
Author

@Leland-Takamine Hey can you check this out

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

Successfully merging this pull request may close these issues.

When one of the devices is offline, Exception has been throwed Dadb.list throws IOException on unauthorized device (OFFLINE)?

1 participant