AI 143883: am: CL 143881 AVD #1703143: delete AVDs not loaded correctly.

This covers the case where an AVD has an invalid target
  or is missing its AVD folder or the config.ini in it.
  Made some cosmetic cleanup too.
  Original author: raphael
  Merged from: //branches/cupcake/...

Automated import of CL 143883
This commit is contained in:
Raphael Moll
2009-03-31 17:23:46 -07:00
committed by The Android Open Source Project
parent 3ae1236bc9
commit 1edcab4738
4 changed files with 96 additions and 41 deletions

View File

@@ -461,13 +461,13 @@ class Main {
}
// Are there some unused AVDs?
List<AvdInfo> badAvds = avdManager.getUnavailableAvdList();
List<AvdInfo> badAvds = avdManager.getUnavailableAvds();
if (badAvds == null || badAvds.size() == 0) {
return;
}
mSdkLog.printf("\nThe following Android Virtual Devices are no longer available:\n");
mSdkLog.printf("\nThe following Android Virtual Devices could not be loaded:\n");
boolean needSeparator = false;
for (AvdInfo info : badAvds) {
if (needSeparator) {
@@ -592,7 +592,7 @@ class Main {
File dir = new File(oldAvdInfo.getPath());
avdManager.recursiveDelete(dir);
dir.delete();
// Remove old avd info from manager
// Remove old AVD info from manager
avdManager.removeAvd(oldAvdInfo);
}
@@ -602,13 +602,27 @@ class Main {
}
/**
* Delete an AVD.
* Delete an AVD. If the AVD name is not part of the available ones look for an
* invalid AVD (one not loaded due to some error) to remove it too.
*/
private void deleteAvd() {
try {
String avdName = mSdkCommandLine.getParamName();
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
AvdInfo info = avdManager.getAvd(avdName);
if (info == null) {
// Look in unavailable AVDs
List<AvdInfo> badAvds = avdManager.getUnavailableAvds();
if (badAvds != null) {
for (AvdInfo i : badAvds) {
if (i.getName().equals(avdName)) {
info = i;
break;
}
}
}
}
if (info == null) {
errorAndExit("There is no Android Virtual Device named '%s'.", avdName);