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)

创建 RemoteAndroidDevice

公共方法

static boolean checkSerialFormatValid(String serialString)

检查序列的格式是否符合预期:端口

boolean connectToWifiNetwork( wifiSsidToPsk, boolean scanSsid)

连接到 WLAN 网络。

DeviceDescriptor getDeviceDescriptor(boolean shortDescriptor)

从设备信息返回 DeviceDescriptor,以便在不传递实际设备对象的情况下获取设备信息。

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)

创建 RemoteAndroidDevice

参数
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)

连接到 WLAN 网络。

开启 wifi 并阻塞,直到与 wifiSsidToPsk 映射中给定的某个 wifi 网络成功建立连接。建立连接后,实例会在每次重新启动后尝试恢复连接,直到调用 ITestDevice.disconnectFromWifi()ITestDevice.clearLastConnectedWifiNetwork()

参数
wifiSsidToPsk :一个将 Wi-Fi SSID 映射到密码的映射。

scanSsid boolean:是否扫描此网络的隐藏 SSID。

返回
boolean true 如果已成功连接到 WLAN 网络。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(前提是设备支持加密)。