fix(appium): skip data connectivity on devices without telephony (#5677) - #5678
Open
mirao wants to merge 1 commit into
Open
fix(appium): skip data connectivity on devices without telephony (#5677)#5678mirao wants to merge 1 commit into
mirao wants to merge 1 commit into
Conversation
…eceptjs#5677) `mobile: setConnectivity` runs `adb shell svc <type> <state>` for every field it is passed, so always sending `data` made setNetworkConnection() fail with "Can't find service: phone" (adb exit 20) on system images without telephony, such as tablet emulators. This regressed in 4.1.0, when codeceptjs#5662 replaced the legacy setNetworkConnection command, which tolerated the missing phone service. Probe `mobile: deviceInfo` for a carrier and only send `data` when the device actually has telephony. Dropping `data` unconditionally is not an option: on a telephony-capable device it leaves cellular up, so going offline silently does nothing and tests keep passing against a device that is still online. Only a positive probe result is cached. A freshly booted device may not have registered a carrier yet, and since the first call typically comes from a suite-setup hook seconds after boot, caching that negative would strip `data` for the rest of the session on a real phone. Guarding with `!this._hasTelephony` re-asks until a carrier appears, then stops. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5677
Problem
mobile: setConnectivityrunsadb shell svc <type> <state>for every field it is passed, so always sendingdatamakessetNetworkConnection()fail on system images without telephony (e.g. tablet emulators,ro.build.characteristics=tablet):This is a regression in 4.1.0 — #5662 replaced the legacy
setNetworkConnectioncommand, which tolerated the missing phone service. It takes down whole suites when the call sits in a_beforeSuitehook.Fix
Probe
mobile: deviceInfofor a carrier and only senddatawhen the device actually has telephony.Dropping
dataunconditionally is not an option: on a telephony-capable device it leaves cellular up, sosetNetworkConnection(1)keeps the device online and "go offline" silently does nothing.Only a positive probe result is cached. The first
setNetworkConnectionof a run typically happens in a suite-setup hook, seconds after the emulator boots — a real phone whose modem has not registered a carrier yet would report an emptycarrierNamethere, and caching that negative would stripdatafor the rest of the session. Guarding with!this._hasTelephonyre-asks until a carrier appears, then stops probing._hasTelephonyundefined— never probedfalse— probed, no carrier seentrue— probed, carrier seenThe cost is one extra
mobile: deviceInfoper call on a genuinely telephony-less device. That is a plain info read, so unlike the send-and-catch alternative it provokes no exception and adds no redERROR webdriver:line to tablet runs.carrierNameis still reported while airplane mode is on, so the probe is not perturbed by the connectivity state being changed.grabNetworkConnection()is unaffected —mobile: getConnectivityworks on these images.Verified
Unit tests added for the telephony-less payload, the re-probe while no carrier has been seen, and probe-once-then-cache after a carrier appears. Full file passes (11 passing).
Verified as a patch against 4.1.0 on two live emulators —
sdk_gtablet_x86_64(Android 15, no telephony) andsdk_gphone64_x86_64(Android 13, carrierT-Mobile):NetworkConnectionIndicatorNetworkConnectionIndicatorStudentAttendanceDndGameWithoutLessonPathNo
ERROR webdriver:line and noCan't find service: phonein any run.StudentAttendanceis the test that originally caught the dropped-datafailure, so its 54 passing scenarios confirm going offline still genuinely disconnects on a telephony-capable device.🤖 Generated with Claude Code