WifiHelper

public class WifiHelper
extends Object

java.lang.Object
   ↳ com.android.tradefed.device.WifiHelper


Helper class for manipulating wifi services on device.

Summary

Fields

public static final String INSTRUMENTATION_PKG

Public constructors

WifiHelper(ITestDevice device)
WifiHelper(ITestDevice device, String wifiUtilApkPath)
WifiHelper(ITestDevice device, String wifiUtilApkPath, boolean doSetup)

Alternative constructor that can skip the setup of the wifi apk.

WifiHelper(ITestDevice device, String wifiUtilApkPath, boolean doSetup, boolean useV2)

Constructor to specify whether to use new wifi helper v2.

Public methods

boolean addOpenNetwork(String ssid)

boolean addOpenNetwork(String ssid, boolean scanSsid)

boolean addWpaPskNetwork(String ssid, String psk)

boolean addWpaPskNetwork(String ssid, String psk, boolean scanSsid)

boolean checkConnectivity(String urlToCheck)

void cleanUp()

boolean connectToNetwork(String ssid, String psk, String urlToCheck)

IWifiHelper.WifiConnectionResult connectToNetwork(String ssid, String psk, String urlToCheck, boolean scanSsid, String defaultType)

IWifiHelper.WifiConnectionResult connectToNetwork(String ssid, String psk, String urlToCheck, boolean scanSsid)

boolean disableWifi()

boolean disconnectFromNetwork()

boolean enableWifi()

static File extractWifiUtilApk()

Helper method to extract the wifi util apk from the classpath

String getBSSID()

String getIpAddress()

String getSSID()

getWifiInfo()

boolean hasValidIp()

boolean isWifiEnabled()

boolean removeAllNetworks()

boolean startMonitor(long interval, String urlToCheck)

stopMonitor()

boolean waitForIp(long timeout)

boolean waitForWifiDisabled(long timeout)
boolean waitForWifiDisabled()

boolean waitForWifiEnabled(long timeout)
boolean waitForWifiEnabled()

boolean waitForWifiState(WifiState... expectedStates)

Fields

INSTRUMENTATION_PKG

public static final String INSTRUMENTATION_PKG

Public constructors

WifiHelper

public WifiHelper (ITestDevice device)

Parameters
device ITestDevice

Throws
DeviceNotAvailableException

WifiHelper

public WifiHelper (ITestDevice device, 
                String wifiUtilApkPath)

Parameters
device ITestDevice

wifiUtilApkPath String

Throws
DeviceNotAvailableException

WifiHelper

public WifiHelper (ITestDevice device, 
                String wifiUtilApkPath, 
                boolean doSetup)

Alternative constructor that can skip the setup of the wifi apk.

Parameters
device ITestDevice

wifiUtilApkPath String

doSetup boolean

Throws
DeviceNotAvailableException

WifiHelper

public WifiHelper (ITestDevice device, 
                String wifiUtilApkPath, 
                boolean doSetup, 
                boolean useV2)

Constructor to specify whether to use new wifi helper v2. v2 operations do not need to install the wifi util apk.

Parameters
device ITestDevice

wifiUtilApkPath String

doSetup boolean

useV2 boolean

Throws
DeviceNotAvailableException

Public methods

addOpenNetwork

public boolean addOpenNetwork (String ssid)

Parameters
ssid String

Returns
boolean

Throws
DeviceNotAvailableException

addOpenNetwork

public boolean addOpenNetwork (String ssid, 
                boolean scanSsid)

Parameters
ssid String

scanSsid boolean

Returns
boolean

Throws
DeviceNotAvailableException

addWpaPskNetwork

public boolean addWpaPskNetwork (String ssid, 
                String psk)

Parameters
ssid String

psk String

Returns
boolean

Throws
DeviceNotAvailableException

addWpaPskNetwork

public boolean addWpaPskNetwork (String ssid, 
                String psk, 
                boolean scanSsid)

Parameters
ssid String

psk String

scanSsid boolean

Returns
boolean

Throws
DeviceNotAvailableException

checkConnectivity

public boolean checkConnectivity (String urlToCheck)

Parameters
urlToCheck String

Returns
boolean

Throws
DeviceNotAvailableException

cleanUp

public void cleanUp ()

Throws
DeviceNotAvailableException

connectToNetwork

public boolean connectToNetwork (String ssid, 
                String psk, 
                String urlToCheck)

Parameters
ssid String

psk String

urlToCheck String

Returns
boolean

Throws
DeviceNotAvailableException

connectToNetwork

public IWifiHelper.WifiConnectionResult connectToNetwork (String ssid, 
                String psk, 
                String urlToCheck, 
                boolean scanSsid, 
                String defaultType)

Parameters
ssid String

psk String

urlToCheck String

scanSsid boolean

defaultType String

Returns
IWifiHelper.WifiConnectionResult

Throws
DeviceNotAvailableException

connectToNetwork

public IWifiHelper.WifiConnectionResult connectToNetwork (String ssid, 
                String psk, 
                String urlToCheck, 
                boolean scanSsid)

Parameters
ssid String

psk String

urlToCheck String

scanSsid boolean

Returns
IWifiHelper.WifiConnectionResult

Throws
DeviceNotAvailableException

disableWifi

public boolean disableWifi ()

Returns
boolean

Throws
DeviceNotAvailableException

disconnectFromNetwork

public boolean disconnectFromNetwork ()

Returns
boolean

Throws
DeviceNotAvailableException

enableWifi

public boolean enableWifi ()

Returns
boolean

Throws
DeviceNotAvailableException

extractWifiUtilApk

public static File extractWifiUtilApk ()

Helper method to extract the wifi util apk from the classpath

Returns
File

getBSSID

public String getBSSID ()

Returns
String

Throws
DeviceNotAvailableException

getIpAddress

public String getIpAddress ()

Returns
String

Throws
DeviceNotAvailableException

getSSID

public String getSSID ()

Returns
String

Throws
DeviceNotAvailableException

getWifiInfo

public  getWifiInfo ()

Returns

Throws
DeviceNotAvailableException

hasValidIp

public boolean hasValidIp ()

Returns
boolean

Throws
DeviceNotAvailableException

isWifiEnabled

public boolean isWifiEnabled ()

Returns
boolean

Throws
DeviceNotAvailableException

removeAllNetworks

public boolean removeAllNetworks ()

Returns
boolean

Throws
DeviceNotAvailableException

startMonitor

public boolean startMonitor (long interval, 
                String urlToCheck)

Parameters
interval long

urlToCheck String

Returns
boolean

Throws
DeviceNotAvailableException

stopMonitor

public  stopMonitor ()

Returns

Throws
DeviceNotAvailableException

waitForIp

public boolean waitForIp (long timeout)

Parameters
timeout long

Returns
boolean

Throws
DeviceNotAvailableException

waitForWifiDisabled

public boolean waitForWifiDisabled (long timeout)

Parameters
timeout long

Returns
boolean

Throws
DeviceNotAvailableException

waitForWifiDisabled

public boolean waitForWifiDisabled ()

Returns
boolean

Throws
DeviceNotAvailableException

waitForWifiEnabled

public boolean waitForWifiEnabled (long timeout)

Parameters
timeout long

Returns
boolean

Throws
DeviceNotAvailableException

waitForWifiEnabled

public boolean waitForWifiEnabled ()

Returns
boolean

Throws
DeviceNotAvailableException

waitForWifiState

public boolean waitForWifiState (WifiState... expectedStates)

Parameters
expectedStates WifiState

Returns
boolean

Throws
DeviceNotAvailableException