TestDevice.MicrodroidBuilder

public static class TestDevice.MicrodroidBuilder
extends Object

java.lang.Object
   ↳ com.android.tradefed.device.TestDevice.MicrodroidBuilder


A builder used to create a Microdroid TestDevice.

Summary

Public methods

TestDevice.MicrodroidBuilder addAssignableDevice(String sysfsNode)

Adds a device to assign to microdroid.

TestDevice.MicrodroidBuilder addBootFile(File localFile, String remoteFileName)

Adds a file for booting to be pushed to ERROR(/#TEST_ROOT).

TestDevice.MicrodroidBuilder addExtraIdsigPath(String extraIdsigPath)

Adds extra idsig file to the list.

TestDevice.MicrodroidBuilder addTestDeviceOption(String optionName, String valueText)

Sets a TestDeviceOptions for the microdroid TestDevice.

ITestDevice build(TestDevice device)

Starts a Micrdroid TestDevice on the given TestDevice.

TestDevice.MicrodroidBuilder cpuAffinity(String affinity)

Sets on which host CPUs the vCPUs can run.

TestDevice.MicrodroidBuilder cpuTopology(String cpuTopology)

Sets the CPU topology configuration.

TestDevice.MicrodroidBuilder debugLevel(String debugLevel)

Sets the debug level.

static TestDevice.MicrodroidBuilder fromDevicePath(String apkPath, String configPath)

Creates a Microdroid builder for the given apkPath and the payload config file in APK.

static TestDevice.MicrodroidBuilder fromFile(File apkFile, String configPath)

Creates a Microdroid builder for the given APK and the payload config file in APK.

TestDevice.MicrodroidBuilder gki(String version)

Uses GKI kernel instead of microdroid kernel

TestDevice.MicrodroidBuilder memoryMib(int memoryMib)

Sets the amount of RAM to give the VM.

TestDevice.MicrodroidBuilder numCpus(int num)

Sets the number of vCPUs in the VM.

TestDevice.MicrodroidBuilder protectedVm(boolean isProtectedVm)

Sets whether the VM will be protected or not.

TestDevice.MicrodroidBuilder setAdbConnectTimeoutMs(long timeoutMs)

Sets the timeout for adb connect to microdroid TestDevice in millis.

Public methods

addAssignableDevice

public TestDevice.MicrodroidBuilder addAssignableDevice (String sysfsNode)

Adds a device to assign to microdroid.

Parameters
sysfsNode String: The path to the sysfs node to assign

Returns
TestDevice.MicrodroidBuilder the microdroid builder.

addBootFile

public TestDevice.MicrodroidBuilder addBootFile (File localFile, 
                String remoteFileName)

Adds a file for booting to be pushed to ERROR(/#TEST_ROOT).

Use this method if an file is required for booting microdroid. Otherwise use NativeDevice.pushFile(File, String).

Parameters
localFile File: The local file on the host

remoteFileName String: The remote file name on the device

Returns
TestDevice.MicrodroidBuilder the microdroid builder.

addExtraIdsigPath

public TestDevice.MicrodroidBuilder addExtraIdsigPath (String extraIdsigPath)

Adds extra idsig file to the list.

Parameters
extraIdsigPath String

Returns
TestDevice.MicrodroidBuilder

addTestDeviceOption

public TestDevice.MicrodroidBuilder addTestDeviceOption (String optionName, 
                String valueText)

Sets a TestDeviceOptions for the microdroid TestDevice.

Parameters
optionName String: The name of the TestDeviceOption to set

valueText String: The value

Returns
TestDevice.MicrodroidBuilder the microdroid builder.

build

public ITestDevice build (TestDevice device)

Starts a Micrdroid TestDevice on the given TestDevice.

Parameters
device TestDevice

Returns
ITestDevice

Throws
DeviceNotAvailableException

cpuAffinity

public TestDevice.MicrodroidBuilder cpuAffinity (String affinity)

Sets on which host CPUs the vCPUs can run. The format is a comma-separated list of CPUs or CPU ranges to run vCPUs on. e.g. "0,1-3,5" to choose host CPUs 0, 1, 2, 3, and 5. Or this can be a colon-separated list of assignments of vCPU to host CPU assignments. e.g. "0=0:1=1:2=2" to map vCPU 0 to host CPU 0, and so on.

Only supported in Android T.

Parameters
affinity String

Returns
TestDevice.MicrodroidBuilder

cpuTopology

public TestDevice.MicrodroidBuilder cpuTopology (String cpuTopology)

Sets the CPU topology configuration. Supported values: "one_cpu" and "match_host".

Parameters
cpuTopology String

Returns
TestDevice.MicrodroidBuilder

debugLevel

public TestDevice.MicrodroidBuilder debugLevel (String debugLevel)

Sets the debug level.

Supported values: "none" and "full". Android T also supports "app_only".

Parameters
debugLevel String

Returns
TestDevice.MicrodroidBuilder

fromDevicePath

public static TestDevice.MicrodroidBuilder fromDevicePath (String apkPath, 
                String configPath)

Creates a Microdroid builder for the given apkPath and the payload config file in APK.

Parameters
apkPath String

configPath String

Returns
TestDevice.MicrodroidBuilder

fromFile

public static TestDevice.MicrodroidBuilder fromFile (File apkFile, 
                String configPath)

Creates a Microdroid builder for the given APK and the payload config file in APK.

Parameters
apkFile File

configPath String

Returns
TestDevice.MicrodroidBuilder

gki

public TestDevice.MicrodroidBuilder gki (String version)

Uses GKI kernel instead of microdroid kernel

Parameters
version String: The GKI version to use

Returns
TestDevice.MicrodroidBuilder

memoryMib

public TestDevice.MicrodroidBuilder memoryMib (int memoryMib)

Sets the amount of RAM to give the VM. If this is zero or negative then the default will be used.

Parameters
memoryMib int

Returns
TestDevice.MicrodroidBuilder

numCpus

public TestDevice.MicrodroidBuilder numCpus (int num)

Sets the number of vCPUs in the VM. Defaults to 1.

Only supported in Android T.

Parameters
num int

Returns
TestDevice.MicrodroidBuilder

protectedVm

public TestDevice.MicrodroidBuilder protectedVm (boolean isProtectedVm)

Sets whether the VM will be protected or not.

Parameters
isProtectedVm boolean

Returns
TestDevice.MicrodroidBuilder

setAdbConnectTimeoutMs

public TestDevice.MicrodroidBuilder setAdbConnectTimeoutMs (long timeoutMs)

Sets the timeout for adb connect to microdroid TestDevice in millis.

Parameters
timeoutMs long: The timeout in millis

Returns
TestDevice.MicrodroidBuilder