to top
public class

DeviceSelectionOptions

extends Object
implements IDeviceSelection
java.lang.Object
   ↳ com.android.tradefed.device.DeviceSelectionOptions

Class Overview

Container for for device selection criteria.

Summary

Constants
String DEVICE_PRODUCT_PROPERTY
String DEVICE_SDK_PROPERTY
String DEVICE_VARIANT_PROPERTY
Fields
private boolean mDeviceRequested @Option(name = "device", shortName = 100, description = "force this test to run on a physical device, not an emulator.")
private boolean mEmulatorRequested @Option(name = "emulator", shortName = 101, description = "force this test to run on emulator.")
private Collection<String> mExcludeSerials @Option(name = "exclude-serial", description = "run this test on any device except those with this serial number(s).")
private Integer mMaxBattery @Option(name = "max-battery", description = "only run this test on a device whose battery level is strictly less than the given amount. Scale: 0-100")
private Integer mMaxSdk @Option(name = "max-sdk-level", description = "Only run this test on devices that are running this or lower Android SDK/API level")
private Integer mMinBattery @Option(name = "min-battery", description = "only run this test on a device whose battery level is at least the given amount. Scale: 0-100")
private Integer mMinSdk @Option(name = "min-sdk-level", description = "Only run this test on devices that support this Android SDK/API level")
private boolean mNullDeviceRequested @Option(name = "null-device", shortName = 110, description = "do not allocate a device for this test.")
private Collection<String> mProductTypes @Option(name = "product-type", description = "run this test on device with this product type(s). May also filter by variant using product:variant.")
private Map<String, String> mPropertyMap @Option(name = "property", description = "run this test on device with this property value. Expected format --property .")
private boolean mRequireBatteryCheck @Option(name = "require-battery-check", description = "_If_ --min-battery and/or --max-battery is specified, skip devices that have an unknown battery level. Note that this may leave restart-looping devices in limbo indefinitely without manual intervention.")
private Collection<String> mSerials @Option(name = "serial", shortName = 115, description = "run this test on a specific device with given serial number(s).")
private boolean mStubEmulatorRequested @Option(name = "new-emulator", description = "allocate a placeholder emulator. Should be used when config intends to launch an emulator")
private boolean mTcpDeviceRequested @Option(name = "tcp-device", description = "start a placeholder for a tcp device that will be connected later.")
Public Constructors
DeviceSelectionOptions()
Public Methods
void addExcludeSerial(String serialNumber)
Add a serial number to exclusion list.
void addProductType(String productType)
Add a product type to the device selection options.
void addProperty(String propertyKey, String propValue)
Add a property criteria to the device selection options
void addSerial(String serialNumber)
Add a serial number to the device selection options.
static IDeviceSelection createForSerial(String serial)
Helper factory method to create a IDeviceSelection that will only match device with given serial
boolean deviceRequested()
boolean emulatorRequested()
Integer getBatteryLevel(IDevice device)
Retrieves the battery level for the given device
String getDeviceProductType(IDevice device)
Gets the given devices product type
String getDeviceProductVariant(IDevice device)
Gets the given devices product variant
Collection<String> getExcludeSerials()
Gets a copy of the serial numbers exclusion list
Integer getMaxBatteryLevel()
Gets the requested maximum battery level
Integer getMinBatteryLevel()
Gets the requested minimum battery level
Collection<String> getProductTypes()
Gets a copy of the product type list
Map<String, String> getProperties()
Returns a map of the property list
boolean getRequireBatteryCheck()
Gets whether battery check is required for devices with unknown battery level
Collection<String> getSerials()
Gets a copy of the serial numbers
boolean matches(IDevice device)
boolean nullDeviceRequested()
void setDeviceRequested(boolean deviceRequested)
Sets the emulator requested flag
void setEmulatorRequested(boolean emulatorRequested)
Sets the emulator requested flag
void setMaxBatteryLevel(Integer maxBattery)
Sets the maximum battery level
void setMinBatteryLevel(Integer minBattery)
Sets the minimum battery level
void setNullDeviceRequested(boolean nullDeviceRequested)
Sets the null device requested flag
void setRequireBatteryCheck(boolean requireCheck)
Sets whether battery check is required for devices with unknown battery level
void setSerial(String... serialNumber)
Set the serial numbers inclusion list, replacing any existing values.
void setStubEmulatorRequested(boolean stubEmulatorRequested)
Sets the stub emulator requested flag
void setTcpDeviceRequested(boolean tcpDeviceRequested)
Sets the tcp device requested flag
boolean stubEmulatorRequested()
boolean tcpDeviceRequested()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.device.IDeviceSelection
From interface com.android.tradefed.util.ConditionPriorityBlockingQueue.IMatcher

