DeviceSetup

public class DeviceSetup
extends BaseTargetPreparer implements IExternalDependency

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


ITargetPreparer 會根據提供的 Option 設定裝置以進行測試。

需要可進行「adb root」的裝置,通常是使用者偵錯版本類型。

應在刷新新版本後執行。

注意:這個準備工具適用於持續測試實驗室,並假設測試中的裝置會在下次執行前刷新並清除。因此,它會在解構期間進行最少的清理作業,且不應在測試模組中使用。

摘要

欄位

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

公用建構函式

DeviceSetup()

公用方法

void changeSettings(ITestDevice device)

變更裝置上的設定。

getDependencies()
ITestDevice getDevice(TestInformation testInfo)
boolean isForceSkipSystemProps()
void processDeprecatedOptions(ITestDevice device)

處理已淘汰的選項,將其轉換為目前使用的選項。

void processOptions(ITestDevice device)

處理所有 Option,並將其轉換為系統道具、設定或執行指令。

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

輔助方法,用於新增要在裝置上執行的開/關執行指令。

void setGlobalSetting(String key, String value)

公開供單元測試使用

void setSecureSetting(String key, String value)

公開供單元測試使用

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

輔助方法,可將開/關設定新增至設定對照圖。

void setSystemSetting(String key, String value)

公開供單元測試使用

void setUp(TestInformation testInfo)

void tearDown(TestInformation testInfo, Throwable e)

受保護的方法

void setAirplaneMode(BinaryState airplaneMode)

公開供單元測試使用

void setAutoRotate(BinaryState autoRotate)

公開供單元測試使用

void setAutoUpdateTime(BinaryState autoUpdateTime)

公開供單元測試使用

void setAutoUpdateTimezone(BinaryState autoUpdateTimezone)

公開供單元測試使用

void setBatterySaver(BinaryState batterySaver)

公開供單元測試使用

void setBatterySaverTrigger(Integer batterySaverTrigger)

公開供單元測試使用

void setBluetooth(BinaryState bluetooth)

公開供單元測試使用

void setCell(BinaryState cell)
void setCellAutoSetting(BinaryState cellAutoSetting)
void setData(BinaryState data)
void setDefaultSimData(Integer defaultSimData)

公開供單元測試使用

void setDefaultSimSms(Integer defaultSimSms)

公開供單元測試使用

void setDefaultSimVoice(Integer defaultSimVoice)

公開供單元測試使用

void setDeprecatedAudioSilent(boolean silent)

這個方法已淘汰。 請改用 setDisableAudio(boolean)

void setDeprecatedMinExternalStoreSpace(long storeSpace)

這個方法已淘汰。 請改用 setMinExternalStorageKb(long)

void setDeprecatedSetProp(String prop)

這個方法已淘汰。 請改用 setProperty(String, String)

void setDisableAudio(boolean disable)

公開供單元測試使用

void setDisableCwWifiMediator(BinaryState disableCwWifiMediator)
void setDisableDalvikVerifier(boolean disableDalvikVerifier)

公開供單元測試使用

void setDisableDialing(boolean disableDialing)

公開供單元測試使用

void setDisableDoze(boolean disableDoze)

公開供單元測試使用

void setEnableFullBatteryStatsHistory(boolean enableFullBatteryStatsHistory)

公開供單元測試使用

void setEthernet(BinaryState ethernet)

公開供單元測試使用

void setForceRootSetup(boolean force)
void setForceSkipSystemProps(boolean force)

公開供單元測試使用

void setInstallNonMarketApps(BinaryState installNonMarketApps)

公開供單元測試使用

void setLocalDataPath(File path)

公開供單元測試使用

void setLocationGps(BinaryState locationGps)

公開供單元測試使用

void setLocationNetwork(BinaryState locationNetwork)

公開供單元測試使用

void setMinExternalStorageKb(long storageKb)

公開供單元測試使用

void setNfc(BinaryState nfc)

公開供單元測試使用

void setNotificationLed(BinaryState notificationLed)

