AdbTcpConnection

public class AdbTcpConnection
extends DefaultConnection

java.lang.Object
   ↳ com.android.tradefed.device.connection.AbstractConnection
     ↳ com.android.tradefed.device.connection.DefaultConnection
       ↳ com.android.tradefed.device.connection.AdbTcpConnection


Default connection representation of a device, assumed to be a standard adb connection of the device.

Summary

Constants

long DEFAULT_SHORT_CMD_TIMEOUT

int MAX_RETRIES

long RETRY_INTERVAL_MS

long WAIT_FOR_ADB_CONNECT

Public constructors

AdbTcpConnection(DefaultConnection.ConnectionBuilder builder)

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

String getHostName(String serial)

Return the hostname associated with the device.

String getPortNum(String serial)

Return the port number asociated with the device.

getSuiteSnapshots()

Returns the map of snapshots

void reconnect(String serial)

Reconnect the connection to the device.

void recoverVirtualDevice(ITestDevice device, String snapshotId, DeviceNotAvailableException dnae)

Recover the given device with device reset.

void setAdbLogFile(File adbLogFile)

Give a receiver file where we can store all the adb connection logs for debugging purpose.

void snapshotDevice(ITestDevice device, String snapshotId)

Snapshot the given device

void tearDownConnection()

Clean up the connection.

Protected methods

void waitForAdbConnect(String serial, long waitTime)

Check if the adb connection is enabled.

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

protected static final long WAIT_FOR_ADB_CONNECT

Constant Value: 120000 (0x000000000001d4c0)

Public constructors

AdbTcpConnection

public AdbTcpConnection (DefaultConnection.ConnectionBuilder builder)

Parameters
builder DefaultConnection.ConnectionBuilder

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.

getHostName

public String getHostName (String serial)

Return the hostname associated with the device. Extracted from the serial.

Parameters
serial String

Returns
String

getPortNum

public String getPortNum (String serial)

Return the port number asociated with the device. Extracted from the serial.

Parameters
serial String

Returns
String

getSuiteSnapshots

public  getSuiteSnapshots ()

Returns the map of snapshots

Returns

reconnect

public void reconnect (String serial)

Reconnect the connection to the device.

Parameters
serial String: The device serial number.

Throws
DeviceNotAvailableException

recoverVirtualDevice

public void recoverVirtualDevice (ITestDevice device, 
                String snapshotId, 
                DeviceNotAvailableException dnae)

Recover the given device with device reset.

Parameters
device ITestDevice: the ITestDevice is used for device reset handler.

snapshotId String: the snapshotId is used for fetching the correct snapshot to restore.

dnae DeviceNotAvailableException: the DeviceNotAvailableException is existing device not available exception.

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

snapshotDevice

public void snapshotDevice (ITestDevice device, 
                String snapshotId)

Snapshot the given device

Parameters
device ITestDevice: the ITestDevice is used for device snapshot handler.

snapshotId String: the snapshotId is the name of the snapshot that will be saved.

Throws
DeviceNotAvailableException

tearDownConnection

public void tearDownConnection ()

Clean up the connection.

Protected methods

waitForAdbConnect

protected void waitForAdbConnect (String serial, 
                long waitTime)

Check if the adb connection is enabled.

Parameters
serial String

waitTime long

Throws
DeviceNotAvailableException