Package com.android.sdklib.devices
Class DeviceManager
- java.lang.Object
-
- com.android.sdklib.devices.DeviceManager
-
public class DeviceManager extends java.lang.ObjectManager class for interacting withDevices within the SDK
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeviceManager.DeviceFilterstatic interfaceDeviceManager.DevicesChangedListenerInterface implemented by objects which want to know when changes occur to theDevicelists.static classDeviceManager.DeviceStatus
-
Field Summary
Fields Modifier and Type Field Description static java.util.EnumSet<DeviceManager.DeviceFilter>ALL_DEVICESgetDevices() flag to list all devices.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUserDevice(Device d)static DeviceManagercreateInstance(com.android.prefs.AndroidLocationsProvider androidLocationsProvider, java.nio.file.Path sdkLocation, com.android.utils.ILogger log)Creates a new instance ofDeviceManager, using the user's android folder.static DeviceManagercreateInstance(AndroidSdkHandler sdkHandler, com.android.utils.ILogger log)DevicegetDevice(java.lang.String id, java.lang.String manufacturer)java.util.Collection<Device>getDevices(DeviceManager.DeviceFilter deviceFilter)Returns the knownDevicelist.java.util.Collection<Device>getDevices(java.util.EnumSet<DeviceManager.DeviceFilter> deviceFilter)Returns the knownDevicelist.DeviceManager.DeviceStatusgetDeviceStatus(java.lang.String name, java.lang.String manufacturer)static java.util.Map<java.lang.String,java.lang.String>getHardwareProperties(Device d)Returns the hardware properties defined inAvdManager.HARDWARE_INIas aMap.static java.util.Map<java.lang.String,java.lang.String>getHardwareProperties(State s)Returns hardware properties (defined in hardware.ini) as aMap.static java.lang.StringhasHardwarePropHashChanged(Device d, java.lang.String hashV2)Checks whether the the hardware props have changed.voidregisterListener(DeviceManager.DevicesChangedListener listener)Register a listener to be notified when the device lists are modified.voidremoveUserDevice(Device d)voidreplaceUserDevice(Device d)voidsaveUserDevices()Saves out the user devices toSdkConstants.FN_DEVICES_XMLin the Android folder.booleanunregisterListener(DeviceManager.DevicesChangedListener listener)Removes a listener from the notification list such that it will no longer receive notifications when modifications to theDevicelist occur.
-
-
-
Field Detail
-
ALL_DEVICES
public static final java.util.EnumSet<DeviceManager.DeviceFilter> ALL_DEVICES
getDevices() flag to list all devices.
-
-
Method Detail
-
createInstance
public static DeviceManager createInstance(@NonNull com.android.prefs.AndroidLocationsProvider androidLocationsProvider, @Nullable java.nio.file.Path sdkLocation, @NonNull com.android.utils.ILogger log)
Creates a new instance ofDeviceManager, using the user's android folder.
-
createInstance
public static DeviceManager createInstance(@NonNull AndroidSdkHandler sdkHandler, @NonNull com.android.utils.ILogger log)
-
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 theDevicelist occur.- Parameters:
listener- The listener to remove.
-
getDeviceStatus
@NonNull public DeviceManager.DeviceStatus getDeviceStatus(@NonNull java.lang.String name, @NonNull java.lang.String manufacturer)
-
getDevice
@Nullable public Device getDevice(@NonNull java.lang.String id, @NonNull java.lang.String manufacturer)
-
getDevices
@NonNull public java.util.Collection<Device> getDevices(@NonNull DeviceManager.DeviceFilter deviceFilter)
Returns the knownDevicelist.- Parameters:
deviceFilter- One of theDeviceManager.DeviceFilterconstants.- Returns:
- A copy of the list of
Devices. Can be empty but not null.
-
getDevices
@NonNull public java.util.Collection<Device> getDevices(@NonNull java.util.EnumSet<DeviceManager.DeviceFilter> deviceFilter)
Returns the knownDevicelist.- Parameters:
deviceFilter- A combination of theDeviceManager.DeviceFilterconstants or the constantALL_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 toSdkConstants.FN_DEVICES_XMLin the Android folder.
-
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 aMap.- Parameters:
s- TheStatefrom which to derive the hardware properties.- Returns:
- A
Mapof hardware properties.
-
getHardwareProperties
@NonNull public static java.util.Map<java.lang.String,java.lang.String> getHardwareProperties(@NonNull Device d)Returns the hardware properties defined inAvdManager.HARDWARE_INIas aMap. This is intended to be dumped in the config.ini and already contains the device name, manufacturer and device hash.- Parameters:
d- TheDevicefrom which to derive the hardware properties.- Returns:
- A
Mapof hardware properties.
-
hasHardwarePropHashChanged
@Nullable public static java.lang.String hasHardwarePropHashChanged(@NonNull Device d, @NonNull java.lang.String hashV2)Checks whether the the hardware props have changed. If the hash is the same, returns null for success. If the hash is not the same or there's not enough information to indicate it's the same (e.g. if in the future we change the digest method), simply return the new hash, indicating it would be best to update it.- Parameters:
d- The device.hashV2- The previous saved AvdManager.AVD_INI_DEVICE_HASH_V2 property.- Returns:
- Null if the same, otherwise returns the new and different hash.
-
-