DeviceSetup

public class DeviceSetup
extends Object implements ITargetPreparer, ITargetCleaner

java.lang.Object
   ↳ com.android.tradefed.targetprep.DeviceSetup


A ITargetPreparer that configures a device for testing based on provided Options.

Requires a device where 'adb root' is possible, typically a userdebug build type.

Should be performed after a new build is flashed.

Summary

Fields

protected BinaryState mAirplaneMode

protected BinaryState mAutoRotate

protected BinaryState mAutoUpdateTime

protected BinaryState mAutoUpdateTimezone

protected BinaryState mBatterySaver

protected Integer mBatterySaverTrigger

protected BinaryState mBluetooth

protected Integer mDefaultSimData

protected Integer mDefaultSimSms

protected Integer mDefaultSimVoice

protected boolean mDisable

protected boolean mDisableAudio

protected boolean mDisableDalvikVerifier

protected boolean mDisableDialing

protected boolean mDisableDoze

protected boolean mEnableFullBatteryStatsHistory

protected BinaryState mEthernet

protected boolean mForceSkipRunCommands

protected boolean mForceSkipSettings

protected boolean mForceSkipSystemProps

protected MultiMap<String, String> mGlobalSettings

protected BinaryState mInstallNonMarketApps

protected File mLocalDataFile

protected BinaryState mLocationGps

protected BinaryState mLocationNetwork

protected long mMinExternalStorageKb

protected BinaryState mNfc

protected BinaryState mNotificationLed

protected String mRemoteDataPath

protected List<String> mRunCommandAfterSettings

protected List<String> mRunCommandBeforeSettings

protected BinaryState mScreenAdaptiveBrightness

protected BinaryState mScreenAlwaysOn

protected BinaryState mScreenAmbientMode

protected Integer mScreenBrightness

protected BinaryState mScreenSaver

protected Long mScreenTimeoutSecs

protected MultiMap<String, String> mSecureSettings

protected Map<String, String> mSetProps

protected boolean mSetTestHarness

protected MultiMap<String, String> mSystemSettings

protected String mTimezone

protected boolean mTriggerMediaMounted

protected BinaryState mWakeGesture

protected BinaryState mWifi

protected String mWifiPsk

protected BinaryState mWifiScanAlwaysEnabled

protected String mWifiSsid

protected BinaryState mWifiWatchdog

Public constructors

DeviceSetup()

Public methods

void changeSettings(ITestDevice device)

Change the settings on the device.

void processDeprecatedOptions(ITestDevice device)

Processes the deprecated options converting them into the currently used options.

void processOptions(ITestDevice device)

Process all the Options and turn them into system props, settings, or run commands.

static void setCommandForBinaryState(BinaryState state, List<String> commands, String onCommand, String offCommand)

Helper method to add an ON/OFF run command to be executed on the device.

static void setSettingForBinaryState(BinaryState state, MultiMap<String, String> settingsMap, String setting, String onValue, String offValue)

Helper method to add an ON/OFF setting to a setting map.

void setUp(ITestDevice device, IBuildInfo buildInfo)

Perform the target setup for testing.

void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)

Perform the target cleanup/teardown after testing.

Protected methods

void setAirplaneMode(BinaryState airplaneMode)

Exposed for unit testing

void setAutoRotate(BinaryState autoRotate)

Exposed for unit testing

void setAutoUpdateTime(BinaryState autoUpdateTime)

Exposed for unit testing

void setAutoUpdateTimezone(BinaryState autoUpdateTimezone)

Exposed for unit testing

void setBatterySaver(BinaryState batterySaver)

Exposed for unit testing

void setBatterySaverTrigger(Integer batterySaverTrigger)

Exposed for unit testing

void setBluetooth(BinaryState bluetooth)

Exposed for unit testing

void setDefaultSimData(Integer defaultSimData)

Exposed for unit testing

void setDefaultSimSms(Integer defaultSimSms)

Exposed for unit testing

void setDefaultSimVoice(Integer defaultSimVoice)

Exposed for unit testing

void setDeprecatedAudioSilent(boolean silent)

This method is deprecated. use setDisableAudio(boolean) instead.

void setDeprecatedMinExternalStoreSpace(long storeSpace)

This method is deprecated. use setMinExternalStorageKb(long) instead.

void setDeprecatedSetProp(String prop)

This method is deprecated. use setProperty(String, String) instead.

void setDisableAudio(boolean disable)

Exposed for unit testing

void setDisableDalvikVerifier(boolean disableDalvikVerifier)

Exposed for unit testing

void setDisableDialing(boolean disableDialing)

Exposed for unit testing

