to top
public class

DeviceSetup

extends Object
implements ITargetPreparer ITargetCleaner @OptionClass(alias = "device-setup")
java.lang.Object
   ↳ com.android.tradefed.targetprep.DeviceSetup

Class Overview

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 @Option(name = "airplane-mode", description = "Turn airplane mode on or off")
protected BinaryState mAutoRotate @Option(name = "auto-rotate", description = "Turn auto rotate on or off")
protected BinaryState mAutoUpdateTime @Option(name = "auto-update-time", description = "Turn auto update time on or off")
protected BinaryState mAutoUpdateTimezone @Option(name = "auto-update-timezone", description = "Turn auto update timezone on or off")
protected BinaryState mBatterySaver @Option(name = "battery-saver-mode", description = "Turn battery saver mode manually on or off. If OFF but battery is less battery-saver-trigger, the device will still go into battery saver mode")
protected Integer mBatterySaverTrigger @Option(name = "battery-saver-trigger", description = "Set the battery saver trigger level. Should be [1-99] to enable, or 0 to disable automatic battery saver mode")
protected BinaryState mBluetooth @Option(name = "bluetooth", description = "Turn bluetooth on or off")
protected Integer mDefaultSimData @Option(name = "default-sim-data", description = "Set the default sim card slot for data. Leave unset for single SIM devices")
protected Integer mDefaultSimSms @Option(name = "default-sim-sms", description = "Set the default sim card slot for SMS. Leave unset for single SIM devices")
protected Integer mDefaultSimVoice @Option(name = "default-sim-voice", description = "Set the default sim card slot for voice calls. Leave unset for single SIM devices")
private long mDeprecatedMinExternalStoreSpace @Option(name = "min-external-store-space", description = "deprecated, use option min-external-storage-kb. The minimum amount of free space in KB that must be present on device\'s external storage.")
private boolean mDeprecatedSetAudioSilent @Option(name = "audio-silent", description = "deprecated, use option disable-audio. set ro.audio.silent on boot.")
private Collection<String> mDeprecatedSetProps @Option(name = "setprop", description = "deprecated, use option set-property. set the specified property on boot. Format: --setprop key=value. May be repeated.")
protected boolean mDisable @Option(name = "disable", description = "Disable the device setup")
protected boolean mDisableAudio @Option(name = "disable-audio", description = "Disable the audio")
protected boolean mDisableDalvikVerifier @Option(name = "disable-dalvik-verifier", description = "Disable the dalvik verifier on device. Allows package-private framework tests to run.")
protected boolean mDisableDialing @Option(name = "disable-dialing", description = "Disable dialing")
protected boolean mDisableDoze @Option(name = "disable-doze", description = "Disable device from going into doze mode. This option is only applicable for M+")
private boolean mDisconnectWifiAfterTest @Option(name = "disconnect-wifi-after-test", description = "Disconnect from wifi network after test completes.")
protected boolean mEnableFullBatteryStatsHistory @Option(name = "enable-full-battery-stats-history", description = "Enable full history for batterystats. This option is only applicable for L+")
protected BinaryState mEthernet @Option(name = "ethernet", description = "Turn ethernet on or off")
protected boolean mForceSkipRunCommands @Option(name = "force-skip-run-commands", description = "Force setup to not run any additional commands. All other commands will be ignored.")
protected boolean mForceSkipSettings @Option(name = "force-skip-settings", description = "Force setup to not modify any device settings. All other setting options will be ignored.")
protected boolean mForceSkipSystemProps @Option(name = "force-skip-system-props", description = "Force setup to not modify any device system properties. All other system property options will be ignored")
protected MultiMap<String, String> mGlobalSettings @Option(name = "set-global-setting", description = "Change a global setting. Option may be repeated and all key/value pairs will be set in order.")
protected BinaryState mInstallNonMarketApps @Option(name = "install-non-market-apps", description = "Allow or prevent non-market app to initiate an apk install request")
protected File mLocalDataFile @Option(name = "local-data-path", description = "Optional local file path of test data to sync to device\'s external storage. Use --remote-data-path to set remote location.")
protected BinaryState mLocationGps @Option(name = "location-gps", description = "Turn the GPS location on or off")
protected BinaryState mLocationNetwork @Option(name = "location-network", description = "Turn the network location on or off")
protected long mMinExternalStorageKb @Option(name = "min-external-storage-kb", description = "The minimum amount of free space in KB that must be present on device\'s external storage.")
protected BinaryState mNotificationLed @Option(name = "notification-led", description = "Turn the notification led on or off")
protected String mRemoteDataPath @Option(name = "remote-data-path", description = "Optional file path on device\'s external storage to sync test data. Must be used with --local-data-path.")
protected List<String> mRunCommandAfterSettings @Option(name = "run-command", description = "Run an adb shell command. Option may be repeated")
protected List<String> mRunCommandBeforeSettings
protected BinaryState mScreenAdaptiveBrightness @Option(name = "screen-adaptive-brightness", description = "Turn screen adaptive brightness on or off")
protected BinaryState mScreenAlwaysOn @Option(name = "screen-always-on", description = "Turn \'screen always on\' on or off. If ON, then screen-timeout-secs must be unset. Will only work when the device is plugged in")
protected BinaryState mScreenAmbientMode @Option(name = "screen-ambient-mode", description = "Turn screen ambient mode on or off")
protected Integer mScreenBrightness @Option(name = "screen-brightness", description = "Set the screen brightness. This is uncalibrated from product to product")
protected BinaryState mScreenSaver @Option(name = "screen-saver", description = "Turn screen saver on or off")
protected Long mScreenTimeoutSecs @Option(name = "screen-timeout-secs", description = "Set the screen timeout in seconds. If set, then screen-always-on must be OFF or DEFAULT")
protected MultiMap<String, String> mSecureSettings @Option(name = "set-secure-setting", description = "Change a secure setting. Option may be repeated and all key/value pairs will be set in order.")
protected Map<String, String> mSetProps @Option(name = "set-property", description = "Set the specified property on boot. Option may be repeated but only the last value for a given key will be set.")
protected boolean mSetTestHarness @Option(name = "set-test-harness", description = "Set the read-only test harness flag on boot")
protected MultiMap<String, String> mSystemSettings @Option(name = "set-system-setting", description = "Change a system (non-secure) setting. Option may be repeated and all key/value pairs will be set in order.")
protected String mTimezone @Option(name = "set-timezone", description = "Set timezone property by TZ name (http://en.wikipedia.org/wiki/List_of_tz_database_time_zones)")
protected boolean mTriggerMediaMounted @Option(name = "trigger-media-mounted", description = "Trigger a MEDIA_MOUNTED broadcast")
protected BinaryState mWakeGesture @Option(name = "wake-gesture", description = "Turn wake gesture on or off")
protected BinaryState mWifi @Option(name = "wifi", description = "Turn wifi on or off")
protected String mWifiPsk @Option(name = "wifi-psk", description = "The passphrase used to connect to a secured network")
protected BinaryState mWifiScanAlwaysEnabled @Option(name = "wifi-scan-always-enabled", description = "Turn wifi scan always enabled on or off")
protected String mWifiSsid @Option(name = "wifi-network", description = "The SSID of the network to connect to. Will only attempt to connect to a network if set")
protected BinaryState mWifiWatchdog @Option(name = "wifi-watchdog", description = "Turn wifi watchdog on or off")
Public Constructors
DeviceSetup()
Public Methods
void changeSettings(ITestDevice device)
Change the settings on the device.
void processDeprecatedOptions()
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)
Exposed for unit testing
void setDeprecatedMinExternalStoreSpace(long storeSpace)
Exposed for unit testing
void setDeprecatedSetProp(String prop)
Exposed for unit testing
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 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
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.targetprep.ITargetPreparer
From interface com.android.tradefed.targetprep.ITargetCleaner

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

