RemoteAndroidDevice
public
class
RemoteAndroidDevice
extends TestDevice
java.lang.Object | |||
↳ | com.android.tradefed.device.NativeDevice | ||
↳ | com.android.tradefed.device.TestDevice | ||
↳ | com.android.tradefed.device.RemoteAndroidDevice |
为通过 adb connect 连接的完整堆栈 Android 设备实现 ITestDevice
。
假设设备序列号的格式为 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)
|
公共方法 | |
---|---|
static
boolean
|
checkSerialFormatValid(String serialString)
检查串行端口的格式是否符合预期 |
boolean
|
connectToWifiNetwork(
连接到 Wi-Fi 网络。 |
DeviceDescriptor
|
getDeviceDescriptor(boolean shortDescriptor)
从设备信息返回 |
String
|
getMacAddress()
返回设备的 MAC 地址,如果从设备中无法查询,则返回 null。 |
boolean
|
isEncryptionSupported()
返回设备是否支持加密。 |
常量
DEFAULT_SHORT_CMD_TIMEOUT
protected static final long DEFAULT_SHORT_CMD_TIMEOUT
常量值: 20000 (0x0000000000004e20)
MAX_RETRIES
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)
公共构造函数
RemoteAndroidDevice
public RemoteAndroidDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
参数 | |
---|---|
device |
IDevice :关联的 IDevice |
stateMonitor |
IDeviceStateMonitor :要使用的 IDeviceStateMonitor 机制 |
allocationMonitor |
IDeviceMonitor :用于通知分配状态变化的 IDeviceMonitor 。 |
公共方法
checkSerialFormatValid
public static boolean checkSerialFormatValid (String serialString)
检查串行端口的格式是否符合预期
参数 | |
---|---|
serialString |
String |
返回 | |
---|---|
boolean |
如果格式有效,则为 true;否则为 false。 |
connectToWifiNetwork
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 |
如果成功连接到 Wi-Fi 网络,则返回 true 。false
否则 |
抛出 | |
---|---|
DeviceNotAvailableException |
getDeviceDescriptor
public DeviceDescriptor getDeviceDescriptor (boolean shortDescriptor)
从设备信息返回 DeviceDescriptor
,以获取其相关信息,而无需传递实际的设备对象。
参数 | |
---|---|
shortDescriptor |
boolean :是否将描述符限制为仅包含必要信息 |
返回 | |
---|---|
DeviceDescriptor |
getMacAddress
public String getMacAddress ()
返回设备的 MAC 地址,如果无法从设备中查询,则返回 null。
返回 | |
---|---|
String |
isEncryptionSupported
public boolean isEncryptionSupported ()
返回设备是否支持加密。
返回 | |
---|---|
boolean |
true (前提是设备支持加密)。 |