aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdklib
diff options
context:
space:
mode:
Diffstat (limited to 'sdkmanager/libs/sdklib')
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/devices/DeviceManager.java258
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java76
2 files changed, 192 insertions, 142 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/devices/DeviceManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/devices/DeviceManager.java
index 37b6876..c17a4df 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/devices/DeviceManager.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/devices/DeviceManager.java
@@ -17,6 +17,7 @@
package com.android.sdklib.devices;
import com.android.SdkConstants;
+import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.prefs.AndroidLocation;
import com.android.prefs.AndroidLocation.AndroidLocationException;
@@ -56,20 +57,26 @@ import javax.xml.transform.TransformerFactoryConfigurationError;
*/
public class DeviceManager {
- private final static String sDeviceProfilesProp = "DeviceProfiles";
- private final static Pattern sPathPropertyPattern = Pattern.compile("^" + PkgProps.EXTRA_PATH
- + "=" + sDeviceProfilesProp + "$");
+ private static final String DEVICE_PROFILES_PROP = "DeviceProfiles";
+ private static final Pattern PATH_PROPERTY_PATTERN =
+ Pattern.compile("^" + PkgProps.EXTRA_PATH + "=" + DEVICE_PROFILES_PROP + "$");
private ILogger mLog;
- // Vendor devices can't be a static list since they change based on the SDK
- // Location
private List<Device> mVendorDevices;
- // Keeps track of where the currently loaded vendor devices were loaded from
- private String mVendorDevicesLocation = "";
- private static List<Device> mUserDevices;
- private static List<Device> mDefaultDevices;
- private static final Object sLock = new Object();
- private static final List<DevicesChangeListener> sListeners =
- new ArrayList<DevicesChangeListener>();
+ private List<Device> mUserDevices;
+ private List<Device> mDefaultDevices;
+ private final Object mLock = new Object();
+ private final List<DevicesChangedListener> sListeners =
+ new ArrayList<DevicesChangedListener>();
+ private final String mOsSdkPath;
+
+ /** getDevices() flag to list user devices. */
+ public static final int USER_DEVICES = 1;
+ /** getDevices() flag to list default devices. */
+ public static final int DEFAULT_DEVICES = 2;
+ /** getDevices() flag to list vendor devices. */
+ public static final int VENDOR_DEVICES = 4;
+ /** getDevices() flag to list all devices. */
+ public static final int ALL_DEVICES = USER_DEVICES | DEFAULT_DEVICES | VENDOR_DEVICES;
public static enum DeviceStatus {
/**
@@ -86,10 +93,26 @@ public class DeviceManager {
MISSING;
}
- // TODO: Refactor this to look more like AvdManager so that we don't have
- // multiple instances in the same application, which forces us to parse
- // the XML multiple times when we don't have to.
- public DeviceManager(ILogger log) {
+ /**
+ * Creates a new instance of DeviceManager.
+ *
+ * @param osSdkPath Path to the current SDK. If null or invalid, vendor devices are ignored.
+ * @param log SDK logger instance. Should be non-null.
+ */
+ public static DeviceManager createInstance(@Nullable String osSdkPath, @NonNull ILogger log) {
+ // TODO consider using a cache and reusing the same instance of the device manager
+ // for the same manager/log combo.
+ return new DeviceManager(osSdkPath, log);
+ }
+
+ /**
+ * Creates a new instance of DeviceManager.
+ *
+ * @param osSdkPath Path to the current SDK. If null or invalid, vendor devices are ignored.
+ * @param log SDK logger instance. Should be non-null.
+ */
+ private DeviceManager(@Nullable String osSdkPath, @NonNull ILogger log) {
+ mOsSdkPath = osSdkPath;
mLog = log;
}
@@ -97,11 +120,11 @@ public class DeviceManager {
* Interface implemented by objects which want to know when changes occur to the {@link Device}
* lists.
*/
- public static interface DevicesChangeListener {
+ public static interface DevicesChangedListener {
/**
* Called after one of the {@link Device} lists has been updated.
*/
- public void onDevicesChange();
+ public void onDevicesChanged();
}
/**
@@ -109,7 +132,7 @@ public class DeviceManager {
*
* @param listener The listener to add. Ignored if already registered.
*/
- public void registerListener(DevicesChangeListener listener) {
+ public void registerListener(DevicesChangedListener listener) {
if (listener != null) {
synchronized (sListeners) {
if (!sListeners.contains(listener)) {
@@ -125,15 +148,14 @@ public class DeviceManager {
*
* @param listener The listener to remove.
*/
- public boolean unregisterListener(DevicesChangeListener listener) {
+ public boolean unregisterListener(DevicesChangedListener listener) {
synchronized (sListeners) {
return sListeners.remove(listener);
}
}
- public DeviceStatus getDeviceStatus(
- @Nullable String sdkLocation, String name, String manufacturer, int hashCode) {
- Device d = getDevice(sdkLocation, name, manufacturer);
+ public DeviceStatus getDeviceStatus(String name, String manufacturer, int hashCode) {
+ Device d = getDevice(name, manufacturer);
if (d == null) {
return DeviceStatus.MISSING;
} else {
@@ -141,46 +163,64 @@ public class DeviceManager {
}
}
- public Device getDevice(@Nullable String sdkLocation, String name, String manufacturer) {
- List<Device> devices;
- if (sdkLocation != null) {
- devices = getDevices(sdkLocation);
- } else {
- devices = new ArrayList<Device>(getDefaultDevices());
- devices.addAll(getUserDevices());
- }
- for (Device d : devices) {
- if (d.getName().equals(name) && d.getManufacturer().equals(manufacturer)) {
- return d;
+ public Device getDevice(String name, String manufacturer) {
+ initDevicesLists();
+ for (List<?> devices :
+ new List<?>[] { mUserDevices, mDefaultDevices, mVendorDevices } ) {
+ if (devices != null) {
+ @SuppressWarnings("unchecked") List<Device> devicesList = (List<Device>) devices;
+ for (Device d : devicesList) {
+ if (d.getName().equals(name) && d.getManufacturer().equals(manufacturer)) {
+ return d;
+ }
+ }
}
}
return null;
}
/**
- * Returns both vendor provided and user created {@link Device}s.
+ * Returns the known {@link Device} list.
*
- * @param sdkLocation Location of the Android SDK
- * @return A list of both vendor and user provided {@link Device}s
+ * @param deviceFilter A combination of USER_DEVICES, VENDOR_DEVICES and DEFAULT_DEVICES
+ * or the constant ALL_DEVICES.
+ * @return A copy of the list of {@link Device}s. Can be empty but not null.
*/
- public List<Device> getDevices(String sdkLocation) {
- List<Device> devices = new ArrayList<Device>(getVendorDevices(sdkLocation));
- devices.addAll(getDefaultDevices());
- devices.addAll(getUserDevices());
+ public List<Device> getDevices(int deviceFilter) {
+ initDevicesLists();
+ List<Device> devices = new ArrayList<Device>();
+ if (mUserDevices != null && (deviceFilter & USER_DEVICES) != 0) {
+ devices.addAll(mUserDevices);
+ }
+ if (mDefaultDevices != null && (deviceFilter & DEFAULT_DEVICES) != 0) {
+ devices.addAll(mDefaultDevices);
+ }
+ if (mVendorDevices != null && (deviceFilter & VENDOR_DEVICES) != 0) {
+ devices.addAll(mVendorDevices);
+ }
return Collections.unmodifiableList(devices);
}
+ private void initDevicesLists() {
+ boolean changed = initDefaultDevices();
+ changed |= initVendorDevices();
+ changed |= initUserDevices();
+ if (changed) {
+ notifyListeners();
+ }
+ }
+
/**
- * Gets the {@link List} of {@link Device}s packaged with the SDK.
- *
- * @return The {@link List} of default {@link Device}s
+ * Initializes the {@link Device}s packaged with the SDK.
+ * @return True if the list has changed.
*/
- public List<Device> getDefaultDevices() {
- synchronized (sLock) {
+ private boolean initDefaultDevices() {
+ synchronized (mLock) {
if (mDefaultDevices == null) {
try {
mDefaultDevices = DeviceParser.parse(
DeviceManager.class.getResourceAsStream(SdkConstants.FN_DEVICES_XML));
+ return true;
} catch (IllegalStateException e) {
// The device builders can throw IllegalStateExceptions if
// build gets called before everything is properly setup
@@ -190,65 +230,64 @@ public class DeviceManager {
mLog.error(null, "Error reading default devices");
mDefaultDevices = new ArrayList<Device>();
}
- notifyListeners();
}
}
- return Collections.unmodifiableList(mDefaultDevices);
+ return false;
}
/**
- * Returns all vendor-provided {@link Device}s
- *
- * @param sdkLocation Location of the Android SDK
- * @return A list of vendor-provided {@link Device}s
+ * Initializes all vendor-provided {@link Device}s.
+ * @return True if the list has changed.
*/
- public List<Device> getVendorDevices(String sdkLocation) {
- synchronized (sLock) {
- if (mVendorDevices == null || !mVendorDevicesLocation.equals(sdkLocation)) {
- mVendorDevicesLocation = sdkLocation;
- List<Device> devices = new ArrayList<Device>();
-
- // Load devices from tools folder
- File toolsDevices = new File(sdkLocation, SdkConstants.OS_SDK_TOOLS_LIB_FOLDER +
- File.separator + SdkConstants.FN_DEVICES_XML);
- if (toolsDevices.isFile()) {
- devices.addAll(loadDevices(toolsDevices));
- }
+ private boolean initVendorDevices() {
+ synchronized (mLock) {
+ if (mVendorDevices == null) {
+ mVendorDevices = new ArrayList<Device>();
+
+ if (mOsSdkPath != null) {
+ // Load devices from tools folder
+ File toolsDevices = new File(mOsSdkPath,
+ SdkConstants.OS_SDK_TOOLS_LIB_FOLDER +
+ File.separator +
+ SdkConstants.FN_DEVICES_XML);
+ if (toolsDevices.isFile()) {
+ mVendorDevices.addAll(loadDevices(toolsDevices));
+ }
- // Load devices from vendor extras
- File extrasFolder = new File(sdkLocation, SdkConstants.FD_EXTRAS);
- List<File> deviceDirs = getExtraDirs(extrasFolder);
- for (File deviceDir : deviceDirs) {
- File deviceXml = new File(deviceDir, SdkConstants.FN_DEVICES_XML);
- if (deviceXml.isFile()) {
- devices.addAll(loadDevices(deviceXml));
+ // Load devices from vendor extras
+ File extrasFolder = new File(mOsSdkPath, SdkConstants.FD_EXTRAS);
+ List<File> deviceDirs = getExtraDirs(extrasFolder);
+ for (File deviceDir : deviceDirs) {
+ File deviceXml = new File(deviceDir, SdkConstants.FN_DEVICES_XML);
+ if (deviceXml.isFile()) {
+ mVendorDevices.addAll(loadDevices(deviceXml));
+ }
}
+ return true;
}
- mVendorDevices = devices;
- notifyListeners();
}
}
- return Collections.unmodifiableList(mVendorDevices);
+ return false;
}
/**
- * Returns all user-created {@link Device}s
- *
- * @return All user-created {@link Device}s
+ * Initializes all user-created {@link Device}s
+ * @return True if the list has changed.
*/
- public List<Device> getUserDevices() {
- synchronized (sLock) {
+ private boolean initUserDevices() {
+ synchronized (mLock) {
if (mUserDevices == null) {
// User devices should be saved out to
// $HOME/.android/devices.xml
mUserDevices = new ArrayList<Device>();
File userDevicesFile = null;
try {
- userDevicesFile = new File(AndroidLocation.getFolder(),
+ userDevicesFile = new File(
+ AndroidLocation.getFolder(),
SdkConstants.FN_DEVICES_XML);
if (userDevicesFile.exists()) {
mUserDevices.addAll(DeviceParser.parse(userDevicesFile));
- notifyListeners();
+ return true;
}
} catch (AndroidLocationException e) {
mLog.warning("Couldn't load user devices: %1$s", e.getMessage());
@@ -262,7 +301,8 @@ public class DeviceManager {
renamedConfig = new File(base + '.' + (i++));
}
mLog.error(null, "Error parsing %1$s, backing up to %2$s",
- userDevicesFile.getAbsolutePath(), renamedConfig.getAbsolutePath());
+ userDevicesFile.getAbsolutePath(),
+ renamedConfig.getAbsolutePath());
userDevicesFile.renameTo(renamedConfig);
}
} catch (ParserConfigurationException e) {
@@ -274,42 +314,52 @@ public class DeviceManager {
}
}
}
- return Collections.unmodifiableList(mUserDevices);
+ return false;
}
public void addUserDevice(Device d) {
- synchronized (sLock) {
+ boolean changed = false;
+ synchronized (mLock) {
if (mUserDevices == null) {
- getUserDevices();
+ initUserDevices();
+ assert mUserDevices != null;
}
- mUserDevices.add(d);
+ if (mUserDevices != null) {
+ mUserDevices.add(d);
+ }
+ changed = true;
+ }
+ if (changed) {
+ notifyListeners();
}
- notifyListeners();
}
public void removeUserDevice(Device d) {
- synchronized (sLock) {
+ synchronized (mLock) {
if (mUserDevices == null) {
- getUserDevices();
+ initUserDevices();
+ assert mUserDevices != null;
}
- Iterator<Device> it = mUserDevices.iterator();
- while (it.hasNext()) {
- Device userDevice = it.next();
- if (userDevice.getName().equals(d.getName())
- && userDevice.getManufacturer().equals(d.getManufacturer())) {
- it.remove();
- notifyListeners();
- break;
- }
+ if (mUserDevices != null) {
+ Iterator<Device> it = mUserDevices.iterator();
+ while (it.hasNext()) {
+ Device userDevice = it.next();
+ if (userDevice.getName().equals(d.getName())
+ && userDevice.getManufacturer().equals(d.getManufacturer())) {
+ it.remove();
+ notifyListeners();
+ return;
+ }
+ }
}
}
}
public void replaceUserDevice(Device d) {
- synchronized (sLock) {
+ synchronized (mLock) {
if (mUserDevices == null) {
- getUserDevices();
+ initUserDevices();
}
removeUserDevice(d);
addUserDevice(d);
@@ -339,7 +389,7 @@ public class DeviceManager {
return;
}
- synchronized (sLock) {
+ synchronized (mLock) {
if (mUserDevices.size() > 0) {
try {
DeviceWriter.writeToXml(new FileOutputStream(userDevicesFile), mUserDevices);
@@ -446,8 +496,8 @@ public class DeviceManager {
private void notifyListeners() {
synchronized (sListeners) {
- for (DevicesChangeListener listener : sListeners) {
- listener.onDevicesChange();
+ for (DevicesChangedListener listener : sListeners) {
+ listener.onDevicesChanged();
}
}
}
@@ -483,7 +533,7 @@ public class DeviceManager {
try {
String line;
while ((line = propertiesReader.readLine()) != null) {
- Matcher m = sPathPropertyPattern.matcher(line);
+ Matcher m = PATH_PROPERTY_PATTERN.matcher(line);
if (m.matches()) {
return true;
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java
index 6b219d3..5f35661 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdManager.java
@@ -59,7 +59,7 @@ public class AvdManager {
/**
* Exception thrown when something is wrong with a target path.
*/
- private final static class InvalidTargetPathException extends Exception {
+ private static final class InvalidTargetPathException extends Exception {
private static final long serialVersionUID = 1L;
InvalidTargetPathException(String message) {
@@ -69,26 +69,26 @@ public class AvdManager {
public static final String AVD_FOLDER_EXTENSION = ".avd"; //$NON-NLS-1$
- public final static String AVD_INFO_PATH = "path"; //$NON-NLS-1$
- public final static String AVD_INFO_TARGET = "target"; //$NON-NLS-1$
+ public static final String AVD_INFO_PATH = "path"; //$NON-NLS-1$
+ public static final String AVD_INFO_TARGET = "target"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the abi type of the specific avd
*
*/
- public final static String AVD_INI_ABI_TYPE = "abi.type"; //$NON-NLS-1$
+ public static final String AVD_INI_ABI_TYPE = "abi.type"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the CPU architecture of the specific avd
*
*/
- public final static String AVD_INI_CPU_ARCH = "hw.cpu.arch"; //$NON-NLS-1$
+ public static final String AVD_INI_CPU_ARCH = "hw.cpu.arch"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the CPU architecture of the specific avd
*
*/
- public final static String AVD_INI_CPU_MODEL = "hw.cpu.model"; //$NON-NLS-1$
+ public static final String AVD_INI_CPU_MODEL = "hw.cpu.model"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the manufacturer of the device this avd was based on.
@@ -106,19 +106,19 @@ public class AvdManager {
*
* @see #NUMERIC_SKIN_SIZE
*/
- public final static String AVD_INI_SKIN_PATH = "skin.path"; //$NON-NLS-1$
+ public static final String AVD_INI_SKIN_PATH = "skin.path"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing an UI name for the skin.
* This config key is ignored by the emulator. It is only used by the SDK manager or
* tools to give a friendlier name to the skin.
* If missing, use the {@link #AVD_INI_SKIN_PATH} key instead.
*/
- public final static String AVD_INI_SKIN_NAME = "skin.name"; //$NON-NLS-1$
+ public static final String AVD_INI_SKIN_NAME = "skin.name"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing whether a dynamic skin should be displayed.
*/
- public final static String AVD_INI_SKIN_DYNAMIC = "skin.dynamic"; //$NON-NLS-1$
+ public static final String AVD_INI_SKIN_DYNAMIC = "skin.dynamic"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the path to the sdcard file.
@@ -127,7 +127,7 @@ public class AvdManager {
*
* @see #SDCARD_IMG
*/
- public final static String AVD_INI_SDCARD_PATH = "sdcard.path"; //$NON-NLS-1$
+ public static final String AVD_INI_SDCARD_PATH = "sdcard.path"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the size of the SD card.
* This property is for UI purposes only. It is not used by the emulator.
@@ -135,7 +135,7 @@ public class AvdManager {
* @see #SDCARD_SIZE_PATTERN
* @see #parseSdcardSize(String, String[])
*/
- public final static String AVD_INI_SDCARD_SIZE = "sdcard.size"; //$NON-NLS-1$
+ public static final String AVD_INI_SDCARD_SIZE = "sdcard.size"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the first path where the emulator looks
* for system images. Typically this is the path to the add-on system image or
@@ -143,80 +143,80 @@ public class AvdManager {
* <p/>
* The emulator looks at {@link #AVD_INI_IMAGES_1} before {@link #AVD_INI_IMAGES_2}.
*/
- public final static String AVD_INI_IMAGES_1 = "image.sysdir.1"; //$NON-NLS-1$
+ public static final String AVD_INI_IMAGES_1 = "image.sysdir.1"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the second path where the emulator looks
* for system images. Typically this is the path to the platform system image.
*
* @see #AVD_INI_IMAGES_1
*/
- public final static String AVD_INI_IMAGES_2 = "image.sysdir.2"; //$NON-NLS-1$
+ public static final String AVD_INI_IMAGES_2 = "image.sysdir.2"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the presence of the snapshots file.
* This property is for UI purposes only. It is not used by the emulator.
*
* @see #SNAPSHOTS_IMG
*/
- public final static String AVD_INI_SNAPSHOT_PRESENT = "snapshot.present"; //$NON-NLS-1$
+ public static final String AVD_INI_SNAPSHOT_PRESENT = "snapshot.present"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing whether hardware OpenGLES emulation is enabled
*/
- public final static String AVD_INI_GPU_EMULATION = "hw.gpu.enabled"; //$NON-NLS-1$
+ public static final String AVD_INI_GPU_EMULATION = "hw.gpu.enabled"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing how to emulate the front facing camera
*/
- public final static String AVD_INI_CAMERA_FRONT = "hw.camera.front"; //$NON-NLS-1$
+ public static final String AVD_INI_CAMERA_FRONT = "hw.camera.front"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing how to emulate the rear facing camera
*/
- public final static String AVD_INI_CAMERA_BACK = "hw.camera.back"; //$NON-NLS-1$
+ public static final String AVD_INI_CAMERA_BACK = "hw.camera.back"; //$NON-NLS-1$
/**
* AVD/config.ini key name representing the amount of RAM the emulated device should have
*/
- public final static String AVD_INI_RAM_SIZE = "hw.ramSize";
+ public static final String AVD_INI_RAM_SIZE = "hw.ramSize";
/**
* AVD/config.ini key name representing the amount of memory available to applications by default
*/
- public final static String AVD_INI_VM_HEAP_SIZE = "vm.heapSize";
+ public static final String AVD_INI_VM_HEAP_SIZE = "vm.heapSize";
/**
* AVD/config.ini key name representing the size of the data partition
*/
- public final static String AVD_INI_DATA_PARTITION_SIZE = "disk.dataPartition.size";
+ public static final String AVD_INI_DATA_PARTITION_SIZE = "disk.dataPartition.size";
/**
* AVD/config.ini key name representing the hash of the device this AVD is based on
*/
- public final static String AVD_INI_DEVICE_HASH = "hw.device.hash";
+ public static final String AVD_INI_DEVICE_HASH = "hw.device.hash";
/**
* Pattern to match pixel-sized skin "names", e.g. "320x480".
*/
- public final static Pattern NUMERIC_SKIN_SIZE = Pattern.compile("([0-9]{2,})x([0-9]{2,})"); //$NON-NLS-1$
+ public static final Pattern NUMERIC_SKIN_SIZE = Pattern.compile("([0-9]{2,})x([0-9]{2,})"); //$NON-NLS-1$
- private final static String USERDATA_IMG = "userdata.img"; //$NON-NLS-1$
- final static String CONFIG_INI = "config.ini"; //$NON-NLS-1$
- private final static String SDCARD_IMG = "sdcard.img"; //$NON-NLS-1$
- private final static String SNAPSHOTS_IMG = "snapshots.img"; //$NON-NLS-1$
+ private static final String USERDATA_IMG = "userdata.img"; //$NON-NLS-1$
+ static final String CONFIG_INI = "config.ini"; //$NON-NLS-1$
+ private static final String SDCARD_IMG = "sdcard.img"; //$NON-NLS-1$
+ private static final String SNAPSHOTS_IMG = "snapshots.img"; //$NON-NLS-1$
- final static String INI_EXTENSION = ".ini"; //$NON-NLS-1$
- private final static Pattern INI_NAME_PATTERN = Pattern.compile("(.+)\\" + //$NON-NLS-1$
+ static final String INI_EXTENSION = ".ini"; //$NON-NLS-1$
+ private static final Pattern INI_NAME_PATTERN = Pattern.compile("(.+)\\" + //$NON-NLS-1$
INI_EXTENSION + "$", //$NON-NLS-1$
Pattern.CASE_INSENSITIVE);
- private final static Pattern IMAGE_NAME_PATTERN = Pattern.compile("(.+)\\.img$", //$NON-NLS-1$
+ private static final Pattern IMAGE_NAME_PATTERN = Pattern.compile("(.+)\\.img$", //$NON-NLS-1$
Pattern.CASE_INSENSITIVE);
/**
* Pattern for matching SD Card sizes, e.g. "4K" or "16M".
* Callers should use {@link #parseSdcardSize(String, String[])} instead of using this directly.
*/
- private final static Pattern SDCARD_SIZE_PATTERN = Pattern.compile("(\\d+)([KMG])"); //$NON-NLS-1$
+ private static final Pattern SDCARD_SIZE_PATTERN = Pattern.compile("(\\d+)([KMG])"); //$NON-NLS-1$
/**
* Minimal size of an SDCard image file in bytes. Currently 9 MiB.
@@ -229,19 +229,19 @@ public class AvdManager {
public static final long SDCARD_MAX_BYTE_SIZE = 1023L<<30;
/** The sdcard string represents a valid number but the size is outside of the allowed range. */
- public final static int SDCARD_SIZE_NOT_IN_RANGE = 0;
+ public static final int SDCARD_SIZE_NOT_IN_RANGE = 0;
/** The sdcard string looks like a size number+suffix but the number failed to decode. */
- public final static int SDCARD_SIZE_INVALID = -1;
+ public static final int SDCARD_SIZE_INVALID = -1;
/** The sdcard string doesn't look like a size, it might be a path instead. */
- public final static int SDCARD_NOT_SIZE_PATTERN = -2;
+ public static final int SDCARD_NOT_SIZE_PATTERN = -2;
/** Regex used to validate characters that compose an AVD name. */
- public final static Pattern RE_AVD_NAME = Pattern.compile("[a-zA-Z0-9._-]+"); //$NON-NLS-1$
+ public static final Pattern RE_AVD_NAME = Pattern.compile("[a-zA-Z0-9._-]+"); //$NON-NLS-1$
/** List of valid characters for an AVD name. Used for display purposes. */
- public final static String CHARS_AVD_NAME = "a-z A-Z 0-9 . _ -"; //$NON-NLS-1$
+ public static final String CHARS_AVD_NAME = "a-z A-Z 0-9 . _ -"; //$NON-NLS-1$
- public final static String HARDWARE_INI = "hardware.ini"; //$NON-NLS-1$
+ public static final String HARDWARE_INI = "hardware.ini"; //$NON-NLS-1$
/**
* Status returned by {@link AvdManager#isAvdNameConflicting(String)}.
@@ -1410,8 +1410,8 @@ public class AvdManager {
String hash = properties.get(AVD_INI_DEVICE_HASH);
if (deviceName != null && deviceMfctr != null && hash != null) {
int deviceHash = Integer.parseInt(hash);
- deviceStatus = (new DeviceManager(log)).getDeviceStatus(
- mSdkManager.getLocation(), deviceName, deviceMfctr, deviceHash);
+ DeviceManager devMan = DeviceManager.createInstance(mSdkManager.getLocation(), log);
+ deviceStatus = devMan.getDeviceStatus(deviceName, deviceMfctr, deviceHash);
}
}