DeviceSetup

public class DeviceSetup
extends BaseTargetPreparer implements ITargetCleaner

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.

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 mInstallNonMarketApps

protected File mLocalDataFile

protected BinaryState mLocationGps

protected BinaryState mLocationNetwork

protected long mMinExternalStorageKb

protected BinaryState mNfc

protected BinaryState mNotificationLed

protected File mPreviousProperties

protected String mRemoteDataPath

protected boolean mRestoreProperties

protected boolean mRestoreSettings

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.

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(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 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 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 setWifiScanAlwaysEnabled(BinaryState wifiScanAlwaysEnabled)

Exposed for unit testing

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

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

mPreviousProperties

protected File mPreviousProperties

mRemoteDataPath

protected String mRemoteDataPath

mRestoreProperties

protected boolean mRestoreProperties

mRestoreSettings

protected boolean mRestoreSettings

mRunCommandAfterSettings

protected List<String> mRunCommandAfterSettings

mRunCommandBeforeSettings

protected List<String> 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 Map<String, String> mSetProps

mSetTestHarness

protected boolean mSetTestHarness

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

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

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, 
                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

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 (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

public 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

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

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

setWifiScanAlwaysEnabled

protected void setWifiScanAlwaysEnabled (BinaryState wifiScanAlwaysEnabled)

Exposed for unit testing

Parameters
wifiScanAlwaysEnabled BinaryState

setWifiWatchdog

protected void setWifiWatchdog (BinaryState wifiWatchdog)

Exposed for unit testing

Parameters
wifiWatchdog BinaryState