AI 146739: am: CL 146689 Broken AVDs are now loaded by default, and we provide a way to fix one (new) type of error (wrong paths to the system image)
Original author: xav Merged from: //branches/cupcake/... Automated import of CL 146739
This commit is contained in:
committed by
The Android Open Source Project
parent
268c824eb1
commit
62ca2ce538
@@ -214,6 +214,10 @@ class Main {
|
||||
SdkCommandLine.OBJECT_AVD.equals(directObject)) {
|
||||
moveAvd();
|
||||
|
||||
} else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_AVD.equals(directObject)) {
|
||||
updateAvd();
|
||||
|
||||
} else if (SdkCommandLine.VERB_CREATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_PROJECT.equals(directObject)) {
|
||||
createProject();
|
||||
@@ -221,6 +225,7 @@ class Main {
|
||||
} else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_PROJECT.equals(directObject)) {
|
||||
updateProject();
|
||||
|
||||
} else {
|
||||
mSdkCommandLine.printHelpAndExit(null);
|
||||
}
|
||||
@@ -424,7 +429,7 @@ class Main {
|
||||
|
||||
mSdkLog.printf("Available Android Virtual Devices:\n");
|
||||
|
||||
AvdInfo[] avds = avdManager.getAvds();
|
||||
AvdInfo[] avds = avdManager.getValidAvds();
|
||||
for (int index = 0 ; index < avds.length ; index++) {
|
||||
AvdInfo info = avds[index];
|
||||
if (index > 0) {
|
||||
@@ -461,9 +466,9 @@ class Main {
|
||||
}
|
||||
|
||||
// Are there some unused AVDs?
|
||||
List<AvdInfo> badAvds = avdManager.getUnavailableAvds();
|
||||
AvdInfo[] badAvds = avdManager.getBrokenAvds();
|
||||
|
||||
if (badAvds == null || badAvds.size() == 0) {
|
||||
if (badAvds.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -473,9 +478,11 @@ class Main {
|
||||
if (needSeparator) {
|
||||
mSdkLog.printf("---------\n");
|
||||
}
|
||||
mSdkLog.printf(" Name: %s\n", info.getName() == null ? "--" : info.getName());
|
||||
mSdkLog.printf(" Path: %s\n", info.getPath() == null ? "--" : info.getPath());
|
||||
mSdkLog.printf(" Error: %s\n", info.getError() == null ? "--" : info.getError());
|
||||
mSdkLog.printf(" Name: %s\n", info.getName() == null ? "--" : info.getName());
|
||||
mSdkLog.printf(" Path: %s\n", info.getPath() == null ? "--" : info.getPath());
|
||||
|
||||
String error = info.getErrorMessage();
|
||||
mSdkLog.printf(" Error: %s\n", error == null ? "Uknown error" : error);
|
||||
needSeparator = true;
|
||||
}
|
||||
} catch (AndroidLocationException e) {
|
||||
@@ -511,7 +518,7 @@ class Main {
|
||||
return;
|
||||
}
|
||||
|
||||
AvdInfo info = avdManager.getAvd(avdName);
|
||||
AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
|
||||
if (info != null) {
|
||||
if (mSdkCommandLine.getFlagForce()) {
|
||||
removePrevious = true;
|
||||
@@ -544,7 +551,7 @@ class Main {
|
||||
|
||||
AvdInfo oldAvdInfo = null;
|
||||
if (removePrevious) {
|
||||
oldAvdInfo = avdManager.getAvd(avdName);
|
||||
oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/);
|
||||
}
|
||||
|
||||
// Validate skin is either default (empty) or NNNxMMM or a valid skin name.
|
||||
@@ -581,8 +588,7 @@ class Main {
|
||||
skin,
|
||||
mSdkCommandLine.getParamSdCard(),
|
||||
hardwareConfig,
|
||||
removePrevious,
|
||||
mSdkLog);
|
||||
removePrevious);
|
||||
|
||||
if (newAvdInfo != null &&
|
||||
oldAvdInfo != null &&
|
||||
@@ -609,21 +615,8 @@ class Main {
|
||||
try {
|
||||
String avdName = mSdkCommandLine.getParamName();
|
||||
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
|
||||
AvdInfo info = avdManager.getAvd(avdName);
|
||||
AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
|
||||
|
||||
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);
|
||||
return;
|
||||
@@ -636,16 +629,16 @@ class Main {
|
||||
}
|
||||
|
||||
/**
|
||||
* Move an AVD.
|
||||
* Moves an AVD.
|
||||
*/
|
||||
private void moveAvd() {
|
||||
try {
|
||||
String avdName = mSdkCommandLine.getParamName();
|
||||
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
|
||||
AvdInfo info = avdManager.getAvd(avdName);
|
||||
AvdInfo info = avdManager.getAvd(avdName, true /*validAvdOnly*/);
|
||||
|
||||
if (info == null) {
|
||||
errorAndExit("There is no Android Virtual Device named '%s'.", avdName);
|
||||
errorAndExit("There is no valid Android Virtual Device named '%s'.", avdName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -703,13 +696,8 @@ class Main {
|
||||
}
|
||||
|
||||
// Check for conflicts
|
||||
|
||||
if (newName != null && avdManager.getAvd(newName) != null) {
|
||||
errorAndExit("There is already an AVD named '%s'.", newName);
|
||||
return;
|
||||
}
|
||||
if (newName != null) {
|
||||
if (avdManager.getAvd(newName) != null) {
|
||||
if (avdManager.getAvd(newName, false /*validAvdOnly*/) != null) {
|
||||
errorAndExit("There is already an AVD named '%s'.", newName);
|
||||
return;
|
||||
}
|
||||
@@ -735,6 +723,21 @@ class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a broken AVD.
|
||||
*/
|
||||
private void updateAvd() {
|
||||
try {
|
||||
String avdName = mSdkCommandLine.getParamName();
|
||||
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
|
||||
avdManager.updateAvd(avdName);
|
||||
} catch (AndroidLocationException e) {
|
||||
errorAndExit(e.getMessage());
|
||||
} catch (IOException e) {
|
||||
errorAndExit(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the user to setup a hardware config for a Platform-based AVD.
|
||||
* @throws IOException
|
||||
|
||||
@@ -79,6 +79,8 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
"Moves or renames an Android Virtual Device." },
|
||||
{ VERB_DELETE, OBJECT_AVD,
|
||||
"Deletes an Android Virtual Device." },
|
||||
{ VERB_UPDATE, OBJECT_AVD,
|
||||
"Updates an Android Virtual Device to match the folders of a new SDK." },
|
||||
|
||||
{ VERB_CREATE, OBJECT_PROJECT,
|
||||
"Creates a new Android Project." },
|
||||
@@ -128,6 +130,12 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
VERB_MOVE, OBJECT_AVD, "p", KEY_PATH,
|
||||
"New location path of the directory where to move the AVD", null);
|
||||
|
||||
// --- update avd ---
|
||||
|
||||
define(MODE.STRING, true,
|
||||
VERB_UPDATE, OBJECT_AVD, "n", KEY_NAME,
|
||||
"Name of the AVD to update", null);
|
||||
|
||||
// --- create project ---
|
||||
|
||||
define(MODE.ENUM, true,
|
||||
|
||||
Reference in New Issue
Block a user