Repository navigation
feat(driver): support the adbHost capability - #155
carrerasdarren-cell wants to merge 3 commits into
Conversation
mykola-mokhnach
left a comment
There was a problem hiding this comment.
- [minor]
packages/driver-lib/lib/commands/device/utils.ts:125:createBaseADBstill reads onlyremoteAdbHost, so the new capability works only through the back-copy invalidateDesiredCaps. A subclass or code path that setsopts.adbHostany other way (for exampleinitialOpts) gets no-Hand falls back to the local ADB server without an error. Consider resolving the host here too (remoteAdbHost: adbHost ?? remoteAdbHost) so the value is chosen at the point where ADB consumes it. - [minor]
packages/driver-lib/lib/constraints.ts:45:remoteAdbHostis now deprecated, but only a runtime log line says so. Consider a@deprecatednote pointing toadbHost, if the constraints or types can carry one. - [minor]
packages/driver-lib/test/unit/driver.spec.ts: add tests for an empty-stringremoteAdbHost, for the deprecation warning, and foradbHostsupplied outside the session caps. The current cases only cover the happy paths and the legacy-wins precedence.
|
|
||
| Appium Android Driver is the collection of common primitives used by other Android drivers, like UIA2/Espresso. This driver cannot work as a separate entity. | ||
|
|
||
| Use the string capability `appium:adbHost` to select the host running the ADB server, and |
There was a problem hiding this comment.
[nit] This text says the deprecated name "takes precedence", which reads as the opposite of the migration advice. adbPort is existing, unchanged behaviour, so it doesn't belong in this feature's note. This intro paragraph is also an odd home for capability documentation, and there is no changelog or capability-docs entry for the new capability.
mykola-mokhnach
left a comment
There was a problem hiding this comment.
- [minor] Tests only exercise a bare
AndroidDriver.createSession(test/unit/driver.spec.ts). A subclass that callsBaseDriver.prototype.createSessiondirectly (as UIA2 does) would leaveopts.remoteAdbHostunset and still pass. After the fix for thecreateSessioncomment, please add a test for that path. - [minor] Docs: the README note is in driver-lib only.
appium-uiautomator2-driver(docs/reference/capabilities.md:443) and the Espresso docs still describe onlyappium:remoteAdbHost. Is a follow-up planned there? - [nit]
caps.remoteAdbHost != null(driver.ts:351) also warns forremoteAdbHost: '', which carries no host. Consider a truthiness check.
| return true; | ||
| } | ||
|
|
||
| override async createSession(w3cCapabilities: W3CDriverCaps<C>) { |
There was a problem hiding this comment.
[major] This override never runs for the UiAutomator2 driver. Its createSession calls BaseDriver.prototype.createSession.call(this, …) (appium-uiautomator2-driver master, lib/driver.ts:297), which skips AndroidDriver.createSession. A UIA2 client that sends only appium:adbHost: 'remote' gets ADB pointed at remote (createBaseADB does adbHost || remoteAdbHost). Meanwhile opts.remoteAdbHost stays unset, and UIA2 builds the server client host from it (lib/uiautomator2-server/session.ts:343: this.opts.remoteAdbHost || LOCALHOST_IP4). ADB talks to the remote host while the server client targets localhost, so the session fails or talks to the wrong machine once UIA2 picks up this driver-lib version. Espresso calls super.createSession and is unaffected by the bypass, but it also reads only opts.remoteAdbHost (lib/commands/server/startup.ts:150).
Resolving the host in one place that every driver reaches would be sturdier, for example a shared getAdbHost() helper in driver-lib. UIA2/Espresso would read that instead of opts.remoteAdbHost, and the post-hoc mutation of opts would go away. Otherwise the normalization needs to live somewhere UIA2 can't bypass.
| if (caps.remoteAdbHost != null) { | ||
| this.log.warn("The 'remoteAdbHost' capability is deprecated. Use 'adbHost' instead."); | ||
| } | ||
| const host = caps.adbHost || caps.remoteAdbHost || opts.adbHost || opts.remoteAdbHost; |
There was a problem hiding this comment.
[minor] The adbHost-over-remoteAdbHost precedence is implemented twice, here and in createBaseADB. The two copies already differ: here it's caps.adbHost || caps.remoteAdbHost || opts.adbHost || opts.remoteAdbHost, there it's opts only. Because this override can be skipped (see above), they can return different hosts for the same session. Please route both through one helper.
Addresses appium/appium#9376.
Android sessions can select the ADB server with
appium:adbHost. The deprecatedappium:remoteAdbHostcontinues to work and logs a warning when it has a nonempty value. A nonemptyadbHosttakes precedence when both names are supplied. The session response preserves the capabilities the client sent, and the shared driver usesgetAdbHost()for its ADB factory and exposes the same resolver to downstream drivers.I used OpenAI Codex to implement and test this change. The TypeScript build, repository lint and formatting checks, and all 383 shared Android driver unit tests passed. Eight local checks exercised the real Appium ADB wrapper against a synthetic executable, verifying the selected host, arguments, runtime options and returned capabilities for defaults, aliases, conflicting and empty values, and initial options. Validation was device-free.
Shared host follow-up
The resolver now works when a subclass calls
BaseDriver.createSessiondirectly. It leaves session capabilities and runtime options intact. The new tests check that path and verify that the ADB factory and the accessor agree.UiAutomator2 and Espresso still need to switch their proxy host lookups to
getAdbHost()and update their capability docs once a compatible shared-driver version is available. The UiAutomator2 and Espresso dependency checks in this PR exercise the published drivers to the synthetic device-discovery boundary and confirm the shared resolution across 12 cases. The TypeScript build, all 385 shared-driver unit tests, repository lint, and formatting passed on this revision.