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」的裝置,通常是 userdebug 建構類型。
應在刷入新版本後執行。
注意:這個準備工具適用於持續測試實驗室,並假設受測裝置會在下次執行前刷機並清除資料。因此,它在拆除期間會進行最少的清理作業,不應在測試模組中使用。
摘要
公用建構函式 | |
|---|---|
DeviceSetup()
|
|
公用方法 | |
|---|---|
void
|
changeSettings(ITestDevice device)
變更裝置上的設定。 |
Set<ExternalDependency>
|
getDependencies()
|
ITestDevice
|
getDevice(TestInformation testInfo)
|
boolean
|
isForceSkipSystemProps()
|
void
|
processDeprecatedOptions(ITestDevice device)
處理已淘汰的選項,並轉換為目前使用的選項。 |
void
|
processOptions(ITestDevice device)
處理所有 |
static
void
|
setCommandForBinaryState(BinaryState state, List<String> commands, String onCommand, String offCommand)
輔助方法,可新增要在裝置上執行的 ON/OFF 執行指令。 |
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)
這個方法已淘汰,
請改用 |
void
|
setDeprecatedMinExternalStoreSpace(long storeSpace)
這個方法已淘汰,
請改用 |
void
|
setDeprecatedSetProp(String prop)
這個方法已淘汰,
請改用 |
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(Map<String, String> wifiSssidToPsk)
|
void
|
setWifiWatchdog(BinaryState wifiWatchdog)
公開以供單元測試 |
欄位
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
protected List<String> mRunCommandAfterSettings
mRunCommandBeforeSettings
protected List<String> mRunCommandBeforeSettings
mScreenBrightness
protected Integer mScreenBrightness
mScreenTimeoutSecs
protected Long mScreenTimeoutSecs
mSetProps
protected Map<String, String> mSetProps
mSetTestHarness
protected boolean mSetTestHarness
mTimezone
protected String mTimezone
mTriggerMediaMounted
protected boolean mTriggerMediaMounted
mWifiPsk
protected String mWifiPsk
mWifiSsid
protected String mWifiSsid
mWifiSsidToPsk
protected Map<String, String> mWifiSsidToPsk
公用建構函式
DeviceSetup
public DeviceSetup ()
公用方法
changeSettings
public void changeSettings (ITestDevice device)
變更裝置上的設定。
公開,因此子項類別可能會覆寫。
| 參數 | |
|---|---|
device |
ITestDevice:ITestDevice |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
如果無法使用裝置 |
TargetSetupError |
無法設定設定 |
getDependencies
public Set<ExternalDependency> getDependencies ()
| 傳回 | |
|---|---|
Set<ExternalDependency> |
|
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 |
ITestDevice:ITestDevice |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
如果無法使用裝置 |
TargetSetupError |
如果 Option 發生衝突 |
setCommandForBinaryState
public static void setCommandForBinaryState (BinaryState state, List<String> commands, String onCommand, String offCommand)
輔助方法,可新增要在裝置上執行的開啟/關閉執行指令。
| 參數 | |
|---|---|
state |
BinaryState:BinaryState |
commands |
List:要新增開啟或關閉指令的指令清單。 |
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 |
BinaryState:BinaryState |
settingsMap |
MultiMap:用於儲存設定的 MultiMap。 |
setting |
String:設定鍵 |
onValue |
String:開啟時的值 |
offValue |
String:如果為 OFF,則為這個值 |
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 |
setCellAutoSetting
protected void setCellAutoSetting (BinaryState cellAutoSetting)
| 參數 | |
|---|---|
cellAutoSetting |
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)
這個方法已淘汰。
請改用 setDisableAudio(boolean)。
公開以進行單元測試
| 參數 | |
|---|---|
silent |
boolean |
setDeprecatedMinExternalStoreSpace
protected void setDeprecatedMinExternalStoreSpace (long storeSpace)
這個方法已淘汰。
請改用 setMinExternalStorageKb(long)。
公開以進行單元測試
| 參數 | |
|---|---|
storeSpace |
long |
setDeprecatedSetProp
protected void setDeprecatedSetProp (String prop)
這個方法已淘汰。
請改用 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 |
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 |
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 |
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 (Map<String, String> wifiSssidToPsk)
| 參數 | |
|---|---|
wifiSssidToPsk |
Map |
setWifiWatchdog
protected void setWifiWatchdog (BinaryState wifiWatchdog)
公開以進行單元測試
| 參數 | |
|---|---|
wifiWatchdog |
BinaryState |