遠端 Android 裝置

public class RemoteAndroidDevice
extends TestDevice

java.lang.Object
   ↳ com.android.tradefed.device.NativeDevice
     ↳ com.android.tradefed.device.TestDevice
       ↳ com.android.tradefed.device.RemoteAndroidDevice


針對透過 ADB 連結連結的完整堆疊 Android 裝置實作 ITestDevice。假設裝置序號的格式應為 : in adb.

摘要

常數

long DEFAULT_SHORT_CMD_TIMEOUT

int MAX_RETRIES

long RETRY_INTERVAL_MS

long WAIT_FOR_ADB_CONNECT

公用建構函式

RemoteAndroidDevice(IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

可建立 RemoteAndroidDevice

公用方法

static boolean checkSerialFormatValid(String serialString)

檢查序列格式是否與預期的 :port

boolean connectToWifiNetwork( wifiSsidToPsk, boolean scanSsid)

連線至 Wi-Fi 網路。

DeviceDescriptor getDeviceDescriptor(boolean shortDescriptor)

從裝置資訊傳回 DeviceDescriptor 即可取得相關資訊,而不會傳送實際的裝置物件。

String getFastbootSerialNumber()

傳回 Quickboot 模式的序號。

String getMacAddress()

傳回裝置的 MAC 位址;如果無法從裝置查詢,則傳回空值。

boolean isEncryptionSupported()

如果裝置支援加密,則傳回 。

常數

DEFAULT_SHORT_CMD_TIMEOUT

protected static final long DEFAULT_SHORT_CMD_TIMEOUT

常數值:20000 (0x0000000000004e20)

重試次數

protected static final int MAX_RETRIES

常數值:5 (0x00000005)

RETRY_INTERVAL_MS

protected static final long RETRY_INTERVAL_MS

常數值:5000 (0x0000000000001388)

WAIT_FOR_ADB_CONNECT

public static final long WAIT_FOR_ADB_CONNECT

常數值:120000 (0x000000000001d4c0)

公用建構函式

遠端 Android 裝置

public RemoteAndroidDevice (IDevice device, 
                IDeviceStateMonitor stateMonitor, 
                IDeviceMonitor allocationMonitor)

可建立 RemoteAndroidDevice

參數
device IDevice:相關聯的 IDevice

stateMonitor IDeviceStateMonitor:要使用的 IDeviceStateMonitor 機制

allocationMonitor IDeviceMonitor:用於通知配置狀態變更的 IDeviceMonitor

公用方法

checkSerialFormatValid

public static boolean checkSerialFormatValid (String serialString)

檢查序列的格式是否符合預期的 :port

參數
serialString String

傳回
boolean 如果格式有效,則為 true,否則傳回 false。

連上 Wi-Fi 網路

public boolean connectToWifiNetwork ( wifiSsidToPsk, 
                boolean scanSsid)

連線至 Wi-Fi 網路。

開啟 Wi-Fi 並保持連線,直到成功連上 wifiSsidToPsk 地圖中提供的其中一個 Wi-Fi 網路。建立連線後,執行個體會在每次重新啟動後嘗試恢復連線,直到呼叫 ITestDevice#disconnectFromWifi()ITestDevice#clearLastConnectedWifiNetwork() 為止。

參數
wifiSsidToPsk :Wi-Fi SSID 和密碼的對應表。

scanSsid boolean:是否要掃描這個網路的隱藏 SSID。

傳回
boolean true (如果已成功連上 Wi-Fi 網路)。否則為 false

擲回
DeviceNotAvailableException

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)

從裝置資訊傳回 DeviceDescriptor 即可取得相關資訊,而不會傳送實際的裝置物件。

參數
shortDescriptor boolean:是否要將描述元限制為最低限度

傳回
DeviceDescriptor

getFastbootSerialNumber

public String getFastbootSerialNumber ()

傳回 Quickboot 模式的序號。

傳回
String

getMacAddress

public String getMacAddress ()

傳回裝置的 MAC 位址;如果無法從裝置查詢,則傳回空值。

傳回
String

isEncryption 支援

public boolean isEncryptionSupported ()

如果裝置支援加密,則傳回 。

傳回
boolean 如果裝置支援加密功能,則為 true