void setDisableDoze(boolean disableDoze)

Exposed for unit testing

void setEnableFullBatteryStatsHistory(boolean enableFullBatteryStatsHistory)

Exposed for unit testing

void setEthernet(BinaryState ethernet)

Exposed for unit testing

void setInstallNonMarketApps(BinaryState installNonMarketApps)

Exposed for unit testing

void setLocalDataPath(File path)

Exposed for unit testing

void setLocationGps(BinaryState locationGps)

Exposed for unit testing

void setLocationNetwork(BinaryState locationNetwork)

Exposed for unit testing

void setMinExternalStorageKb(long storageKb)

Exposed for unit testing

void setNfc(BinaryState nfc)

Exposed for unit testing

void setNotificationLed(BinaryState notificationLed)

Exposed for unit testing

void setProperty(String key, String value)

Exposed for unit testing

void setScreenAdaptiveBrightness(BinaryState screenAdaptiveBrightness)

Exposed for unit testing

void setScreenAlwaysOn(BinaryState screenAlwaysOn)

Exposed for unit testing

void setScreenAmbientMode(BinaryState screenAmbientMode)

Exposed for unit testing

void setScreenBrightness(Integer screenBrightness)

Exposed for unit testing

void setScreenSaver(BinaryState screenSaver)

Exposed for unit testing

void setScreenTimeoutSecs(Long screenTimeoutSecs)

Exposed for unit testing

void setTestHarness(boolean setTestHarness)

Exposed for unit testing

void setTimezone(String timezone)

Exposed for unit testing

void setTriggerMediaMounted(boolean triggerMediaMounted)

Exposed for unit testing

void setWakeGesture(BinaryState wakeGesture)

Exposed for unit testing

void setWifi(BinaryState wifi)

Exposed for unit testing

void setWifiNetwork(String wifiNetwork)

Exposed for unit testing

void setWifiScanAlwaysEnabled(BinaryState wifiScanAlwaysEnabled)

Exposed for unit testing

void setWifiWatchdog(BinaryState wifiWatchdog)

Exposed for unit testing

Fields

mAirplaneMode

BinaryState mAirplaneMode

mAutoRotate

BinaryState mAutoRotate

mAutoUpdateTime

BinaryState mAutoUpdateTime

mAutoUpdateTimezone

BinaryState mAutoUpdateTimezone

mBatterySaver

BinaryState mBatterySaver

mBatterySaverTrigger

Integer mBatterySaverTrigger

mBluetooth

BinaryState mBluetooth

mDefaultSimData

Integer mDefaultSimData

mDefaultSimSms

Integer mDefaultSimSms

mDefaultSimVoice

Integer mDefaultSimVoice

mDisable

boolean mDisable

mDisableAudio

boolean mDisableAudio

mDisableDalvikVerifier

boolean mDisableDalvikVerifier

mDisableDialing

boolean mDisableDialing

mDisableDoze

boolean mDisableDoze

mEnableFullBatteryStatsHistory

boolean mEnableFullBatteryStatsHistory

mEthernet

BinaryState mEthernet

mForceSkipRunCommands

boolean mForceSkipRunCommands

mForceSkipSettings

boolean mForceSkipSettings

mForceSkipSystemProps

boolean mForceSkipSystemProps

mGlobalSettings

MultiMap<String, String> mGlobalSettings

mInstallNonMarketApps

BinaryState mInstallNonMarketApps

mLocalDataFile

File mLocalDataFile

mLocationGps

BinaryState mLocationGps

mLocationNetwork

BinaryState mLocationNetwork

mMinExternalStorageKb

long mMinExternalStorageKb

mNfc

BinaryState mNfc

mNotificationLed

BinaryState mNotificationLed

mRemoteDataPath

String mRemoteDataPath

mRunCommandAfterSettings

List<String> mRunCommandAfterSettings

mRunCommandBeforeSettings

List<String> mRunCommandBeforeSettings

mScreenAdaptiveBrightness

BinaryState mScreenAdaptiveBrightness

mScreenAlwaysOn

BinaryState mScreenAlwaysOn

mScreenAmbientMode

BinaryState mScreenAmbientMode

mScreenBrightness

Integer mScreenBrightness

mScreenSaver

BinaryState mScreenSaver

mScreenTimeoutSecs

Long mScreenTimeoutSecs

mSecureSettings

MultiMap<String, String> mSecureSettings

mSetProps

Map<String, String> mSetProps

mSetTestHarness

boolean mSetTestHarness

mSystemSettings

MultiMap<String, String> mSystemSettings

mTimezone

String mTimezone

mTriggerMediaMounted

