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.
|
// display some extra values.
|
||||||
Map<String, String> properties = info.getProperties();
|
Map<String, String> properties = info.getProperties();
|
||||||
|
if (properties != null) {
|
||||||
String skin = properties.get(AvdManager.AVD_INI_SKIN_NAME);
|
String skin = properties.get(AvdManager.AVD_INI_SKIN_NAME);
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
mSdkLog.printf(" Skin: %s\n", skin);
|
mSdkLog.printf(" Skin: %s\n", skin);
|
||||||
@@ -466,6 +467,7 @@ class Main {
|
|||||||
mSdkLog.printf(" Sdcard: %s\n", sdcard);
|
mSdkLog.printf(" Sdcard: %s\n", sdcard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Are there some unused AVDs?
|
// Are there some unused AVDs?
|
||||||
AvdInfo[] badAvds = avdManager.getBrokenAvds();
|
AvdInfo[] badAvds = avdManager.getBrokenAvds();
|
||||||
@@ -508,7 +510,7 @@ class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean removePrevious = false;
|
boolean removePrevious = mSdkCommandLine.getFlagForce();
|
||||||
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
|
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
|
||||||
|
|
||||||
String avdName = mSdkCommandLine.getParamName();
|
String avdName = mSdkCommandLine.getParamName();
|
||||||
@@ -522,8 +524,7 @@ class Main {
|
|||||||
|
|
||||||
AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
|
AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
if (mSdkCommandLine.getFlagForce()) {
|
if (removePrevious) {
|
||||||
removePrevious = true;
|
|
||||||
mSdkLog.warning(
|
mSdkLog.warning(
|
||||||
"Android Virtual Device '%s' already exists and will be replaced.",
|
"Android Virtual Device '%s' already exists and will be replaced.",
|
||||||
avdName);
|
avdName);
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public final class AvdManager {
|
|||||||
* @param targetHash the target hash
|
* @param targetHash the target hash
|
||||||
* @param target The target. Can be null, if the target was not resolved.
|
* @param target The target. Can be null, if the target was not resolved.
|
||||||
* @param properties The property map. Can be null.
|
* @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,
|
public AvdInfo(String name, String path, String targetHash, IAndroidTarget target,
|
||||||
Map<String, String> properties, AvdStatus status) {
|
Map<String, String> properties, AvdStatus status) {
|
||||||
@@ -193,7 +193,7 @@ public final class AvdManager {
|
|||||||
mPath = path;
|
mPath = path;
|
||||||
mTargetHash = targetHash;
|
mTargetHash = targetHash;
|
||||||
mTarget = target;
|
mTarget = target;
|
||||||
mProperties = Collections.unmodifiableMap(properties);
|
mProperties = properties == null ? null : Collections.unmodifiableMap(properties);
|
||||||
mStatus = status;
|
mStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ public final class AvdManager {
|
|||||||
return mTargetHash;
|
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() {
|
public IAndroidTarget getTarget() {
|
||||||
return mTarget;
|
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() {
|
public Map<String, String> getProperties() {
|
||||||
return mProperties;
|
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.
|
* 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 avdFolder the data folder for the AVD. It will be created as needed.
|
||||||
* @param name the name of the AVD
|
* @param name the name of the AVD
|
||||||
* @param target the target 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 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
|
* @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).
|
* 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.
|
* @param removePrevious If true remove any previous files.
|
||||||
*/
|
*/
|
||||||
public AvdInfo createAvd(File avdFolder, String name, IAndroidTarget target,
|
public AvdInfo createAvd(File avdFolder, String name, IAndroidTarget target,
|
||||||
@@ -482,7 +483,7 @@ public final class AvdManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now the skin.
|
// Now the skin.
|
||||||
if (skinName == null) {
|
if (skinName == null || skinName.length() == 0) {
|
||||||
skinName = target.getDefaultSkin();
|
skinName = target.getDefaultSkin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,7 +506,7 @@ public final class AvdManager {
|
|||||||
values.put(AVD_INI_SKIN_NAME, skinName);
|
values.put(AVD_INI_SKIN_NAME, skinName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdcard != null) {
|
if (sdcard != null && sdcard.length() > 0) {
|
||||||
File sdcardFile = new File(sdcard);
|
File sdcardFile = new File(sdcard);
|
||||||
if (sdcardFile.isFile()) {
|
if (sdcardFile.isFile()) {
|
||||||
// sdcard value is an external sdcard, so we put its path into the config.ini
|
// 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
|
// 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);
|
target, values);
|
||||||
|
|
||||||
synchronized (mAllAvdList) {
|
synchronized (mAllAvdList) {
|
||||||
mAllAvdList.add(avdInfo);
|
mAllAvdList.add(newAvdInfo);
|
||||||
mValidAvdList = mBrokenAvdList = null;
|
mValidAvdList = mBrokenAvdList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return avdInfo;
|
return newAvdInfo;
|
||||||
} catch (AndroidLocationException e) {
|
} catch (AndroidLocationException e) {
|
||||||
if (mSdkLog != null) {
|
if (mSdkLog != null) {
|
||||||
mSdkLog.error(e, null);
|
mSdkLog.error(e, null);
|
||||||
@@ -724,6 +727,7 @@ public final class AvdManager {
|
|||||||
* these operations fail.
|
* these operations fail.
|
||||||
*
|
*
|
||||||
* @param avdInfo the information on the AVD to delete
|
* @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) {
|
public void deleteAvd(AvdInfo avdInfo, ISdkLog log) {
|
||||||
try {
|
try {
|
||||||
@@ -905,10 +909,8 @@ public final class AvdManager {
|
|||||||
* Parses an AVD .ini file to create an {@link AvdInfo}.
|
* Parses an AVD .ini file to create an {@link AvdInfo}.
|
||||||
*
|
*
|
||||||
* @param path The path to the AVD .ini file
|
* @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
|
* @return A new {@link AvdInfo} with an {@link AvdStatus} indicating whether this AVD is
|
||||||
* returned. When true, such an AVD will be returned with an error description.
|
* valid or not.
|
||||||
* @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.
|
|
||||||
*/
|
*/
|
||||||
private AvdInfo parseAvdInfo(File path) {
|
private AvdInfo parseAvdInfo(File path) {
|
||||||
Map<String, String> map = SdkManager.parsePropertyFile(path, mSdkLog);
|
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 toolLocation The path to the mksdcard tool.
|
||||||
* @param size The size of the new SD Card, compatible with {@link #SDCARD_SIZE_PATTERN}.
|
* @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 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.
|
* @return True if the sdcard could be created.
|
||||||
*/
|
*/
|
||||||
private boolean createSdCard(String toolLocation, String size, String location) {
|
private boolean createSdCard(String toolLocation, String size, String location) {
|
||||||
@@ -1173,7 +1174,9 @@ public final class AvdManager {
|
|||||||
|
|
||||||
// create a new map
|
// create a new map
|
||||||
Map<String, String> properties = new HashMap<String, String>();
|
Map<String, String> properties = new HashMap<String, String>();
|
||||||
|
if (oldProperties != null) {
|
||||||
properties.putAll(oldProperties);
|
properties.putAll(oldProperties);
|
||||||
|
}
|
||||||
|
|
||||||
AvdStatus status;
|
AvdStatus status;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user