公開供單元測試使用

void setProperty(String key, String value)

公開供單元測試使用

void setRestoreProperties(boolean restoreProperties)

公開供單元測試使用

void setRestoreSettings(boolean restoreSettings)

公開供單元測試使用

void setScreenAdaptiveBrightness(BinaryState screenAdaptiveBrightness)

公開供單元測試使用

void setScreenAlwaysOn(BinaryState screenAlwaysOn)

公開供單元測試使用

void setScreenAmbientMode(BinaryState screenAmbientMode)

公開供單元測試使用

void setScreenBrightness(Integer screenBrightness)

公開供單元測試使用

void setScreenSaver(BinaryState screenSaver)

公開供單元測試使用

void setScreenTimeoutSecs(Long screenTimeoutSecs)

公開供單元測試使用

void setTestHarness(boolean setTestHarness)

公開供單元測試使用

void setTimezone(String timezone)

公開供單元測試使用

void setTriggerMediaMounted(boolean triggerMediaMounted)

公開供單元測試使用

void setWakeGesture(BinaryState wakeGesture)

公開供單元測試使用

void setWifi(BinaryState wifi)

公開供單元測試使用

void setWifiNetwork(String wifiNetwork)

公開供單元測試使用

void setWifiPsk(String wifiPsk)
void setWifiScanAlwaysEnabled(BinaryState wifiScanAlwaysEnabled)

公開供單元測試使用

void setWifiSsidToPsk( wifiSssidToPsk)
void setWifiWatchdog(BinaryState wifiWatchdog)

公開供單元測試使用

欄位

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

公用建構函式

DeviceSetup

public DeviceSetup ()

公用方法

changeSettings

public void changeSettings (ITestDevice device)

變更裝置的設定。

已公開,因此子類別可覆寫。

參數
device ITestDeviceITestDevice

擲回
DeviceNotAvailableException 如果裝置無法使用
TargetSetupError 是否設定失敗

getDependencies

public  getDependencies ()

傳回

getDevice

public ITestDevice getDevice (TestInformation testInfo)

參數
testInfo TestInformation

傳回
ITestDevice

isForceSkipSystemProps

public boolean isForceSkipSystemProps ()

傳回
boolean

processDeprecatedOptions

public void processDeprecatedOptions (ITestDevice device)

處理已淘汰的選項,將這些選項轉換為目前使用的選項。

您應在執行其他處理方法之前,先執行這個方法。如果已淘汰的選項覆寫指定的非淘汰選項,系統會擲回 TargetSetupError

參數
device ITestDevice

擲回
TargetSetupError 是否有衝突

processOptions

public void processOptions (ITestDevice device)

處理所有 Option,並將其轉換為系統道具、設定或執行指令。目前不會在裝置上執行任何指令。

公開,以便子類別覆寫此值。

參數
device ITestDeviceITestDevice

擲回
DeviceNotAvailableException 如果裝置無法使用
TargetSetupError 如果 Option 發生衝突

setCommandForBinaryState

public static void setCommandForBinaryState (BinaryState state, 
                 commands, 
                String onCommand, 
                String offCommand)

輔助方法,用於新增要在裝置上執行的開/關執行指令。

參數
state BinaryStateBinaryState

commands :要加入開啟或關閉指令的指令清單。

onCommand String:如果為 ON,則執行的指令。如果指令為 null,則會遭到忽略

offCommand String:如果為 OFF,則執行的指令。如果指令為 null,則會略過

setGlobalSetting

public void setGlobalSetting (String key, 
                String value)

公開供單元測試使用

參數
key String

value String

setSecureSetting

public void setSecureSetting (String key, 
                String value)

公開供單元測試使用

參數
key String

value String

setSettingForBinaryState

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

輔助方法,可將開/關設定加入設定地圖。

參數
state BinaryStateBinaryState

settingsMap MultiMap:用於儲存設定的 MultiMap

setting String:設定鍵

onValue String:如果為開啟,則為這個值