boolean mTriggerMediaMounted

mWakeGesture

BinaryState mWakeGesture

mWifi

BinaryState mWifi

mWifiPsk

String mWifiPsk

mWifiScanAlwaysEnabled

BinaryState mWifiScanAlwaysEnabled

mWifiSsid

String mWifiSsid

mWifiWatchdog

BinaryState mWifiWatchdog

Public constructors

DeviceSetup

DeviceSetup ()

Public methods

changeSettings

void changeSettings (ITestDevice device)

Change the settings on the device.

Exposed so children classes may override.

Parameters
device ITestDevice: The ITestDevice

Throws
DeviceNotAvailableException if the device is not available
TargetSetupError if there was a failure setting the settings

processDeprecatedOptions

void processDeprecatedOptions (ITestDevice device)

Processes the deprecated options converting them into the currently used options.

This method should be run before any other processing methods. Will throw a TargetSetupError if the deprecated option overrides a specified non-deprecated option.

Parameters
device ITestDevice

Throws
TargetSetupError if there is a conflict

processOptions

void processOptions (ITestDevice device)

Process all the Options and turn them into system props, settings, or run commands. Does not run any commands on the device at this time.

Exposed so that children classes may override this.

Parameters
device ITestDevice: The ITestDevice

Throws
DeviceNotAvailableException if the device is not available
TargetSetupError if the Options conflict

setCommandForBinaryState

void setCommandForBinaryState (BinaryState state, 
                List<String> commands, 
                String onCommand, 
                String offCommand)

Helper method to add an ON/OFF run command to be executed on the device.

Parameters
state BinaryState: The BinaryState

commands List: The list of commands to add the on or off command to.

onCommand String: The command to run if ON. Ignored if the command is null

offCommand String: The command to run if OFF. Ignored if the command is null

setSettingForBinaryState

void setSettingForBinaryState (BinaryState state, 
                MultiMap<String, String> settingsMap, 
                String setting, 
                String onValue, 
                String offValue)

Helper method to add an ON/OFF setting to a setting map.

Parameters
state BinaryState: The BinaryState

settingsMap MultiMap: The MultiMap used to store the settings.

setting String: The setting key

onValue String: The value if ON

offValue String: The value if OFF

setUp

void setUp (ITestDevice device, 
                IBuildInfo buildInfo)

Perform the target setup for testing.

Parameters
device ITestDevice: the ITestDevice to prepare.

buildInfo IBuildInfo: data about the build under test.

Throws
DeviceNotAvailableException
TargetSetupError

tearDown

void tearDown (ITestDevice device, 
                IBuildInfo buildInfo, 
                Throwable e)

Perform the target cleanup/teardown after testing.

Parameters
device ITestDevice: the ITestDevice to prepare.

buildInfo IBuildInfo: data about the build under test.

e Throwable: if the invocation ended with an exception, this will be the exception that was caught at the Invocation level. Otherwise, will be null.

Throws
DeviceNotAvailableException

Protected methods

setAirplaneMode

void setAirplaneMode (BinaryState airplaneMode)

Exposed for unit testing

Parameters
airplaneMode BinaryState

setAutoRotate

void setAutoRotate (BinaryState autoRotate)

Exposed for unit testing

Parameters
autoRotate BinaryState

setAutoUpdateTime

void setAutoUpdateTime (BinaryState autoUpdateTime)

Exposed for unit testing

Parameters
autoUpdateTime BinaryState

setAutoUpdateTimezone

void setAutoUpdateTimezone (BinaryState autoUpdateTimezone)

Exposed for unit testing

Parameters
autoUpdateTimezone BinaryState

setBatterySaver

void setBatterySaver (BinaryState batterySaver)

Exposed for unit testing

Parameters
batterySaver BinaryState

setBatterySaverTrigger

void setBatterySaverTrigger (Integer batterySaverTrigger)

Exposed for unit testing

Parameters
batterySaverTrigger Integer

setBluetooth

void setBluetooth (BinaryState bluetooth)

Exposed for unit testing

Parameters
bluetooth BinaryState

setDefaultSimData

void setDefaultSimData (Integer defaultSimData)

Exposed for unit testing

Parameters
defaultSimData Integer

setDefaultSimSms

void setDefaultSimSms (Integer defaultSimSms)

Exposed for unit testing

Parameters
defaultSimSms Integer

setDefaultSimVoice

void setDefaultSimVoice (Integer defaultSimVoice)

Exposed for unit testing

Parameters
defaultSimVoice Integer

setDeprecatedAudioSilent

void setDeprecatedAudioSilent (boolean silent)

This method is deprecated.
use setDisableAudio(boolean) instead.

