AI 149397: ADT 1807821 and 1841824: Fixes in android tool
- Bug 1807821: create avd -f option does nothing. - Bug 1841824: NPE during AVD delete or update. BUG=1841824,1807821 Automated import of CL 149397
This commit is contained in:
committed by
The Android Open Source Project
parent
838143199e
commit
6f56ebc737
@@ -454,6 +454,7 @@ class Main {
|
||||
|
||||
// display some extra values.
|
||||
Map<String, String> properties = info.getProperties();
|
||||
if (properties != null) {
|
||||
String skin = properties.get(AvdManager.AVD_INI_SKIN_NAME);
|
||||
if (skin != null) {
|
||||
mSdkLog.printf(" Skin: %s\n", skin);
|
||||
@@ -466,6 +467,7 @@ class Main {
|
||||
mSdkLog.printf(" Sdcard: %s\n", sdcard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Are there some unused AVDs?
|
||||
AvdInfo[] badAvds = avdManager.getBrokenAvds();
|
||||
@@ -508,7 +510,7 @@ class Main {
|
||||
}
|
||||
|
||||
try {
|
||||
boolean removePrevious = false;
|
||||
boolean removePrevious = mSdkCommandLine.getFlagForce();
|
||||
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
|
||||
|
||||
String avdName = mSdkCommandLine.getParamName();
|
||||
@@ -522,8 +524,7 @@ class Main {
|
||||
|
||||
AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
|
||||
if (info != null) {
|
||||
if (mSdkCommandLine.getFlagForce()) {
|
||||
removePrevious = true;
|
||||
if (removePrevious) {
|
||||
mSdkLog.warning(
|
||||
"Android Virtual Device '%s' already exists and will be replaced.",
|
||||
avdName);
|
||||
|
||||
@@ -185,7 +185,7 @@ public final class AvdManager {
|
||||
* @param targetHash the target hash
|
||||
* @param target The target. Can be null, if the target was not resolved.
|
||||
* @param properties The property map. Can be null.
|
||||
* @param error The error describing why this AVD is invalid. Cannot be null.
|
||||
* @param status The {@link AvdStatus} of this AVD. Cannot be null.
|
||||
*/
|
||||
public AvdInfo(String name, String path, String targetHash, IAndroidTarget target,
|
||||
Map<String, String> properties, AvdStatus status) {
|
||||
@@ -193,7 +193,7 @@ public final class AvdManager {
|
||||
mPath = path;
|
||||
mTargetHash = targetHash;
|
||||
mTarget = target;
|
||||
mProperties = Collections.unmodifiableMap(properties);
|
||||
mProperties = properties == null ? null : Collections.unmodifiableMap(properties);
|
||||
mStatus = status;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public final class AvdManager {
|
||||
return mTargetHash;
|
||||
}
|
||||
|
||||
/** Returns the target of the AVD, or <code>null</code> if it has not been resolved */
|
||||
/** Returns the target of the AVD, or <code>null</code> if it has not been resolved. */
|
||||
public IAndroidTarget getTarget() {
|
||||
return mTarget;
|
||||
}
|
||||
@@ -257,7 +257,7 @@ public final class AvdManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of properties for the AVD.
|
||||
* Returns an unmodifiable map of properties for the AVD. This can be null.
|
||||
*/
|
||||
public Map<String, String> getProperties() {
|
||||
return mProperties;
|
||||
@@ -405,13 +405,14 @@ public final class AvdManager {
|
||||
|
||||
/**
|
||||
* Creates a new AVD. It is expected that there is no existing AVD with this name already.
|
||||
*
|
||||
* @param avdFolder the data folder for the AVD. It will be created as needed.
|
||||
* @param name the name of the AVD
|
||||
* @param target the target of the AVD
|
||||
* @param skinName the name of the skin. Can be null. Must have been verified by caller.
|
||||
* @param sdcard the parameter value for the sdCard. Can be null. This is either a path to
|
||||
* an existing sdcard image or a sdcard size (\d+, \d+K, \dM).
|
||||
* @param hardwareConfig the hardware setup for the AVD
|
||||
* @param hardwareConfig the hardware setup for the AVD. Can be null to use defaults.
|
||||
* @param removePrevious If true remove any previous files.
|
||||
*/
|
||||
public AvdInfo createAvd(File avdFolder, String name, IAndroidTarget target,
|
||||
@@ -482,7 +483,7 @@ public final class AvdManager {
|
||||
}
|
||||
|
||||
// Now the skin.
|
||||
if (skinName == null) {
|
||||
if (skinName == null || skinName.length() == 0) {
|
||||
skinName = target.getDefaultSkin();
|
||||
}
|
||||
|
||||
@@ -505,7 +506,7 @@ public final class AvdManager {
|
||||
values.put(AVD_INI_SKIN_NAME, skinName);
|
||||
}
|
||||
|
||||
if (sdcard != null) {
|
||||
if (sdcard != null && sdcard.length() > 0) {
|
||||
File sdcardFile = new File(sdcard);
|
||||
if (sdcardFile.isFile()) {
|
||||
// sdcard value is an external sdcard, so we put its path into the config.ini
|
||||
@@ -571,15 +572,17 @@ public final class AvdManager {
|
||||
}
|
||||
|
||||
// create the AvdInfo object, and add it to the list
|
||||
AvdInfo avdInfo = new AvdInfo(name, avdFolder.getAbsolutePath(), target.hashString(),
|
||||
AvdInfo newAvdInfo = new AvdInfo(name,
|
||||
avdFolder.getAbsolutePath(),
|
||||
target.hashString(),
|
||||
target, values);
|
||||
|
||||
synchronized (mAllAvdList) {
|
||||
mAllAvdList.add(avdInfo);
|
||||
mAllAvdList.add(newAvdInfo);
|
||||
mValidAvdList = mBrokenAvdList = null;
|
||||
}
|
||||
|
||||
return avdInfo;
|
||||
return newAvdInfo;
|
||||
} catch (AndroidLocationException e) {
|
||||
if (mSdkLog != null) {
|
||||
mSdkLog.error(e, null);
|
||||
@@ -724,6 +727,7 @@ public final class AvdManager {
|
||||
* these operations fail.
|
||||
*
|
||||
* @param avdInfo the information on the AVD to delete
|
||||
* @return True if the AVD was deleted with no error.
|
||||
*/
|
||||
public void deleteAvd(AvdInfo avdInfo, ISdkLog log) {
|
||||
try {
|
||||
@@ -905,10 +909,8 @@ public final class AvdManager {
|
||||
* Parses an AVD .ini file to create an {@link AvdInfo}.
|
||||
*
|
||||
* @param path The path to the AVD .ini file
|
||||
* @param acceptError When false, an AVD that fails to load will be discarded and null will be
|
||||
* returned. When true, such an AVD will be returned with an error description.
|
||||
* @return A new {@link AvdInfo} or null if the file is not valid or null if the AVD is not
|
||||
* valid and acceptError is false.
|
||||
* @return A new {@link AvdInfo} with an {@link AvdStatus} indicating whether this AVD is
|
||||
* valid or not.
|
||||
*/
|
||||
private AvdInfo parseAvdInfo(File path) {
|
||||
Map<String, String> map = SdkManager.parsePropertyFile(path, mSdkLog);
|
||||
@@ -1012,7 +1014,6 @@ public final class AvdManager {
|
||||
* @param toolLocation The path to the mksdcard tool.
|
||||
* @param size The size of the new SD Card, compatible with {@link #SDCARD_SIZE_PATTERN}.
|
||||
* @param location The path of the new sdcard image file to generate.
|
||||
* @param log The logger object, to report errors.
|
||||
* @return True if the sdcard could be created.
|
||||
*/
|
||||
private boolean createSdCard(String toolLocation, String size, String location) {
|
||||
@@ -1173,7 +1174,9 @@ public final class AvdManager {
|
||||
|
||||
// create a new map
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
if (oldProperties != null) {
|
||||
properties.putAll(oldProperties);
|
||||
}
|
||||
|
||||
AvdStatus status;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user