RemoteAndroidDevice
public
class
RemoteAndroidDevice
extends TestDevice
java.lang.Object | |||
↳ | com.android.tradefed.device.NativeDevice | ||
↳ | com.android.tradefed.device.TestDevice | ||
↳ | com.android.tradefed.device.RemoteAndroidDevice |
Implementation of a ITestDevice
for a full stack android device connected via
adb connect.
Assume the device serial will be in the format
Summary
Constants | |
---|---|
long |
DEFAULT_SHORT_CMD_TIMEOUT
|
int |
MAX_RETRIES
|
long |
RETRY_INTERVAL_MS
|
long |
WAIT_FOR_ADB_CONNECT
|
Public constructors | |
---|---|
RemoteAndroidDevice(IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
Creates a |
Public methods | |
---|---|
boolean
|
adbTcpConnect(String host, String port)
Helper method to adb connect to a given tcp ip Android device |
boolean
|
adbTcpDisconnect(String host, String port)
Helper method to adb disconnect from a given tcp ip Android device |
static
boolean
|
checkSerialFormatValid(String serialString)
Check if the format of the serial is as expected |
DeviceDescriptor
|
getDeviceDescriptor()
|
String
|
getHostName()
Return the hostname associated with the device. |
String
|
getMacAddress()
|
String
|
getPortNum()
Return the port number asociated with the device. |
boolean
|
isEncryptionSupported()
|
void
|
postAdbRootAction()
Override if the device needs some specific actions to be taken after adb root and before the device is back online. |
void
|
postAdbUnrootAction()
Override if the device needs some specific actions to be taken after adb unroot and before the device is back online. |
void
|
postInvocationTearDown(Throwable exception)
|
void
|
recoverDevice()
Attempts to recover device communication. |
void
|
setAdbLogFile(File adbLogFile)
Give a receiver file where we can store all the adb connection logs for debugging purpose. |
void
|
waitForAdbConnect(long waitTime)
Check if the adb connection is enabled. |
Protected methods | |
---|---|
String
|
getInitialIp()
Returns the initial associated ip to the device if any. |
String
|
getInitialSerial()
Returns the initial serial name of the device. |
void
|
postAdbReboot()
Possible extra actions that can be taken after a reboot. |
Constants
DEFAULT_SHORT_CMD_TIMEOUT
protected static final long DEFAULT_SHORT_CMD_TIMEOUT
Constant Value: 20000 (0x0000000000004e20)
MAX_RETRIES
protected static final int MAX_RETRIES
Constant Value: 5 (0x00000005)
RETRY_INTERVAL_MS
protected static final long RETRY_INTERVAL_MS
Constant Value: 5000 (0x0000000000001388)
WAIT_FOR_ADB_CONNECT
public static final long WAIT_FOR_ADB_CONNECT
Constant Value: 120000 (0x000000000001d4c0)
Public constructors
RemoteAndroidDevice
public RemoteAndroidDevice (IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)
Creates a RemoteAndroidDevice
.
Parameters | |
---|---|
device |
IDevice : the associated IDevice |
stateMonitor |
IDeviceStateMonitor : the IDeviceStateMonitor mechanism to use |
allocationMonitor |
IDeviceMonitor : the IDeviceMonitor to inform of allocation state changes.
|
Public methods
adbTcpConnect
public boolean adbTcpConnect (String host, String port)
Helper method to adb connect to a given tcp ip Android device
Parameters | |
---|---|
host |
String : the hostname/ip of a tcp/ip Android device |
port |
String : the port number of a tcp/ip device |
Returns | |
---|---|
boolean |
true if we successfully connected to the device, false otherwise. |
adbTcpDisconnect
public boolean adbTcpDisconnect (String host, String port)
Helper method to adb disconnect from a given tcp ip Android device
Parameters | |
---|---|
host |
String : the hostname/ip of a tcp/ip Android device |
port |
String : the port number of a tcp/ip device |
Returns | |
---|---|
boolean |
true if we successfully disconnected to the device, false otherwise. |
checkSerialFormatValid
public static boolean checkSerialFormatValid (String serialString)
Check if the format of the serial is as expected
Parameters | |
---|---|
serialString |
String |
Returns | |
---|---|
boolean |
true if the format is valid, false otherwise. |
getDeviceDescriptor
public DeviceDescriptor getDeviceDescriptor ()
Returns | |
---|---|
DeviceDescriptor |
getHostName
public String getHostName ()
Return the hostname associated with the device. Extracted from the serial.
Returns | |
---|---|
String |
getMacAddress
public String getMacAddress ()
Returns | |
---|---|
String |
getPortNum
public String getPortNum ()
Return the port number asociated with the device. Extracted from the serial.
Returns | |
---|---|
String |
isEncryptionSupported
public boolean isEncryptionSupported ()
Returns | |
---|---|
boolean |
postAdbRootAction
public void postAdbRootAction ()
Override if the device needs some specific actions to be taken after adb root and before the device is back online. Default implementation doesn't include any addition actions. adb root is not guaranteed to be enabled at this stage.
Throws | |
---|---|
DeviceNotAvailableException |
postAdbUnrootAction
public void postAdbUnrootAction ()
Override if the device needs some specific actions to be taken after adb unroot and before the device is back online. Default implementation doesn't include any additional actions. adb root is not guaranteed to be disabled at this stage.
Throws | |
---|---|
DeviceNotAvailableException |
postInvocationTearDown
public void postInvocationTearDown (Throwable exception)
Parameters | |
---|---|
exception |
Throwable |
recoverDevice
public void recoverDevice ()
Attempts to recover device communication.
Throws | |
---|---|
DeviceNotAvailableException |
setAdbLogFile
public void setAdbLogFile (File adbLogFile)
Give a receiver file where we can store all the adb connection logs for debugging purpose.
Parameters | |
---|---|
adbLogFile |
File |
waitForAdbConnect
public void waitForAdbConnect (long waitTime)
Check if the adb connection is enabled.
Parameters | |
---|---|
waitTime |
long |
Throws | |
---|---|
DeviceNotAvailableException |
Protected methods
getInitialIp
protected String getInitialIp ()
Returns the initial associated ip to the device if any. Returns null if no known initial ip.
Returns | |
---|---|
String |
getInitialSerial
protected String getInitialSerial ()
Returns the initial serial name of the device.
Returns | |
---|---|
String |
postAdbReboot
protected void postAdbReboot ()
Possible extra actions that can be taken after a reboot.
Throws | |
---|---|
DeviceNotAvailableException |