offValue String:如果為「關閉」,則為這個值

setSystemSetting

public void setSystemSetting (String key, 
                String value)

公開供單元測試使用

參數
key String

value String

setUp

public void setUp (TestInformation testInfo)

參數
testInfo TestInformation

擲回
BuildError
DeviceNotAvailableException
TargetSetupError

tearDown

public void tearDown (TestInformation testInfo, 
                Throwable e)

參數
testInfo TestInformation

e Throwable

擲回
DeviceNotAvailableException

受保護的方法

setAirplaneMode

protected void setAirplaneMode (BinaryState airplaneMode)

公開供單元測試使用

參數
airplaneMode BinaryState

setAutoRotate

protected void setAutoRotate (BinaryState autoRotate)

公開供單元測試使用

參數
autoRotate BinaryState

setAutoUpdateTime

protected void setAutoUpdateTime (BinaryState autoUpdateTime)

公開供單元測試使用

參數
autoUpdateTime BinaryState

setAutoUpdateTimezone

protected void setAutoUpdateTimezone (BinaryState autoUpdateTimezone)

公開供單元測試使用

參數
autoUpdateTimezone BinaryState

setBatterySaver

protected void setBatterySaver (BinaryState batterySaver)

公開供單元測試使用

參數
batterySaver BinaryState

setBatterySaverTrigger

protected void setBatterySaverTrigger (Integer batterySaverTrigger)

公開供單元測試使用

參數
batterySaverTrigger Integer

setBluetooth

protected void setBluetooth (BinaryState bluetooth)

公開供單元測試使用

參數
bluetooth BinaryState

setCell

protected void setCell (BinaryState cell)

參數
cell BinaryState

setCellAutoSetting

protected void setCellAutoSetting (BinaryState cellAutoSetting)

參數
cellAutoSetting BinaryState

setData

protected void setData (BinaryState data)

參數
data BinaryState

setDefaultSimData

protected void setDefaultSimData (Integer defaultSimData)

公開供單元測試使用

參數
defaultSimData Integer

setDefaultSimSms

protected void setDefaultSimSms (Integer defaultSimSms)

公開供單元測試使用

參數
defaultSimSms Integer

setDefaultSimVoice

protected void setDefaultSimVoice (Integer defaultSimVoice)

公開供單元測試使用

參數
defaultSimVoice Integer

setDeprecatedAudioSilent

protected void setDeprecatedAudioSilent (boolean silent)

This method is deprecated.
請改用 setDisableAudio(boolean)

公開供單元測試使用

參數
silent boolean

setDeprecatedMinExternalStoreSpace

protected void setDeprecatedMinExternalStoreSpace (long storeSpace)

This method is deprecated.
請改用 setMinExternalStorageKb(long)

公開供單元測試使用

參數
storeSpace long

setDeprecatedSetProp

protected void setDeprecatedSetProp (String prop)

This method is deprecated.
請改用 setProperty(String, String)

公開供單元測試使用

參數
prop String

setDisableAudio

protected void setDisableAudio (boolean disable)

公開供單元測試使用

參數
disable boolean

setDisableCwWifiMediator

protected void setDisableCwWifiMediator (BinaryState disableCwWifiMediator)

參數
disableCwWifiMediator BinaryState

setDisableDalvikVerifier

protected void setDisableDalvikVerifier (boolean disableDalvikVerifier)

公開供單元測試使用

參數
disableDalvikVerifier boolean

setDisableDialing

protected void setDisableDialing (boolean disableDialing)

公開供單元測試使用

參數
disableDialing boolean

setDisableDoze

protected void setDisableDoze (boolean disableDoze)

公開供單元測試使用

參數
disableDoze boolean

setEnableFullBatteryStatsHistory

protected void setEnableFullBatteryStatsHistory (boolean enableFullBatteryStatsHistory)

公開供單元測試使用

參數
enableFullBatteryStatsHistory boolean

setEthernet

protected void setEthernet (BinaryState ethernet)

公開供單元測試使用