private long mDeprecatedMinExternalStoreSpace

private boolean mDeprecatedSetAudioSilent

private Collection<String> mDeprecatedSetProps

protected boolean mDisable

protected boolean mDisableAudio

protected boolean mDisableDalvikVerifier

protected boolean mDisableDialing

protected boolean mDisableDoze

private boolean mDisconnectWifiAfterTest

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

public DeviceSetup ()

Public Methods

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

public void processDeprecatedOptions ()

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.

Throws
TargetSetupError if there is a conflict

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

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

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

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

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

protected void setAirplaneMode (BinaryState airplaneMode)

Exposed for unit testing

Parameters
airplaneMode BinaryState

protected void setAutoRotate (BinaryState autoRotate)

Exposed for unit testing

Parameters
autoRotate BinaryState

protected void setAutoUpdateTime (BinaryState autoUpdateTime)

Exposed for unit testing

Parameters
autoUpdateTime BinaryState

protected void setAutoUpdateTimezone (BinaryState autoUpdateTimezone)

Exposed for unit testing

Parameters
autoUpdateTimezone BinaryState

protected void setBatterySaver (BinaryState batterySaver)

Exposed for unit testing

Parameters
batterySaver BinaryState

protected void setBatterySaverTrigger (Integer batterySaverTrigger)