Constants

public static final String DEVICE_PRODUCT_PROPERTY

Constant Value: "ro.hardware"

public static final String DEVICE_SDK_PROPERTY

Constant Value: "ro.build.version.sdk"

public static final String DEVICE_VARIANT_PROPERTY

Constant Value: "ro.product.device"

Fields

private boolean mDeviceRequested

private boolean mEmulatorRequested

private Collection<String> mExcludeSerials

private Integer mMaxBattery

private Integer mMaxSdk

private Integer mMinBattery

private Integer mMinSdk

private boolean mNullDeviceRequested

private Collection<String> mProductTypes

private Map<String, String> mPropertyMap

private boolean mRequireBatteryCheck

private Collection<String> mSerials

private boolean mStubEmulatorRequested

private boolean mTcpDeviceRequested

Public Constructors

public DeviceSelectionOptions ()

Public Methods

public void addExcludeSerial (String serialNumber)

Add a serial number to exclusion list.

public void addProductType (String productType)

Add a product type to the device selection options.

public void addProperty (String propertyKey, String propValue)

Add a property criteria to the device selection options

Parameters
propertyKey String
propValue String

public void addSerial (String serialNumber)

Add a serial number to the device selection options.

public static IDeviceSelection createForSerial (String serial)

Helper factory method to create a IDeviceSelection that will only match device with given serial

Parameters
serial String
Returns
IDeviceSelection

public boolean deviceRequested ()

Returns
boolean

public boolean emulatorRequested ()

Returns
boolean

public Integer getBatteryLevel (IDevice device)

Retrieves the battery level for the given device

Parameters
device IDevice: the IDevice
Returns
Integer the device battery level or null if unknown

public String getDeviceProductType (IDevice device)

Gets the given devices product type

Parameters
device IDevice: the IDevice
Returns
String the device product type or null if unknown

public String getDeviceProductVariant (IDevice device)

Gets the given devices product variant

Parameters
device IDevice: the IDevice
Returns
String the device product variant or null if unknown

public Collection<String> getExcludeSerials ()

Gets a copy of the serial numbers exclusion list

Returns
Collection<String> a Collection of serial numbers

public Integer getMaxBatteryLevel ()

Gets the requested maximum battery level

Returns
Integer

public Integer getMinBatteryLevel ()

Gets the requested minimum battery level

Returns
Integer

public Collection<String> getProductTypes ()

Gets a copy of the product type list

Returns
Collection<String> a Collection of product types

public Map<String, String> getProperties ()

Returns a map of the property list

Returns
Map<String, String> a Map of device property names to values

public boolean getRequireBatteryCheck ()

Gets whether battery check is required for devices with unknown battery level

Returns
boolean

public Collection<String> getSerials ()

Gets a copy of the serial numbers

Returns
Collection<String> a Collection of serial numbers

public boolean matches (IDevice device)

Parameters
device IDevice
Returns
boolean true if the given IDevice is a match for the provided options. false otherwise

public boolean nullDeviceRequested ()

Returns
boolean

public void setDeviceRequested (boolean deviceRequested)

Sets the emulator requested flag

Parameters
deviceRequested boolean

public void setEmulatorRequested (boolean emulatorRequested)

Sets the emulator requested flag

Parameters
emulatorRequested boolean

public void setMaxBatteryLevel (Integer maxBattery)

Sets the maximum battery level

Parameters
maxBattery Integer

public void setMinBatteryLevel (Integer minBattery)

Sets the minimum battery level

Parameters
minBattery Integer

public void setNullDeviceRequested (boolean nullDeviceRequested)

Sets the null device requested flag

Parameters
nullDeviceRequested boolean

public void setRequireBatteryCheck (boolean requireCheck)

Sets whether battery check is required for devices with unknown battery level

Parameters
requireCheck boolean

public void setSerial (String... serialNumber)

Set the serial numbers inclusion list, replacing any existing values.

Parameters
serialNumber String

public void setStubEmulatorRequested (boolean stubEmulatorRequested)

Sets the stub emulator requested flag

Parameters
stubEmulatorRequested boolean

public void setTcpDeviceRequested (boolean tcpDeviceRequested)

Sets the tcp device requested flag

Parameters
tcpDeviceRequested boolean

public boolean stubEmulatorRequested ()

Returns
boolean

public boolean tcpDeviceRequested ()

Returns
boolean