ManagedDeviceList

class ManagedDeviceList
extends Object implements Iterable<IManagedTestDevice>

java.lang.Object
   ↳ com.android.tradefed.device.ManagedDeviceList


A thread-safe data structure that holds all devices known to DeviceManager.

Iteration is also thread-safe, but not consistent. A copy of the list is made at iterator creation time, and that copy is used as the iteration target. If queue is modified during iteration, a ConcurrentModificationException will not be thrown, but the iterator will also not reflect the modified contents.

Summary

Public constructors

ManagedDeviceList(IManagedTestDeviceFactory d)

Public methods

IManagedTestDevice allocate(IDeviceSelection options)

Attempt to allocate a device from the list

IManagedTestDevice find(String serialNumber)

Finds the device with the given serial

IManagedTestDevice findOrCreate(IDevice idevice)

Find the IManagedTestDevice corresponding to the IDevice.

IManagedTestDevice.DeviceEventResponse handleDeviceEvent(IManagedTestDevice d, DeviceEvent event)

Handle a device event for given device.

Iterator<IManagedTestDevice> iterator()

int size()

Return the number of elements in the list

void updateFastbootStates(Set<String> serials)

Update the getDeviceState() of devices as appropriate.

Public constructors

ManagedDeviceList

ManagedDeviceList (IManagedTestDeviceFactory d)

Parameters
d IManagedTestDeviceFactory

Public methods

allocate

IManagedTestDevice allocate (IDeviceSelection options)

Attempt to allocate a device from the list

Returns
IManagedTestDevice the IManagedTestDevice that was successfully allocated, null otherwise

find

IManagedTestDevice find (String serialNumber)

Finds the device with the given serial

Returns
IManagedTestDevice the IManagedTestDevice or null if not found

findOrCreate

IManagedTestDevice findOrCreate (IDevice idevice)

Find the IManagedTestDevice corresponding to the IDevice. If it does not exist, create a new one.

Returns
IManagedTestDevice the IManagedTestDevice.

handleDeviceEvent

IManagedTestDevice.DeviceEventResponse handleDeviceEvent (IManagedTestDevice d, 
                DeviceEvent event)

Handle a device event for given device. Will remove device from list if state transitions to unknown.

DeviceManager should always make calls through this method as opposed to calling handleAllocationEvent(DeviceEvent) directly, to ensure list stays valid.

Parameters
d IManagedTestDevice

event DeviceEvent

Returns
IManagedTestDevice.DeviceEventResponse

iterator

Iterator<IManagedTestDevice> iterator ()

Returns
Iterator<IManagedTestDevice>

size

int size ()

Return the number of elements in the list

Returns
int

updateFastbootStates

void updateFastbootStates (Set<String> serials)

Update the getDeviceState() of devices as appropriate.

Parameters
serials Set: the devices currently on fastboot