Merge change Ib096f1f0 into eclair
* changes: SDK Manager: suggest install of new platforms, addons or extra packages.
This commit is contained in:
@@ -36,6 +36,16 @@ import java.util.Map.Entry;
|
||||
*/
|
||||
class CommandLineProcessor {
|
||||
|
||||
/*
|
||||
* Steps needed to add a new action:
|
||||
* - Each action is defined as a "verb object" followed by parameters.
|
||||
* - Either reuse a VERB_ constant or define a new one.
|
||||
* - Either reuse an OBJECT_ constant or define a new one.
|
||||
* - Add a new entry to mAction with a one-line help summary.
|
||||
* - In the constructor, add a define() call for each parameter (either mandatory
|
||||
* or optional) for the given action.
|
||||
*/
|
||||
|
||||
/** Internal verb name for internally hidden flags. */
|
||||
public final static String GLOBAL_FLAG_VERB = "@@internal@@";
|
||||
|
||||
@@ -57,10 +67,14 @@ class CommandLineProcessor {
|
||||
/**
|
||||
* Action definitions.
|
||||
* <p/>
|
||||
* This list serves two purposes: first it is used to know which verb/object
|
||||
* actions are acceptable on the command-line; second it provides a summary
|
||||
* for each action that is printed in the help.
|
||||
* <p/>
|
||||
* Each entry is a string array with:
|
||||
* <ul>
|
||||
* <li> the verb.
|
||||
* <li> a direct object (use #NO_VERB_OBJECT if there's no object).
|
||||
* <li> a direct object (use {@link #NO_VERB_OBJECT} if there's no object).
|
||||
* <li> a description.
|
||||
* <li> an alternate form for the object (e.g. plural).
|
||||
* </ul>
|
||||
@@ -81,6 +95,15 @@ class CommandLineProcessor {
|
||||
/** Logger */
|
||||
private final ISdkLog mLog;
|
||||
|
||||
/**
|
||||
* Constructs a new command-line processor.
|
||||
*
|
||||
* @param logger An SDK logger object. Must not be null.
|
||||
* @param actions The list of actions recognized on the command-line.
|
||||
* See the javadoc of {@link #mActions} for more details.
|
||||
*
|
||||
* @see #mActions
|
||||
*/
|
||||
public CommandLineProcessor(ISdkLog logger, String[][] actions) {
|
||||
mLog = logger;
|
||||
mActions = actions;
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
|
||||
import com.android.sdklib.xml.AndroidXPathFactory;
|
||||
import com.android.sdkmanager.internal.repository.AboutPage;
|
||||
import com.android.sdkmanager.internal.repository.SettingsPage;
|
||||
import com.android.sdkuilib.internal.repository.LocalPackagesPage;
|
||||
import com.android.sdkuilib.repository.UpdaterWindow;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
@@ -243,7 +244,11 @@ public class Main {
|
||||
updateTestProject();
|
||||
|
||||
} else if (verb == null && directObject == null) {
|
||||
showMainWindow();
|
||||
showMainWindow(false /*autoUpdate*/);
|
||||
|
||||
} else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_SDK.equals(directObject)) {
|
||||
showMainWindow(true /*autoUpdate*/);
|
||||
|
||||
} else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_ADB.equals(directObject)) {
|
||||
@@ -257,7 +262,7 @@ public class Main {
|
||||
/**
|
||||
* Display the main SdkManager app window
|
||||
*/
|
||||
private void showMainWindow() {
|
||||
private void showMainWindow(boolean autoUpdate) {
|
||||
try {
|
||||
// display a message talking about the command line version
|
||||
System.out.printf("No command line parameters provided, launching UI.\n" +
|
||||
@@ -269,6 +274,10 @@ public class Main {
|
||||
false /*userCanChangeSdkRoot*/);
|
||||
window.registerPage("Settings", SettingsPage.class);
|
||||
window.registerPage("About", AboutPage.class);
|
||||
if (autoUpdate) {
|
||||
window.setInitialPage(LocalPackagesPage.class);
|
||||
window.setRequestAutoUpdate(true);
|
||||
}
|
||||
window.open();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -353,12 +362,14 @@ public class Main {
|
||||
} catch (IOException e) {
|
||||
errorAndExit("Unable to resolve Main project's directory: %1$s",
|
||||
pathToMainProject);
|
||||
return; // help Eclipse static analyzer understand we'll never execute the rest.
|
||||
}
|
||||
}
|
||||
|
||||
if (parentProject.isDirectory() == false) {
|
||||
errorAndExit("Main project's directory does not exist: %1$s",
|
||||
pathToMainProject);
|
||||
return;
|
||||
}
|
||||
|
||||
// now look for a manifest in there
|
||||
@@ -366,6 +377,7 @@ public class Main {
|
||||
if (manifest.isFile() == false) {
|
||||
errorAndExit("No AndroidManifest.xml file found in the main project directory: %1$s",
|
||||
parentProject.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
// now query the manifest for the package file.
|
||||
@@ -405,6 +417,7 @@ public class Main {
|
||||
String targetHash = p.getProperty(ProjectProperties.PROPERTY_TARGET);
|
||||
if (targetHash == null) {
|
||||
errorAndExit("Couldn't find the main project target");
|
||||
return;
|
||||
}
|
||||
|
||||
// and resolve it.
|
||||
@@ -413,6 +426,7 @@ public class Main {
|
||||
errorAndExit(
|
||||
"Unable to resolve main project target '%1$s'. You may want to install the platform in your SDK.",
|
||||
targetHash);
|
||||
return;
|
||||
}
|
||||
|
||||
mSdkLog.printf("Found main project target: %1$s\n", target.getFullName());
|
||||
|
||||
@@ -25,12 +25,23 @@ import com.android.sdklib.SdkManager;
|
||||
*/
|
||||
class SdkCommandLine extends CommandLineProcessor {
|
||||
|
||||
/*
|
||||
* Steps needed to add a new action:
|
||||
* - Each action is defined as a "verb object" followed by parameters.
|
||||
* - Either reuse a VERB_ constant or define a new one.
|
||||
* - Either reuse an OBJECT_ constant or define a new one.
|
||||
* - Add a new entry to mAction with a one-line help summary.
|
||||
* - In the constructor, add a define() call for each parameter (either mandatory
|
||||
* or optional) for the given action.
|
||||
*/
|
||||
|
||||
public final static String VERB_LIST = "list";
|
||||
public final static String VERB_CREATE = "create";
|
||||
public final static String VERB_MOVE = "move";
|
||||
public final static String VERB_DELETE = "delete";
|
||||
public final static String VERB_UPDATE = "update";
|
||||
|
||||
public static final String OBJECT_SDK = "sdk";
|
||||
public static final String OBJECT_AVD = "avd";
|
||||
public static final String OBJECT_AVDS = "avds";
|
||||
public static final String OBJECT_TARGET = "target";
|
||||
@@ -59,6 +70,10 @@ class SdkCommandLine extends CommandLineProcessor {
|
||||
/**
|
||||
* Action definitions for SdkManager command line.
|
||||
* <p/>
|
||||
* This list serves two purposes: first it is used to know which verb/object
|
||||
* actions are acceptable on the command-line; second it provides a summary
|
||||
* for each action that is printed in the help.
|
||||
* <p/>
|
||||
* Each entry is a string array with:
|
||||
* <ul>
|
||||
* <li> the verb.
|
||||
@@ -98,11 +113,16 @@ class SdkCommandLine extends CommandLineProcessor {
|
||||
|
||||
{ VERB_UPDATE, OBJECT_ADB,
|
||||
"Updates adb to support the USB devices declared in the SDK add-ons." },
|
||||
|
||||
{ VERB_UPDATE, OBJECT_SDK,
|
||||
"Updates the SDK by suggesting new platforms to install if available." }
|
||||
};
|
||||
|
||||
public SdkCommandLine(ISdkLog logger) {
|
||||
super(logger, ACTIONS);
|
||||
|
||||
// The following defines the parameters of the actions defined in mAction.
|
||||
|
||||
// --- create avd ---
|
||||
|
||||
define(Mode.STRING, false,
|
||||
@@ -175,6 +195,7 @@ class SdkCommandLine extends CommandLineProcessor {
|
||||
"Project name", null);
|
||||
|
||||
// --- create test-project ---
|
||||
|
||||
define(Mode.STRING, true,
|
||||
VERB_CREATE, OBJECT_TEST_PROJECT,
|
||||
"p", KEY_PATH,
|
||||
|
||||
Reference in New Issue
Block a user