DeviceSetup

public class DeviceSetup
extends BaseTargetPreparer implements IExternalDependency

java.lang.Object
   ↳ com.android.tradefed.targetprep.BaseTargetPreparer
     ↳ 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.

Note: this preparer is meant for continuous testing labs and assumes that the device under test will be flashed and wiped before the next run. As such, it does minimal clean up during teardown and should not be used in a test module.

Summary

Fields

protected BinaryState mAirplaneMode

protected BinaryState mAutoRotate

protected BinaryState mAutoUpdateTime

protected BinaryState mAutoUpdateTimezone

protected BinaryState mBatterySaver

protected Integer mBatterySaverTrigger

protected BinaryState mBluetooth

protected BinaryState mCell

protected BinaryState mCellAutoSetting

protected BinaryState mData

protected Integer mDefaultSimData

protected Integer mDefaultSimSms

protected Integer mDefaultSimVoice

protected boolean mDisableAudio

protected BinaryState mDisableCwWifiMediator

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 mHideErrorDialogs

protected BinaryState mInstallNonMarketApps

protected File mLocalDataFile

protected BinaryState mLocationGps

protected BinaryState mLocationNetwork

protected long mMinExternalStorageKb

protected BinaryState mNfc

protected BinaryState mNotificationLed

protected boolean mOptimizedPropertySetting

protected File mPreviousProperties

protected String mRemoteDataPath

protected boolean mRestoreProperties

protected boolean mRestoreSettings

protected mRunCommandAfterSettings

protected 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 mSetProps

protected boolean mSetTestHarness

protected BinaryState mSyncTimezoneWithHost

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 mWifiSsidToPsk

protected BinaryState mWifiWatchdog

Public constructors

DeviceSetup()

Public methods

void changeSettings(ITestDevice device)

Change the settings on the device.

getDependencies()
ITestDevice getDevice(TestInformation testInfo)
boolean isForceSkipSystemProps()
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, commands, String onCommand, String offCommand)

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

void setGlobalSetting(String key, String value)

Exposed for unit testing

void setSecureSetting(String key, String value)

Exposed for unit testing

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 setSystemSetting(String key, String value)

Exposed for unit testing

void setUp(TestInformation testInfo)

void tearDown(TestInformation testInfo, Throwable e)

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 setCell(BinaryState cell)
void setCellAutoSetting(BinaryState cellAutoSetting)
void setData(BinaryState data)
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 setDisableCwWifiMediator(BinaryState disableCwWifiMediator)
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 setForceRootSetup(boolean force)
void setForceSkipSystemProps(boolean force)

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 setRestoreProperties(boolean restoreProperties)

Exposed for unit testing

void setRestoreSettings(boolean restoreSettings)

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 setWifiPsk(String wifiPsk)
void setWifiScanAlwaysEnabled(BinaryState wifiScanAlwaysEnabled)

Exposed for unit testing

void setWifiSsidToPsk( wifiSssidToPsk)
void setWifiWatchdog(BinaryState wifiWatchdog)

Exposed for unit testing

Fields

mAirplaneMode

protected BinaryState mAirplaneMode

mAutoRotate

protected BinaryState mAutoRotate

mAutoUpdateTime

protected BinaryState mAutoUpdateTime

mAutoUpdateTimezone

protected BinaryState mAutoUpdateTimezone

mBatterySaver

protected BinaryState mBatterySaver

mBatterySaverTrigger

protected Integer mBatterySaverTrigger

mBluetooth

protected BinaryState mBluetooth

mCell

protected BinaryState mCell

mCellAutoSetting

protected BinaryState mCellAutoSetting

mData

protected BinaryState mData

mDefaultSimData

protected Integer mDefaultSimData

mDefaultSimSms

protected Integer mDefaultSimSms

mDefaultSimVoice

protected Integer mDefaultSimVoice

mDisableAudio

protected boolean mDisableAudio

mDisableCwWifiMediator

