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 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")
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
boolean stubEmulatorRequested()
[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 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

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

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

public boolean deviceRequested ()

public boolean emulatorRequested ()

public Integer getBatteryLevel (IDevice device)

Retrieves the battery level for the given device

Parameters
device the IDevice
Returns
  • the device battery level or null if unknown

public String getDeviceProductType (IDevice device)

Gets the given devices product type

Parameters
device the IDevice
Returns
  • the device product type or null if unknown

public String getDeviceProductVariant (IDevice device)

Gets the given devices product variant

Parameters
device the IDevice
Returns
  • the device product variant or null if unknown

public Collection<String> getExcludeSerials ()

Gets a copy of the serial numbers exclusion list

Returns

public Integer getMaxBatteryLevel ()

Gets the requested maximum battery level

public Integer getMinBatteryLevel ()

Gets the requested minimum battery level

public Collection<String> getProductTypes ()

Gets a copy of the product type list

Returns

public Map<String, String> getProperties ()

Returns a map of the property list

Returns
  • a Map of device property names to values

public boolean getRequireBatteryCheck ()

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

public Collection<String> getSerials ()

Gets a copy of the serial numbers

Returns

public boolean matches (IDevice device)

Returns
  • true if the given IDevice is a match for the provided options. false otherwise

public boolean nullDeviceRequested ()

public void setDeviceRequested (boolean deviceRequested)

Sets the emulator requested flag

public void setEmulatorRequested (boolean emulatorRequested)

Sets the emulator requested flag

public void setMaxBatteryLevel (Integer maxBattery)

Sets the maximum battery level

public void setMinBatteryLevel (Integer minBattery)

Sets the minimum battery level

public void setNullDeviceRequested (boolean nullDeviceRequested)

Sets the null device requested flag

public void setRequireBatteryCheck (boolean requireCheck)

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

public void setSerial (String... serialNumber)

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

public void setStubEmulatorRequested (boolean stubEmulatorRequested)

Sets the stub emulator requested flag

public boolean stubEmulatorRequested ()