AI 143885: am: CL 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/...
  Original author: android-build
  Merged from: //branches/donutburger/...

Automated import of CL 143885
This commit is contained in:
Raphael Moll
2009-03-31 17:24:12 -07:00
committed by The Android Open Source Project
parent dc9a9a7bf7
commit 4ca8a78df7
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);