protected BinaryState mDisableCwWifiMediator

mDisableDalvikVerifier

protected boolean mDisableDalvikVerifier

mDisableDialing

protected boolean mDisableDialing

mDisableDoze

protected boolean mDisableDoze

mEnableFullBatteryStatsHistory

protected boolean mEnableFullBatteryStatsHistory

mEthernet

protected BinaryState mEthernet

mForceSkipRunCommands

protected boolean mForceSkipRunCommands

mForceSkipSettings

protected boolean mForceSkipSettings

mForceSkipSystemProps

protected boolean mForceSkipSystemProps

mGlobalSettings

protected MultiMap<String, String> mGlobalSettings

mHideErrorDialogs

protected BinaryState mHideErrorDialogs

mInstallNonMarketApps

protected BinaryState mInstallNonMarketApps

mLocalDataFile

protected File mLocalDataFile

mLocationGps

protected BinaryState mLocationGps

mLocationNetwork

protected BinaryState mLocationNetwork

mMinExternalStorageKb

protected long mMinExternalStorageKb

mNfc

protected BinaryState mNfc

mNotificationLed

protected BinaryState mNotificationLed

mOptimizedPropertySetting

protected boolean mOptimizedPropertySetting

mPreviousProperties

protected File mPreviousProperties

mRemoteDataPath

protected String mRemoteDataPath

mRestoreProperties

protected boolean mRestoreProperties

mRestoreSettings

protected boolean mRestoreSettings

mRunCommandAfterSettings

protected  mRunCommandAfterSettings

mRunCommandBeforeSettings

protected  mRunCommandBeforeSettings

mScreenAdaptiveBrightness

protected BinaryState mScreenAdaptiveBrightness

mScreenAlwaysOn

protected BinaryState mScreenAlwaysOn

mScreenAmbientMode

protected BinaryState mScreenAmbientMode

mScreenBrightness

protected Integer mScreenBrightness

mScreenSaver

protected BinaryState mScreenSaver

mScreenTimeoutSecs

protected Long mScreenTimeoutSecs

mSecureSettings

protected MultiMap<String, String> mSecureSettings

mSetProps

protected  mSetProps

mSetTestHarness

protected boolean mSetTestHarness

mSyncTimezoneWithHost

protected BinaryState mSyncTimezoneWithHost

mSystemSettings

protected MultiMap<String, String> mSystemSettings

mTimezone

protected String mTimezone

mTriggerMediaMounted

protected boolean mTriggerMediaMounted

mWakeGesture

protected BinaryState mWakeGesture

mWifi

protected BinaryState mWifi

mWifiPsk

protected String mWifiPsk

mWifiScanAlwaysEnabled

protected BinaryState mWifiScanAlwaysEnabled

mWifiSsid

protected String mWifiSsid

mWifiSsidToPsk

protected  mWifiSsidToPsk

mWifiWatchdog

protected BinaryState mWifiWatchdog

Public constructors

DeviceSetup

public DeviceSetup ()

Public methods

changeSettings

public 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

getDependencies

public  getDependencies ()

Returns

getDevice

public ITestDevice getDevice (TestInformation testInfo)

Parameters
testInfo TestInformation

Returns
ITestDevice

isForceSkipSystemProps

public boolean isForceSkipSystemProps ()

Returns
boolean

processDeprecatedOptions

public 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

public 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

