Skip to content

Conversation

@vdanti
Copy link

@vdanti vdanti commented Dec 15, 2025

[ISSUE]

Regarding the current codebase (adb.ts) :

image

If there is no proxy configured on the device, the function returns a ProxyOptions with ip=undefined and port=0.
This ProxyOptions is used to save the state of the wifi proxy before applying the new configuration, so that the previous state can be restored automatically :

  • when the Appium session is deleted (deleteSession hook in plugin.ts)
  • when the Appium session is closed because of an unexpected error (onUnexpectedShutdown hook in plugin.ts)
image

The problem is that the ip and port are not checked before executing the adb command (so the command can be run with ip=undefined and port=0), resulting the proxy to not be deactivated correctly and the device to loose its internet connection.

[SOLUTION]

Improve checks on the response of the adb command (adb shell settings get global http_proxy) :

  • if the response is undefined / :0 / null, then returns undefined (instead of a ProxyOptions like before)
  • if the response contains something, ensure it matches the format ip:port
  • trim the ip to be sure (it should not be empty + verify the port is a valid number > 0)

Also :

  • Rename function getGlobalProxyValue to getCurrentWifiProxyConfig
  • Add function description on configureWifiProxy and getCurrentWifiProxyConfig
  • Add another check in the getCurrentWifiProxyConfig function to ensure the ProxyOptions received in parameter in valid : If valid, apply it, otherwise disable the proxy (adb shell settings put global http_proxy :0 )
  • Add logs (using logger.ts)

- Add more logs
- Check proxy configuration before applying it
- Rename getGlobalProxyValue function to getCurrentWifiProxyConfig
- Add additional checks on adb command response when retrieving the current wifi proxy conf
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.

1 participant