to top
public class

SdkAvdPreparer

extends Object
implements ITargetPreparer ITargetCleaner
java.lang.Object
   ↳ com.android.tradefed.targetprep.SdkAvdPreparer
Known Direct Subclasses

Class Overview

A ITargetPreparer that will create an avd and launch an emulator

Summary

Fields
private String mAbi @Option(name = "abi", description = "abi to select for the avd")
private String mAvdSkin @Option(name = "skin", description = "AVD skin")
private String mAvdTag @Option(name = "tag", description = "The sys-img tag to use for the AVD.")
private int mAvdTimeoutSeconds @Option(name = "avd-timeout", description = "the maximum time in seconds to wait for avd creation")
private String mDevice @Option(name = "emulator-device-type", description = "emulator device type to launch.If unspecified, will launch generic version")
private String mDisplay @Option(name = "display", description = "which display to launch the emulator in. If unspecified, display will not be set. Display values should start with : for example for display 1 use \':1\'.")
private Collection<String> mEmulatorArgs @Option(name = "emulator-arg", description = "Additional argument to launch the emulator with. Can be repeated.")
private String mEmulatorBinary @Option(name = "emulator-binary", description = "location of the emulator binary")
private String mEmulatorRamdiskImage @Option(name = "emulator-ramdisk-image", description = "ramdisk image will be loaded into emulator.")
private String mEmulatorSystemImage @Option(name = "emulator-system-image", description = "system image will be loaded into emulator.")
private boolean mForceKvm @Option(name = "force-kvm", description = "require kvm for emulator launch")
private boolean mGpu @Option(name = "gpu", description = "launch emulator with GPU on")
private Map<String, String> mHwOptions @Option(name = "hw-options", description = "pass key-value pairs of avd hardware options")
private int mLaunchAttempts @Option(name = "launch-attempts", description = "max number of attempts to launch emulator")
private long mMaxBootTime @Option(name = "boot-time", description = "the maximum time in minutes to wait for emulator to boot.")
private Map<String, String> mProps @Option(name = "prop", description = "pass key-value pairs of system props")
private String mSdcardSize @Option(name = "sdcard-size", description = "capacity of the SD card")
private String mTargetName @Option(name = "sdk-target", description = "the name of SDK target to launch. If unspecified, will use first target found")
private boolean mVerbose @Option(name = "verbose", description = "Use verbose for emulator output")
private boolean mWindow @Option(name = "window", description = "launch emulator with a graphical window display.")
Public Constructors
SdkAvdPreparer()
Creates a SdkAvdPreparer.
Public Methods
String createAvd(ISdkBuildInfo sdkBuildInfo)
Finds SDK target based on the ISdkBuildInfo, creates AVD for this target and returns its name.
void launchEmulatorForAvd(ISdkBuildInfo sdkBuild, ITestDevice device, String avd)
Launch an emulator for given avd, and wait for it to become available.
void setForceKvm(boolean forceKvm)
void setGpu(boolean gpu)
Sets programmatically whether the gpu should be on or off.
void setUp(ITestDevice device, IBuildInfo buildInfo)
Perform the target setup for testing.
void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
Perform the target cleanup/teardown after testing.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.targetprep.ITargetPreparer
From interface com.android.tradefed.targetprep.ITargetCleaner

Fields

private String mAbi

private String mAvdSkin

private String mAvdTag

private int mAvdTimeoutSeconds

private String mDevice

private String mDisplay

private Collection<String> mEmulatorArgs

private String mEmulatorBinary

private String mEmulatorRamdiskImage

private String mEmulatorSystemImage

private boolean mForceKvm

private boolean mGpu

private Map<String, String> mHwOptions

private int mLaunchAttempts

private long mMaxBootTime

private Map<String, String> mProps

private String mSdcardSize

private String mTargetName

private boolean mVerbose

private boolean mWindow

Public Constructors

public SdkAvdPreparer ()

Creates a SdkAvdPreparer.

Public Methods

public String createAvd (ISdkBuildInfo sdkBuildInfo)

Finds SDK target based on the ISdkBuildInfo, creates AVD for this target and returns its name.

Parameters
sdkBuildInfo the ISdkBuildInfo
Returns
  • the created AVD name
Throws
TargetSetupError if could not get targets
BuildError if failed to create the AVD

public void launchEmulatorForAvd (ISdkBuildInfo sdkBuild, ITestDevice device, String avd)

Launch an emulator for given avd, and wait for it to become available. Will launch the emulator on the port specified in the allocated ITestDevice

Parameters
sdkBuild the ISdkBuildInfo
device the placeholder ITestDevice representing allocated emulator device
avd the avd to launch
Throws
DeviceNotAvailableException
TargetSetupError if could not get targets
BuildError if emulator fails to boot
DeviceNotAvailableException

public void setForceKvm (boolean forceKvm)

public void setGpu (boolean gpu)

Sets programmatically whether the gpu should be on or off.

public void setUp (ITestDevice device, IBuildInfo buildInfo)

Perform the target setup for testing.

Parameters
device the ITestDevice to prepare.
buildInfo data about the build under test.

public void tearDown (ITestDevice device, IBuildInfo buildInfo, Throwable e)

Perform the target cleanup/teardown after testing.

Parameters
device the ITestDevice to prepare.
buildInfo data about the build under test.
e if the invocation ended with an exception, this will be the exception that was caught at the Invocation level. Otherwise, will be null.