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 Option
s.
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
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 |
static
void
|
setCommandForBinaryState(BinaryState state,
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 |
void
|
setDeprecatedMinExternalStoreSpace(long storeSpace)
This method is deprecated.
use |
void
|
setDeprecatedSetProp(String prop)
This method is deprecated.
use |
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(
|
void
|
setWifiWatchdog(BinaryState wifiWatchdog)
Exposed for unit testing |
Fields
mBatterySaverTrigger
protected Integer mBatterySaverTrigger
mDefaultSimData
protected Integer mDefaultSimData
mDefaultSimSms
protected Integer mDefaultSimSms
mDefaultSimVoice
protected Integer mDefaultSimVoice
mDisableAudio
protected boolean mDisableAudio
mDisableDalvikVerifier
protected boolean mDisableDalvikVerifier
mDisableDialing
protected boolean mDisableDialing
mDisableDoze
protected boolean mDisableDoze
mEnableFullBatteryStatsHistory
protected boolean mEnableFullBatteryStatsHistory
mForceSkipRunCommands
protected boolean mForceSkipRunCommands
mForceSkipSettings
protected boolean mForceSkipSettings
mForceSkipSystemProps
protected boolean mForceSkipSystemProps
mLocalDataFile
protected File mLocalDataFile
mMinExternalStorageKb
protected long mMinExternalStorageKb
mOptimizedPropertySetting
protected boolean mOptimizedPropertySetting
mPreviousProperties
protected File mPreviousProperties
mRemoteDataPath
protected String mRemoteDataPath
mRestoreProperties
protected boolean mRestoreProperties
mRestoreSettings
protected boolean mRestoreSettings
mRunCommandAfterSettings
protectedmRunCommandAfterSettings
mRunCommandBeforeSettings
protectedmRunCommandBeforeSettings
mScreenBrightness
protected Integer mScreenBrightness
mScreenTimeoutSecs
protected Long mScreenTimeoutSecs
mSetProps
protectedmSetProps
mSetTestHarness
protected boolean mSetTestHarness
mTimezone
protected String mTimezone
mTriggerMediaMounted
protected boolean mTriggerMediaMounted
mWifiPsk
protected String mWifiPsk
mWifiSsid
protected String mWifiSsid
mWifiSsidToPsk
protectedmWifiSsidToPsk
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
publicgetDependencies ()
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 Option
s 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 Option s 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 |
setCellAutoSetting
protected void setCellAutoSetting (BinaryState cellAutoSetting)
Parameters | |
---|---|
cellAutoSetting |
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 |
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 |