參數
ethernet BinaryState

setForceRootSetup

protected void setForceRootSetup (boolean force)

參數
force boolean

setForceSkipSystemProps

protected void setForceSkipSystemProps (boolean force)

公開供單元測試使用

參數
force boolean

setInstallNonMarketApps

protected void setInstallNonMarketApps (BinaryState installNonMarketApps)

公開供單元測試使用

參數
installNonMarketApps BinaryState

setLocalDataPath

protected void setLocalDataPath (File path)

公開供單元測試使用

參數
path File

setLocationGps

protected void setLocationGps (BinaryState locationGps)

公開供單元測試使用

參數
locationGps BinaryState

setLocationNetwork

protected void setLocationNetwork (BinaryState locationNetwork)

公開供單元測試使用

參數
locationNetwork BinaryState

setMinExternalStorageKb

protected void setMinExternalStorageKb (long storageKb)

公開供單元測試使用

參數
storageKb long

setNfc

protected void setNfc (BinaryState nfc)

公開供單元測試使用

參數
nfc BinaryState

setNotificationLed

protected void setNotificationLed (BinaryState notificationLed)

公開供單元測試使用

參數
notificationLed BinaryState

setProperty

protected void setProperty (String key, 
                String value)

公開供單元測試使用

參數
key String

value String

setRestoreProperties

protected void setRestoreProperties (boolean restoreProperties)

公開供單元測試使用

參數
restoreProperties boolean

setRestoreSettings

protected void setRestoreSettings (boolean restoreSettings)

公開供單元測試使用

參數
restoreSettings boolean

setScreenAdaptiveBrightness

protected void setScreenAdaptiveBrightness (BinaryState screenAdaptiveBrightness)

公開供單元測試使用

參數
screenAdaptiveBrightness BinaryState

setScreenAlwaysOn

protected void setScreenAlwaysOn (BinaryState screenAlwaysOn)

公開供單元測試使用

參數
screenAlwaysOn BinaryState

setScreenAmbientMode

protected void setScreenAmbientMode (BinaryState screenAmbientMode)

公開供單元測試使用

參數
screenAmbientMode BinaryState

setScreenBrightness

protected void setScreenBrightness (Integer screenBrightness)

公開供單元測試使用

參數
screenBrightness Integer

setScreenSaver

protected void setScreenSaver (BinaryState screenSaver)

公開供單元測試使用

參數
screenSaver BinaryState

setScreenTimeoutSecs

protected void setScreenTimeoutSecs (Long screenTimeoutSecs)

公開供單元測試使用

參數
screenTimeoutSecs Long

setTestHarness

protected void setTestHarness (boolean setTestHarness)

公開供單元測試使用

參數
setTestHarness boolean

setTimezone

protected void setTimezone (String timezone)

公開供單元測試使用

參數
timezone String

setTriggerMediaMounted

protected void setTriggerMediaMounted (boolean triggerMediaMounted)

公開供單元測試使用

參數
triggerMediaMounted boolean

setWakeGesture

protected void setWakeGesture (BinaryState wakeGesture)

公開供單元測試使用

參數
wakeGesture BinaryState

setWifi

protected void setWifi (BinaryState wifi)

公開供單元測試使用

參數
wifi BinaryState

setWifiNetwork

protected void setWifiNetwork (String wifiNetwork)

公開供單元測試使用

參數
wifiNetwork String

setWifiPsk

protected void setWifiPsk (String wifiPsk)

參數
wifiPsk String

setWifiScanAlwaysEnabled

protected void setWifiScanAlwaysEnabled (BinaryState wifiScanAlwaysEnabled)

公開供單元測試使用

參數
wifiScanAlwaysEnabled BinaryState

setWifiSsidToPsk

protected void setWifiSsidToPsk ( wifiSssidToPsk)

參數
wifiSssidToPsk

setWifiWatchdog

protected void setWifiWatchdog (BinaryState wifiWatchdog)

公開供單元測試使用

參數
wifiWatchdog BinaryState