RemoteAndroidVirtualDevice

public class RemoteAndroidVirtualDevice
extends RemoteAndroidDevice implements ITestLoggerReceiver

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


Extends RemoteAndroidDevice behavior for a full stack android device running in the Google Compute Engine (Gce). Assume the device serial will be in the format : in adb.

Summary

Public constructors

RemoteAndroidVirtualDevice(IDevice device, IDeviceStateMonitor stateMonitor, IDeviceMonitor allocationMonitor)

Creates a RemoteAndroidVirtualDevice.

Public methods

GceAvdInfo getAvdInfo()

Returns the GceAvdInfo from the created remote VM.

DeviceDescriptor getDeviceDescriptor()

Return a DeviceDescriptor from the device information to get info on it without passing the actual device object.

getTombstones()

Cuttlefish has a special feature that brings the tombstones to the remote host where we can get them directly.

void postBootSetup()

{@inherit }

void postInvocationTearDown(Throwable exception)

Extra steps for device specific required clean up that will be executed after the invocation is done.

boolean powerwashGce()

Attempt to powerwash a GCE instance

void preInvocationSetup(IBuildInfo info, MultiMap<String, String> attributes)

Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.

void recoverDevice()

Attempts to recover device communication.

void setGceSshMonitor(GceSshTunnelMonitor gceSshMonitor)

Override the internal GceSshTunnelMonitor of the device.

void setTestLogger(ITestLogger testLogger)

Injects the ITestLogger instance

Protected methods

void doAdbReboot(NativeDevice.RebootMode rebootMode, String reason)

Perform a adb reboot.

long getCurrentTime()

Returns the current system time.

GceSshTunnelMonitor getGceSshMonitor()

Returns the GceSshTunnelMonitor of the device.

void launchGce(IBuildInfo buildInfo, MultiMap<String, String> attributes)

Launch the actual gce device based on the build info.

void postAdbReboot()

Possible extra actions that can be taken after a reboot.

void waitForTunnelOnline(long waitTime)

Check if the tunnel monitor is running.

Public constructors

RemoteAndroidVirtualDevice

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

Creates a RemoteAndroidVirtualDevice.

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

getAvdInfo

public GceAvdInfo getAvdInfo ()

Returns the GceAvdInfo from the created remote VM. Returns null if the bring up was not successful.

Returns
GceAvdInfo

getDeviceDescriptor

public DeviceDescriptor getDeviceDescriptor ()

Return a DeviceDescriptor from the device information to get info on it without passing the actual device object.

Returns
DeviceDescriptor

getTombstones

public  getTombstones ()

Cuttlefish has a special feature that brings the tombstones to the remote host where we can get them directly.

Returns
A list of tombstone files, empty if no tombstone.

Throws
DeviceNotAvailableException

postBootSetup

public void postBootSetup ()

{@inherit }

Throws
DeviceNotAvailableException

postInvocationTearDown

public void postInvocationTearDown (Throwable exception)

Extra steps for device specific required clean up that will be executed after the invocation is done.

Parameters
exception Throwable: if any, the final exception raised by the invocation failure.

powerwashGce

public boolean powerwashGce ()

Attempt to powerwash a GCE instance

Returns
boolean returns true if powerwash Gce success.

Throws
com.android.tradefed.targetprep.TargetSetupError
DeviceNotAvailableException
TargetSetupError

preInvocationSetup

public void preInvocationSetup (IBuildInfo info, 
                MultiMap<String, String> attributes)

Extra steps for device specific required setup that will be executed on the device prior to the invocation flow.

Parameters
info IBuildInfo: The IBuildInfo of the device.

attributes MultiMap: The attributes stored in the invocation context

Throws
DeviceNotAvailableException
TargetSetupError

recoverDevice

public void recoverDevice ()

Attempts to recover device communication.

Throws
DeviceNotAvailableException

setGceSshMonitor

public void setGceSshMonitor (GceSshTunnelMonitor gceSshMonitor)

Override the internal GceSshTunnelMonitor of the device.

Parameters
gceSshMonitor GceSshTunnelMonitor

setTestLogger

public void setTestLogger (ITestLogger testLogger)

Injects the ITestLogger instance

Parameters
testLogger ITestLogger

Protected methods

doAdbReboot

protected void doAdbReboot (NativeDevice.RebootMode rebootMode, 
                String reason)

Perform a adb reboot.

Parameters
rebootMode NativeDevice.RebootMode: a mode of this reboot.

reason String: for this reboot.

Throws
DeviceNotAvailableException

getCurrentTime

protected long getCurrentTime ()

Returns the current system time. Exposed for testing.

Returns
long

getGceSshMonitor

protected GceSshTunnelMonitor getGceSshMonitor ()

Returns the GceSshTunnelMonitor of the device. Exposed for testing.

Returns
GceSshTunnelMonitor

launchGce

protected void launchGce (IBuildInfo buildInfo, 
                MultiMap<String, String> attributes)

Launch the actual gce device based on the build info.

Parameters
buildInfo IBuildInfo

attributes MultiMap

Throws
TargetSetupError

postAdbReboot

protected void postAdbReboot ()

Possible extra actions that can be taken after a reboot.

Throws
DeviceNotAvailableException

waitForTunnelOnline

protected void waitForTunnelOnline (long waitTime)

Check if the tunnel monitor is running.

Parameters
waitTime long

Throws
DeviceNotAvailableException