avdName + AvdManager.AVD_FOLDER_EXTENSION);
}
- Map<String, String> hardwareConfig = null;
- if (target.isPlatform()) {
- try {
- hardwareConfig = promptForHardware(target);
- } catch (IOException e) {
- errorAndExit(e.getMessage());
- }
- }
-
- AvdInfo oldAvdInfo = null;
- if (removePrevious) {
- oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/);
- }
-
// Validate skin is either default (empty) or NNNxMMM or a valid skin name.
+ Map<String, String> skinHardwareConfig = null;
String skin = mSdkCommandLine.getParamSkin();
if (skin != null && skin.length() == 0) {
skin = null;
if (skin.equalsIgnoreCase(s)) {
skin = s; // Make skin names case-insensitive.
valid = true;
+
+ // get the hardware properties for this skin
+ File skinFile = avdManager.getSkinPath(skin, target);
+ if (skinFile.isDirectory()) { // this should not fail since we got the skin
+ // name from the target
+ File skinHardwareFle = new File(skinFile, AvdManager.HARDWARE_INI);
+ if (skinHardwareFle.isFile()) {
+ skinHardwareConfig = SdkManager.parsePropertyFile(
+ skinHardwareFle, mSdkLog);
+ }
+ }
break;
}
}
}
}
+ Map<String, String> hardwareConfig = null;
+ if (target.isPlatform()) {
+ try {
+ hardwareConfig = promptForHardware(target, skinHardwareConfig);
+ } catch (IOException e) {
+ errorAndExit(e.getMessage());
+ }
+ }
+
+ AvdInfo oldAvdInfo = null;
+ if (removePrevious) {
+ oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/);
+ }
+
AvdInfo newAvdInfo = avdManager.createAvd(avdFolder,
avdName,
target,
* Prompts the user to setup a hardware config for a Platform-based AVD.
* @throws IOException
*/
- private Map<String, String> promptForHardware(IAndroidTarget createTarget) throws IOException {
+ private Map<String, String> promptForHardware(IAndroidTarget createTarget,
+ Map<String, String> skinHardwareConfig) throws IOException {
byte[] readLineBuffer = new byte[256];
String result;
String defaultAnswer = "no";
}
if (getBooleanReply(result) == false) {
- // no custom config.
- return null;
+ // no custom config, return the skin hardware config in case there is one.
+ return skinHardwareConfig;
}
mSdkLog.printf("\n"); // empty line
}
String defaultValue = property.getDefault();
+ String defaultFromSkin = skinHardwareConfig != null ? skinHardwareConfig.get(
+ property.getName()) : null;
- if (defaultValue != null) {
+ if (defaultFromSkin != null) {
+ mSdkLog.printf("%s [%s (from skin)]:", property.getName(), defaultFromSkin);
+ } else if (defaultValue != null) {
mSdkLog.printf("%s [%s]:", property.getName(), defaultValue);
} else {
mSdkLog.printf("%s (%s):", property.getName(), property.getType());
result = readLine(readLineBuffer);
if (result.length() == 0) {
- if (defaultValue != null) {
+ if (defaultFromSkin != null || defaultValue != null) {
+ if (defaultFromSkin != null) {
+ // we need to write this one in the AVD file
+ map.put(property.getName(), defaultFromSkin);
+ }
+
mSdkLog.printf("\n"); // empty line
i++; // go to the next property if we have a valid default value.
// if there's no default, we'll redo this property
/** 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 . _ -";
+ public final static String HARDWARE_INI = "hardware.ini";
+
/** An immutable structure describing an Android Virtual Device. */
public static final class AvdInfo {
}
}
+ // add the hardware config to the config file.
+ // priority order is:
+ // - values provided by the user
+ // - values provided by the skin
+ // - values provided by the target (add-on only).
+ // In order to follow this priority, we'll add the lowest priority values first and then
+ // override by higher priority values.
+ // In the case of a platform with override values from the user, the skin value might
+ // already be there, but it's ok.
+
+ HashMap<String, String> finalHardwareValues = new HashMap<String, String>();
+
+ File targetHardwareFile = new File(target.getLocation(), AvdManager.HARDWARE_INI);
+ if (targetHardwareFile.isFile()) {
+ Map<String, String> targetHardwareConfig = SdkManager.parsePropertyFile(
+ targetHardwareFile, mSdkLog);
+ if (targetHardwareConfig != null) {
+ finalHardwareValues.putAll(targetHardwareConfig);
+ values.putAll(targetHardwareConfig);
+ }
+ }
+
+ // get the hardware properties for this skin
+ File skinFile = getSkinPath(skinName, target);
+ if (skinFile.isDirectory()) { // this should not fail since we got the skin
+ // name from the target
+ File skinHardwareFile = new File(skinFile, AvdManager.HARDWARE_INI);
+ if (skinHardwareFile.isFile()) {
+ Map<String, String> skinHardwareConfig = SdkManager.parsePropertyFile(
+ skinHardwareFile, mSdkLog);
+ if (skinHardwareConfig != null) {
+ finalHardwareValues.putAll(skinHardwareConfig);
+ values.putAll(skinHardwareConfig);
+ }
+ }
+ }
+
+ // finally put the hardware provided by the user.
if (hardwareConfig != null) {
+ finalHardwareValues.putAll(hardwareConfig);
values.putAll(hardwareConfig);
}
if (mSdkLog != null) {
if (target.isPlatform()) {
- mSdkLog.printf("Created AVD '%1$s' based on %2$s\n", name, target.getName());
+ mSdkLog.printf("Created AVD '%1$s' based on %2$s", name, target.getName());
+ } else {
+ mSdkLog.printf("Created AVD '%1$s' based on %2$s (%3$s)", name,
+ target.getName(), target.getVendor());
+ }
+
+ // display the chosen hardware config
+ if (finalHardwareValues.size() > 0) {
+ mSdkLog.printf(", with the following hardware config:\n");
+ for (Entry<String, String> entry : finalHardwareValues.entrySet()) {
+ mSdkLog.printf("%s=%s\n",entry.getKey(), entry.getValue());
+ }
} else {
- mSdkLog.printf("Created AVD '%1$s' based on %2$s (%3$s)\n", name, target.getName(),
- target.getVendor());
+ mSdkLog.printf("\n");
}
}
/**
* Returns the path to the skin, as a relative path to the SDK.
*/
- private String getSkinRelativePath(String skinName, IAndroidTarget target) {
+ public String getSkinRelativePath(String skinName, IAndroidTarget target) {
// first look to see if the skin is in the target
-
- String path = target.getPath(IAndroidTarget.SKINS);
- File skin = new File(path, skinName);
-
- if (skin.exists() == false && target.isPlatform() == false) {
- target = target.getParent();
-
- path = target.getPath(IAndroidTarget.SKINS);
- skin = new File(path, skinName);
- }
+ File skin = getSkinPath(skinName, target);
// skin really does not exist!
if (skin.exists() == false) {
}
// get the skin path
- path = skin.getAbsolutePath();
+ String path = skin.getAbsolutePath();
// make this path relative to the SDK location
String sdkLocation = mSdk.getLocation();
}
/**
+ * Returns the full absolute OS path to a skin specified by name for a given target.
+ * @return a {@link File} that may or may not actually exist.
+ */
+ public File getSkinPath(String skinName, IAndroidTarget target) {
+ String path = target.getPath(IAndroidTarget.SKINS);
+ File skin = new File(path, skinName);
+
+ if (skin.exists() == false && target.isPlatform() == false) {
+ target = target.getParent();
+
+ path = target.getPath(IAndroidTarget.SKINS);
+ skin = new File(path, skinName);
+ }
+
+ return skin;
+ }
+
+ /**
* Creates the ini file for an AVD.
*
* @param name of the AVD.
try {
t1.join();
} catch (InterruptedException e) {
+ // nothing to do here
}
try {
t2.join();
} catch (InterruptedException e) {
+ // nothing to do here
}
}