Exposed for unit testing

Parameters
batterySaverTrigger Integer

protected void setBluetooth (BinaryState bluetooth)

Exposed for unit testing

Parameters
bluetooth BinaryState

protected void setDefaultSimData (Integer defaultSimData)

Exposed for unit testing

Parameters
defaultSimData Integer

protected void setDefaultSimSms (Integer defaultSimSms)

Exposed for unit testing

Parameters
defaultSimSms Integer

protected void setDefaultSimVoice (Integer defaultSimVoice)

Exposed for unit testing

Parameters
defaultSimVoice Integer

protected void setDeprecatedAudioSilent (boolean silent)

Exposed for unit testing

Parameters
silent boolean

protected void setDeprecatedMinExternalStoreSpace (long storeSpace)

Exposed for unit testing

Parameters
storeSpace long

protected void setDeprecatedSetProp (String prop)

Exposed for unit testing

Parameters
prop String

protected void setDisableAudio (boolean disable)

Exposed for unit testing

Parameters
disable boolean

protected void setDisableDalvikVerifier (boolean disableDalvikVerifier)

Exposed for unit testing

Parameters
disableDalvikVerifier boolean

protected void setDisableDialing (boolean disableDialing)

Exposed for unit testing

Parameters
disableDialing boolean

protected void setDisableDoze (boolean disableDoze)

Exposed for unit testing

Parameters
disableDoze boolean

protected void setEnableFullBatteryStatsHistory (boolean enableFullBatteryStatsHistory)

Exposed for unit testing

Parameters
enableFullBatteryStatsHistory boolean

protected void setEthernet (BinaryState ethernet)

Exposed for unit testing

Parameters
ethernet BinaryState

protected void setInstallNonMarketApps (BinaryState installNonMarketApps)

Exposed for unit testing

Parameters
installNonMarketApps BinaryState

protected void setLocalDataPath (File path)

Exposed for unit testing

Parameters
path File

protected void setLocationGps (BinaryState locationGps)

Exposed for unit testing

Parameters
locationGps BinaryState

protected void setLocationNetwork (BinaryState locationNetwork)

Exposed for unit testing

Parameters
locationNetwork BinaryState

protected void setMinExternalStorageKb (long storageKb)

Exposed for unit testing

Parameters
storageKb long

protected void setNotificationLed (BinaryState notificationLed)

Exposed for unit testing

Parameters
notificationLed BinaryState

protected void setProperty (String key, String value)

Exposed for unit testing

Parameters
key String
value String

protected void setScreenAdaptiveBrightness (BinaryState screenAdaptiveBrightness)

Exposed for unit testing

Parameters
screenAdaptiveBrightness BinaryState

protected void setScreenAlwaysOn (BinaryState screenAlwaysOn)

Exposed for unit testing

Parameters
screenAlwaysOn BinaryState

protected void setScreenAmbientMode (BinaryState screenAmbientMode)

Exposed for unit testing

Parameters
screenAmbientMode BinaryState

protected void setScreenBrightness (Integer screenBrightness)

Exposed for unit testing

Parameters
screenBrightness Integer

protected void setScreenSaver (BinaryState screenSaver)

Exposed for unit testing

Parameters
screenSaver BinaryState

protected void setScreenTimeoutSecs (Long screenTimeoutSecs)

Exposed for unit testing

Parameters
screenTimeoutSecs Long

protected void setTestHarness (boolean setTestHarness)

Exposed for unit testing

Parameters
setTestHarness boolean

protected void setTimezone (String timezone)

Exposed for unit testing

Parameters
timezone String

protected void setTriggerMediaMounted (boolean triggerMediaMounted)

Exposed for unit testing

Parameters
triggerMediaMounted boolean

protected void setWakeGesture (BinaryState wakeGesture)

Exposed for unit testing

Parameters
wakeGesture BinaryState

protected void setWifi (BinaryState wifi)

Exposed for unit testing

Parameters
wifi BinaryState

protected void setWifiNetwork (String wifiNetwork)

Exposed for unit testing

Parameters
wifiNetwork String

protected void setWifiScanAlwaysEnabled (BinaryState wifiScanAlwaysEnabled)

Exposed for unit testing

Parameters
wifiScanAlwaysEnabled BinaryState

protected void setWifiWatchdog (BinaryState wifiWatchdog)

Exposed for unit testing

Parameters
wifiWatchdog BinaryState