com.android.sdklib.devices
Class DeviceManager

java.lang.Object
  extended by com.android.sdklib.devices.DeviceManager

public class DeviceManager
extends java.lang.Object

Manager class for interacting with Devices within the SDK


Nested Class Summary
static interface DeviceManager.DevicesChangedListener
          Interface implemented by objects which want to know when changes occur to the Device lists.
static class DeviceManager.DeviceStatus
           
 
Field Summary
static int ALL_DEVICES
          getDevices() flag to list all devices.
static int DEFAULT_DEVICES
          getDevices() flag to list default devices.
static int USER_DEVICES
          getDevices() flag to list user devices.
static int VENDOR_DEVICES
          getDevices() flag to list vendor devices.
 
Method Summary
 void addUserDevice(Device d)
           
static DeviceManager createInstance(java.lang.String osSdkPath, com.android.utils.ILogger log)
          Creates a new instance of DeviceManager.
 Device getDevice(java.lang.String id, java.lang.String manufacturer)
           
 java.util.List<Device> getDevices(int deviceFilter)
          Returns the known Device list.
 DeviceManager.DeviceStatus getDeviceStatus(java.lang.String name, java.lang.String manufacturer, int hashCode)
           
static java.util.Map<java.lang.String,java.lang.String> getHardwareProperties(Device d)
          Returns the hardware properties defined in AvdManager.HARDWARE_INI as a Map.
static java.util.Map<java.lang.String,java.lang.String> getHardwareProperties(State s)
          Returns hardware properties (defined in hardware.ini) as a Map.
 void registerListener(DeviceManager.DevicesChangedListener listener)
          Register a listener to be notified when the device lists are modified.
 void removeUserDevice(Device d)
           
 void replaceUserDevice(Device d)
           
 void saveUserDevices()
          Saves out the user devices to SdkConstants.FN_DEVICES_XML in AndroidLocation.getFolder().
 boolean unregisterListener(DeviceManager.DevicesChangedListener listener)
          Removes a listener from the notification list such that it will no longer receive notifications when modifications to the Device list occur.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_DEVICES

public static final int USER_DEVICES
getDevices() flag to list user devices.

See Also:
Constant Field Values

DEFAULT_DEVICES

public static final int DEFAULT_DEVICES
getDevices() flag to list default devices.

See Also:
Constant Field Values

VENDOR_DEVICES

public static final int VENDOR_DEVICES
getDevices() flag to list vendor devices.

See Also:
Constant Field Values

ALL_DEVICES

public static final int ALL_DEVICES
getDevices() flag to list all devices.

See Also:
Constant Field Values
Method Detail

createInstance

public static DeviceManager createInstance(@Nullable
                                           java.lang.String osSdkPath,
                                           @NonNull
                                           com.android.utils.ILogger log)
Creates a new instance of DeviceManager.

Parameters:
osSdkPath - Path to the current SDK. If null or invalid, vendor devices are ignored.
log - SDK logger instance. Should be non-null.

registerListener

public void registerListener(@NonNull
                             DeviceManager.DevicesChangedListener listener)
Register a listener to be notified when the device lists are modified.

Parameters:
listener - The listener to add. Ignored if already registered.

unregisterListener

public boolean unregisterListener(@NonNull
                                  DeviceManager.DevicesChangedListener listener)
Removes a listener from the notification list such that it will no longer receive notifications when modifications to the Device list occur.

Parameters:
listener - The listener to remove.

getDeviceStatus

@NonNull
public DeviceManager.DeviceStatus getDeviceStatus(@NonNull
                                                          java.lang.String name,
                                                          @NonNull
                                                          java.lang.String manufacturer,
                                                          int hashCode)

getDevice

@Nullable
public Device getDevice(@NonNull
                                 java.lang.String id,
                                 @NonNull
                                 java.lang.String manufacturer)

getDevices

@NonNull
public java.util.List<Device> getDevices(int deviceFilter)
Returns the known Device list.

Parameters:
deviceFilter - A combination of USER_DEVICES, VENDOR_DEVICES and DEFAULT_DEVICES or the constant ALL_DEVICES.
Returns:
A copy of the list of Devices. Can be empty but not null.

addUserDevice

public void addUserDevice(@NonNull
                          Device d)

removeUserDevice

public void removeUserDevice(@NonNull
                             Device d)

replaceUserDevice

public void replaceUserDevice(@NonNull
                              Device d)

saveUserDevices

public void saveUserDevices()
Saves out the user devices to SdkConstants.FN_DEVICES_XML in AndroidLocation.getFolder().


getHardwareProperties

@NonNull
public static java.util.Map<java.lang.String,java.lang.String> getHardwareProperties(@NonNull
                                                                                             State s)
Returns hardware properties (defined in hardware.ini) as a Map.

Parameters:
s - The State from which to derive the hardware properties.
Returns:
A Map of hardware properties.

getHardwareProperties

@NonNull
public static java.util.Map<java.lang.String,java.lang.String> getHardwareProperties(@NonNull
                                                                                             Device d)
Returns the hardware properties defined in AvdManager.HARDWARE_INI as a Map.

Parameters:
d - The Device from which to derive the hardware properties.
Returns:
A Map of hardware properties.