Exposed for unit testing

Parameters
silent boolean

setDeprecatedMinExternalStoreSpace

void setDeprecatedMinExternalStoreSpace (long storeSpace)

This method is deprecated.
use setMinExternalStorageKb(long) instead.

Exposed for unit testing

Parameters
storeSpace long

setDeprecatedSetProp

void setDeprecatedSetProp (String prop)

This method is deprecated.
use setProperty(String, String) instead.

Exposed for unit testing

Parameters
prop String

setDisableAudio

void setDisableAudio (boolean disable)

Exposed for unit testing

Parameters
disable boolean

setDisableDalvikVerifier

void setDisableDalvikVerifier (boolean disableDalvikVerifier)

Exposed for unit testing

Parameters
disableDalvikVerifier boolean

setDisableDialing

void setDisableDialing (boolean disableDialing)

Exposed for unit testing

Parameters
disableDialing boolean

setDisableDoze

void setDisableDoze (boolean disableDoze)

Exposed for unit testing

Parameters
disableDoze boolean

setEnableFullBatteryStatsHistory

void setEnableFullBatteryStatsHistory (boolean enableFullBatteryStatsHistory)

Exposed for unit testing

Parameters
enableFullBatteryStatsHistory boolean

setEthernet

void setEthernet (BinaryState ethernet)

Exposed for unit testing

Parameters
ethernet BinaryState

setInstallNonMarketApps

void setInstallNonMarketApps (BinaryState installNonMarketApps)

Exposed for unit testing

Parameters
installNonMarketApps BinaryState

setLocalDataPath

void setLocalDataPath (File path)

Exposed for unit testing

Parameters
path File

setLocationGps

void setLocationGps (BinaryState locationGps)

Exposed for unit testing

Parameters
locationGps BinaryState

setLocationNetwork

void setLocationNetwork (BinaryState locationNetwork)

Exposed for unit testing

Parameters
locationNetwork BinaryState

setMinExternalStorageKb

void setMinExternalStorageKb (long storageKb)

Exposed for unit testing

Parameters
storageKb long

setNfc

void setNfc (BinaryState nfc)

Exposed for unit testing

Parameters
nfc BinaryState

setNotificationLed

void setNotificationLed (BinaryState notificationLed)

Exposed for unit testing

Parameters
notificationLed BinaryState

setProperty

void setProperty (String key, 
                String value)

Exposed for unit testing

Parameters
key String

value String

setScreenAdaptiveBrightness

void setScreenAdaptiveBrightness (BinaryState screenAdaptiveBrightness)

Exposed for unit testing

Parameters
screenAdaptiveBrightness BinaryState

setScreenAlwaysOn

void setScreenAlwaysOn (BinaryState screenAlwaysOn)

Exposed for unit testing

Parameters
screenAlwaysOn BinaryState

setScreenAmbientMode

void setScreenAmbientMode (BinaryState screenAmbientMode)

Exposed for unit testing

Parameters
screenAmbientMode BinaryState

setScreenBrightness

void setScreenBrightness (Integer screenBrightness)

Exposed for unit testing

Parameters
screenBrightness Integer

setScreenSaver

void setScreenSaver (BinaryState screenSaver)

Exposed for unit testing

Parameters
screenSaver BinaryState

setScreenTimeoutSecs

void setScreenTimeoutSecs (Long screenTimeoutSecs)

Exposed for unit testing

Parameters
screenTimeoutSecs Long

setTestHarness

void setTestHarness (boolean setTestHarness)

Exposed for unit testing

Parameters
setTestHarness boolean

setTimezone

void setTimezone (String timezone)

Exposed for unit testing

Parameters
timezone String

setTriggerMediaMounted

void setTriggerMediaMounted (boolean triggerMediaMounted)

Exposed for unit testing

Parameters
triggerMediaMounted boolean

setWakeGesture

void setWakeGesture (BinaryState wakeGesture)

Exposed for unit testing

Parameters
wakeGesture BinaryState

setWifi

void setWifi (BinaryState wifi)

Exposed for unit testing

Parameters
wifi BinaryState

setWifiNetwork

void setWifiNetwork (String wifiNetwork)

Exposed for unit testing

Parameters
wifiNetwork String

setWifiScanAlwaysEnabled

void setWifiScanAlwaysEnabled (BinaryState wifiScanAlwaysEnabled)

Exposed for unit testing

Parameters
wifiScanAlwaysEnabled BinaryState

setWifiWatchdog

void setWifiWatchdog (BinaryState wifiWatchdog)

Exposed for unit testing

Parameters
wifiWatchdog BinaryState