Auto-configure wifi on virtual devices

At the moment tests run on virtual devices through TEST_MAPPING do not
necessarily have wifi configured to auto-connect to a test SSID.

This could be fixed by adding a TargetPreparer in AndroidTest.xml with a
given SSID, but that configuration would then apply to all runs,
including local ones. There is also no good way to apply a preparer that
configures wifi "if it is not already connected": WifiPreparer in
particular will not configure wifi even if just a mobile network is
active.

Implement auto-configuration in CtsNetUtils#connectToWifi so that if no
network is configured, and a virtual SSID is detected when scanning,
that SSID will be added to the list of configured networks. This allows
addressing the issue until TEST_MAPPING can support configuring wifi,
with minimal side-effects on other runs.

Test: atest CtsNetTestCasesLatestSdk:CaptivePortalTest
Bug: 158153057
Change-Id: I47df4c325b073f8a9bf320894245eed211606952
1 file changed
tree: eaf509caf8fcddb69b89c114cd0089fa8c28b0df
  1. tests/