public static void setCommandForBinaryState (BinaryState state, 
                 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 : 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

setGlobalSetting

public void setGlobalSetting (String key, 
                String value)

Exposed for unit testing

Parameters
key String

value String

setSecureSetting

public void setSecureSetting (String key, 
                String value)

Exposed for unit testing

Parameters
key String

value String

setSettingForBinaryState

public 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.

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

setSystemSetting

public void setSystemSetting (String key, 
                String value)

Exposed for unit testing

Parameters
key String

value String

setUp

public void setUp (TestInformation testInfo)

Parameters
testInfo TestInformation

Throws
BuildError
DeviceNotAvailableException
TargetSetupError

tearDown

public void tearDown (TestInformation testInfo, 
                Throwable e)

Parameters
testInfo TestInformation

e Throwable

Throws
DeviceNotAvailableException

Protected methods

setAirplaneMode

protected void setAirplaneMode (BinaryState airplaneMode)

Exposed for unit testing

Parameters
airplaneMode BinaryState

setAutoRotate

protected void setAutoRotate (BinaryState autoRotate)

Exposed for unit testing

Parameters
autoRotate BinaryState

setAutoUpdateTime

protected void setAutoUpdateTime (BinaryState autoUpdateTime)

Exposed for unit testing

Parameters
autoUpdateTime BinaryState

setAutoUpdateTimezone

protected void setAutoUpdateTimezone (BinaryState autoUpdateTimezone)

Exposed for unit testing

Parameters
autoUpdateTimezone BinaryState

setBatterySaver

protected void setBatterySaver (BinaryState batterySaver)

Exposed for unit testing

Parameters
batterySaver BinaryState

setBatterySaverTrigger

protected void setBatterySaverTrigger (Integer batterySaverTrigger)

Exposed for unit testing

Parameters
batterySaverTrigger Integer

setBluetooth

protected void setBluetooth (BinaryState bluetooth)

Exposed for unit testing

Parameters
bluetooth BinaryState

setCell

protected void setCell (BinaryState cell)

Parameters
cell BinaryState

setCellAutoSetting

protected void setCellAutoSetting (BinaryState cellAutoSetting)

Parameters
cellAutoSetting BinaryState

setData

protected void setData (BinaryState data)

Parameters
data BinaryState

setDefaultSimData

protected void setDefaultSimData (Integer defaultSimData)

Exposed for unit testing

Parameters
defaultSimData Integer

setDefaultSimSms

protected void setDefaultSimSms (Integer defaultSimSms)

Exposed for unit testing

Parameters
defaultSimSms Integer

setDefaultSimVoice

protected void setDefaultSimVoice (Integer defaultSimVoice)

Exposed for unit testing

Parameters
defaultSimVoice Integer

setDeprecatedAudioSilent

protected void setDeprecatedAudioSilent (boolean silent)

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

Exposed for unit testing

Parameters
silent boolean

setDeprecatedMinExternalStoreSpace

protected void setDeprecatedMinExternalStoreSpace (long storeSpace)

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

Exposed for unit testing

Parameters
storeSpace long

setDeprecatedSetProp

protected void setDeprecatedSetProp (String prop)

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

Exposed for unit testing

Parameters
prop String

setDisableAudio

protected void setDisableAudio (boolean disable)

Exposed for unit testing

Parameters
disable boolean

setDisableCwWifiMediator

protected void setDisableCwWifiMediator (BinaryState disableCwWifiMediator)

Parameters
disableCwWifiMediator BinaryState

setDisableDalvikVerifier

protected void setDisableDalvikVerifier (boolean disableDalvikVerifier)

Exposed for unit testing

Parameters
disableDalvikVerifier boolean

setDisableDialing

protected void setDisableDialing (boolean disableDialing)

Exposed for unit testing

Parameters
disableDialing boolean

setDisableDoze

protected void setDisableDoze (boolean disableDoze)

Exposed for unit testing

Parameters
disableDoze boolean

setEnableFullBatteryStatsHistory

protected void setEnableFullBatteryStatsHistory (boolean enableFullBatteryStatsHistory)

Exposed for unit testing

Parameters
enableFullBatteryStatsHistory boolean

setEthernet

protected void setEthernet (BinaryState ethernet)

Exposed for unit testing

Parameters
ethernet BinaryState

setForceRootSetup

protected void setForceRootSetup (boolean force)

Parameters
force boolean

setForceSkipSystemProps

protected void setForceSkipSystemProps (boolean force)

Exposed for unit testing

Parameters
force boolean

setInstallNonMarketApps

protected void setInstallNonMarketApps (BinaryState installNonMarketApps)

Exposed for unit testing

Parameters
installNonMarketApps BinaryState

setLocalDataPath

protected void setLocalDataPath (File path)

Exposed for unit testing

Parameters
path File

setLocationGps

protected void setLocationGps (BinaryState locationGps)

Exposed for unit testing

Parameters
locationGps BinaryState

setLocationNetwork

protected void setLocationNetwork (BinaryState locationNetwork)

Exposed for unit testing

Parameters
locationNetwork BinaryState

setMinExternalStorageKb

protected void setMinExternalStorageKb (long storageKb)

Exposed for unit testing

Parameters
storageKb long

setNfc

protected void setNfc (BinaryState nfc)

Exposed for unit testing

Parameters
nfc BinaryState

setNotificationLed

protected void setNotificationLed (BinaryState notificationLed)

Exposed for unit testing

Parameters
notificationLed BinaryState

setProperty

protected void setProperty (String key, 
                String value)

Exposed for unit testing

Parameters
key String

value String

setRestoreProperties

protected void setRestoreProperties (boolean restoreProperties)

Exposed for unit testing

Parameters
restoreProperties boolean

setRestoreSettings

protected void setRestoreSettings (boolean restoreSettings)

Exposed for unit testing

Parameters
restoreSettings boolean

setScreenAdaptiveBrightness

protected void setScreenAdaptiveBrightness (BinaryState screenAdaptiveBrightness)

Exposed for unit testing

Parameters
screenAdaptiveBrightness BinaryState

setScreenAlwaysOn

protected void setScreenAlwaysOn (BinaryState screenAlwaysOn)

Exposed for unit testing

Parameters
screenAlwaysOn BinaryState

setScreenAmbientMode

protected void setScreenAmbientMode (BinaryState screenAmbientMode)

Exposed for unit testing

Parameters
screenAmbientMode BinaryState

setScreenBrightness

protected void setScreenBrightness (Integer screenBrightness)

Exposed for unit testing

Parameters
screenBrightness Integer

setScreenSaver

protected void setScreenSaver (BinaryState screenSaver)

Exposed for unit testing

Parameters
screenSaver BinaryState

setScreenTimeoutSecs

protected void setScreenTimeoutSecs (Long screenTimeoutSecs)

Exposed for unit testing

Parameters
screenTimeoutSecs Long

setTestHarness

protected void setTestHarness (boolean setTestHarness)

Exposed for unit testing

Parameters
setTestHarness boolean

setTimezone

protected void setTimezone (String timezone)

Exposed for unit testing

Parameters
timezone String

setTriggerMediaMounted

protected void setTriggerMediaMounted (boolean triggerMediaMounted)

Exposed for unit testing

Parameters
triggerMediaMounted boolean

setWakeGesture

protected void setWakeGesture (BinaryState wakeGesture)

Exposed for unit testing

Parameters
wakeGesture BinaryState

setWifi

protected void setWifi (BinaryState wifi)

Exposed for unit testing

Parameters
wifi BinaryState

setWifiNetwork

protected void setWifiNetwork (String wifiNetwork)

Exposed for unit testing

Parameters
wifiNetwork String

setWifiPsk

protected void setWifiPsk (String wifiPsk)

Parameters
wifiPsk String

setWifiScanAlwaysEnabled

protected void setWifiScanAlwaysEnabled (BinaryState wifiScanAlwaysEnabled)

Exposed for unit testing

Parameters
wifiScanAlwaysEnabled BinaryState

setWifiSsidToPsk

protected void setWifiSsidToPsk ( wifiSssidToPsk)

Parameters
wifiSssidToPsk

setWifiWatchdog

protected void setWifiWatchdog (BinaryState wifiWatchdog)

Exposed for unit testing

Parameters
wifiWatchdog BinaryState