eclair snapshot
This commit is contained in:
@@ -7,5 +7,6 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/AndroidPrefs"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/SdkUiLib"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ANDROID_SWT"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -62,14 +62,17 @@ else
|
||||
java_debug=
|
||||
fi
|
||||
|
||||
java_cmd="java"
|
||||
|
||||
# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
|
||||
if [ `uname` = "Darwin" ]; then
|
||||
os_opts="-XstartOnFirstThread"
|
||||
#because Java 1.6 is 64 bits only and SWT doesn't support this, we force the usage of java 1.5
|
||||
java_cmd="/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands/java"
|
||||
else
|
||||
os_opts=
|
||||
java_cmd="java"
|
||||
fi
|
||||
|
||||
if [ `uname` = "Linux" ]; then
|
||||
export GDK_NATIVE_WINDOWS=true
|
||||
fi
|
||||
|
||||
if [ "$OSTYPE" = "cygwin" ] ; then
|
||||
@@ -87,7 +90,7 @@ swtpath=""
|
||||
if [ -n "$ANDROID_SWT" ]; then
|
||||
swtpath="$ANDROID_SWT"
|
||||
else
|
||||
vmarch=`java -jar "${frameworkdir}"/archquery.jar`
|
||||
vmarch=`${java_cmd} -jar "${frameworkdir}"/archquery.jar`
|
||||
if [ -n "$ANDROID_BUILD_TOP" ]; then
|
||||
osname=`uname -s | tr A-Z a-z`
|
||||
swtpath="${ANDROID_BUILD_TOP}/prebuilt/${osname}-${vmarch}/swt"
|
||||
@@ -105,6 +108,10 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Starting Android SDK and AVD Manager"
|
||||
fi
|
||||
|
||||
# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
|
||||
# might need more memory, e.g. -Xmx128M
|
||||
exec "$java_cmd" -Xmx256M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir" -Dcom.android.sdkmanager.toolsdir="$progdir" -jar "$jarpath" "$@"
|
||||
|
||||
@@ -32,8 +32,10 @@ set jarpath=lib\sdkmanager.jar
|
||||
rem Set SWT.Jar path based on current architecture (x86 or x86_64)
|
||||
for /f %%a in ('java -jar lib\archquery.jar') do set swt_path=lib\%%a
|
||||
|
||||
if "%1 %2"=="update sdk" goto StartUi
|
||||
if not "%1"=="" goto EndTempCopy
|
||||
echo Starting Android SDK Updater
|
||||
:StartUi
|
||||
echo Starting Android SDK and AVD Manager
|
||||
|
||||
rem We're now going to create a temp dir to hold all the Jar files needed
|
||||
rem to run the android tool, copy them in the temp dir and finally execute
|
||||
@@ -42,7 +44,7 @@ if not "%1"=="" goto EndTempCopy
|
||||
rem update the tools directory where the updater itself is located.
|
||||
|
||||
set tmpdir=%TEMP%\temp-android-tool
|
||||
xcopy lib\x86 %tmpdir%\lib\x86 /I /E /C /G /R /O /Y /Q > nul
|
||||
xcopy lib\x86 %tmpdir%\lib\x86 /I /E /C /G /R /Y /Q > nul
|
||||
copy /B /D /Y lib\androidprefs.jar %tmpdir%\lib\ > nul
|
||||
copy /B /D /Y lib\org.eclipse.* %tmpdir%\lib\ > nul
|
||||
copy /B /D /Y lib\sdk* %tmpdir%\lib\ > nul
|
||||
|
||||
@@ -34,7 +34,17 @@ import java.util.Map.Entry;
|
||||
* To use, call {@link #parseArgs(String[])} and then
|
||||
* call {@link #getValue(String, String, String)}.
|
||||
*/
|
||||
public class CommandLineProcessor {
|
||||
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 @@ public 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 @@ public 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;
|
||||
@@ -460,7 +483,7 @@ public class CommandLineProcessor {
|
||||
stdout("\nValid actions are composed of a verb and an optional direct object:");
|
||||
for (String[] action : mActions) {
|
||||
|
||||
stdout("- %1$6s %2$-7s: %3$s",
|
||||
stdout("- %1$6s %2$-12s: %3$s",
|
||||
action[ACTION_VERB_INDEX],
|
||||
action[ACTION_OBJECT_INDEX],
|
||||
action[ACTION_DESC_INDEX]);
|
||||
|
||||
@@ -28,28 +28,41 @@ import com.android.sdklib.internal.avd.HardwareProperties;
|
||||
import com.android.sdklib.internal.avd.AvdManager.AvdInfo;
|
||||
import com.android.sdklib.internal.avd.HardwareProperties.HardwareProperty;
|
||||
import com.android.sdklib.internal.project.ProjectCreator;
|
||||
import com.android.sdklib.internal.project.ProjectProperties;
|
||||
import com.android.sdklib.internal.project.ProjectCreator.OutputLevel;
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.xpath.XPath;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
|
||||
/**
|
||||
* Main class for the 'android' application.
|
||||
*/
|
||||
class Main {
|
||||
public class Main {
|
||||
|
||||
/** Java property that defines the location of the sdk/tools directory. */
|
||||
private final static String TOOLSDIR = "com.android.sdkmanager.toolsdir";
|
||||
public final static String TOOLSDIR = "com.android.sdkmanager.toolsdir";
|
||||
/** Java property that defines the working directory. On Windows the current working directory
|
||||
* is actually the tools dir, in which case this is used to get the original CWD. */
|
||||
private final static String WORKDIR = "com.android.sdkmanager.workdir";
|
||||
|
||||
/** Value returned by {@link #resolveTargetName(String)} when the target id does not match. */
|
||||
private final static int INVALID_TARGET_ID = 0;
|
||||
|
||||
private final static String[] BOOLEAN_YES_REPLIES = new String[] { "yes", "y" };
|
||||
private final static String[] BOOLEAN_NO_REPLIES = new String[] { "no", "n" };
|
||||
|
||||
@@ -218,12 +231,24 @@ class Main {
|
||||
SdkCommandLine.OBJECT_PROJECT.equals(directObject)) {
|
||||
createProject();
|
||||
|
||||
} else if (SdkCommandLine.VERB_CREATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_TEST_PROJECT.equals(directObject)) {
|
||||
createTestProject();
|
||||
|
||||
} else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_PROJECT.equals(directObject)) {
|
||||
updateProject();
|
||||
|
||||
} else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_TEST_PROJECT.equals(directObject)) {
|
||||
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)) {
|
||||
@@ -237,7 +262,7 @@ 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" +
|
||||
@@ -249,6 +274,10 @@ 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();
|
||||
@@ -260,13 +289,13 @@ class Main {
|
||||
*/
|
||||
private void createProject() {
|
||||
// get the target and try to resolve it.
|
||||
int targetId = mSdkCommandLine.getParamTargetId();
|
||||
int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
|
||||
IAndroidTarget[] targets = mSdkManager.getTargets();
|
||||
if (targetId < 1 || targetId > targets.length) {
|
||||
if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
|
||||
errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
|
||||
SdkConstants.androidCmdName());
|
||||
}
|
||||
IAndroidTarget target = targets[targetId - 1];
|
||||
IAndroidTarget target = targets[targetId - 1]; // target id is 1-based
|
||||
|
||||
ProjectCreator creator = new ProjectCreator(mOsSdkFolder,
|
||||
mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE :
|
||||
@@ -311,23 +340,140 @@ class Main {
|
||||
packageName,
|
||||
activityName,
|
||||
target,
|
||||
false /* isTestProject*/);
|
||||
null /*pathToMain*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Android test project based on command-line parameters
|
||||
*/
|
||||
private void createTestProject() {
|
||||
|
||||
String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
|
||||
|
||||
// first check the path of the parent project, and make sure it's valid.
|
||||
String pathToMainProject = mSdkCommandLine.getParamTestProjectMain();
|
||||
|
||||
File parentProject = new File(pathToMainProject);
|
||||
if (parentProject.isAbsolute() == false) {
|
||||
// if the path is not absolute, we need to resolve it based on the
|
||||
// destination path of the project
|
||||
try {
|
||||
parentProject = new File(projectDir, pathToMainProject).getCanonicalFile();
|
||||
} 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
|
||||
File manifest = new File(parentProject, SdkConstants.FN_ANDROID_MANIFEST_XML);
|
||||
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.
|
||||
XPath xpath = AndroidXPathFactory.newXPath();
|
||||
String packageName, activityName;
|
||||
|
||||
try {
|
||||
packageName = xpath.evaluate("/manifest/@package",
|
||||
new InputSource(new FileInputStream(manifest)));
|
||||
|
||||
mSdkLog.printf("Found main project package: %1$s\n", packageName);
|
||||
|
||||
// now get the name of the first activity we find
|
||||
activityName = xpath.evaluate("/manifest/application/activity[1]/@android:name",
|
||||
new InputSource(new FileInputStream(manifest)));
|
||||
// xpath will return empty string when there's no match
|
||||
if (activityName == null || activityName.length() == 0) {
|
||||
activityName = null;
|
||||
} else {
|
||||
mSdkLog.printf("Found main project activity: %1$s\n", activityName);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
// this shouldn't happen as we test it above.
|
||||
errorAndExit("No AndroidManifest.xml file found in main project.");
|
||||
return; // this is not strictly needed because errorAndExit will stop the execution,
|
||||
// but this makes the java compiler happy, wrt to uninitialized variables.
|
||||
} catch (XPathExpressionException e) {
|
||||
// looks like the main manifest is not valid.
|
||||
errorAndExit("Unable to parse main project manifest to get information.");
|
||||
return; // this is not strictly needed because errorAndExit will stop the execution,
|
||||
// but this makes the java compiler happy, wrt to uninitialized variables.
|
||||
}
|
||||
|
||||
// now get the target hash
|
||||
ProjectProperties p = ProjectProperties.load(parentProject.getAbsolutePath(),
|
||||
PropertyType.DEFAULT);
|
||||
String targetHash = p.getProperty(ProjectProperties.PROPERTY_TARGET);
|
||||
if (targetHash == null) {
|
||||
errorAndExit("Couldn't find the main project target");
|
||||
return;
|
||||
}
|
||||
|
||||
// and resolve it.
|
||||
IAndroidTarget target = mSdkManager.getTargetFromHashString(targetHash);
|
||||
if (target == null) {
|
||||
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());
|
||||
|
||||
ProjectCreator creator = new ProjectCreator(mOsSdkFolder,
|
||||
mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE :
|
||||
mSdkCommandLine.isSilent() ? OutputLevel.SILENT :
|
||||
OutputLevel.NORMAL,
|
||||
mSdkLog);
|
||||
|
||||
String projectName = mSdkCommandLine.getParamName();
|
||||
|
||||
if (projectName != null &&
|
||||
!ProjectCreator.RE_PROJECT_NAME.matcher(projectName).matches()) {
|
||||
errorAndExit(
|
||||
"Project name '%1$s' contains invalid characters.\nAllowed characters are: %2$s",
|
||||
projectName, ProjectCreator.CHARS_PROJECT_NAME);
|
||||
return;
|
||||
}
|
||||
|
||||
creator.createProject(projectDir,
|
||||
projectName,
|
||||
packageName,
|
||||
activityName,
|
||||
target,
|
||||
pathToMainProject);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates an existing Android project based on command-line parameters
|
||||
*/
|
||||
private void updateProject() {
|
||||
// get the target and try to resolve it.
|
||||
IAndroidTarget target = null;
|
||||
int targetId = mSdkCommandLine.getParamTargetId();
|
||||
if (targetId >= 0) {
|
||||
String targetStr = mSdkCommandLine.getParamTargetId();
|
||||
// For "update project" the target parameter is optional so having null is acceptable.
|
||||
// However if there's a value, it must be valid.
|
||||
if (targetStr != null) {
|
||||
IAndroidTarget[] targets = mSdkManager.getTargets();
|
||||
if (targetId < 1 || targetId > targets.length) {
|
||||
errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
|
||||
int targetId = resolveTargetName(targetStr);
|
||||
if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
|
||||
errorAndExit("Target id '%1$s' is not valid. Use '%2$s list targets' to get the target ids.",
|
||||
targetStr,
|
||||
SdkConstants.androidCmdName());
|
||||
}
|
||||
target = targets[targetId - 1];
|
||||
target = targets[targetId - 1]; // target id is 1-based
|
||||
}
|
||||
|
||||
ProjectCreator creator = new ProjectCreator(mOsSdkFolder,
|
||||
@@ -370,6 +516,21 @@ class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing test project with a new path to the main project.
|
||||
*/
|
||||
private void updateTestProject() {
|
||||
ProjectCreator creator = new ProjectCreator(mOsSdkFolder,
|
||||
mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE :
|
||||
mSdkCommandLine.isSilent() ? OutputLevel.SILENT :
|
||||
OutputLevel.NORMAL,
|
||||
mSdkLog);
|
||||
|
||||
String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
|
||||
|
||||
creator.updateTestProject(projectDir, mSdkCommandLine.getParamTestProjectMain());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the project location to make it absolute & canonical relative to the
|
||||
* working directory, if any.
|
||||
@@ -412,7 +573,7 @@ class Main {
|
||||
|
||||
int index = 1;
|
||||
for (IAndroidTarget target : mSdkManager.getTargets()) {
|
||||
mSdkLog.printf("id: %d\n", index);
|
||||
mSdkLog.printf("id: %1$d or \"%2$s\"\n", index, target.hashString());
|
||||
mSdkLog.printf(" Name: %s\n", target.getName());
|
||||
if (target.isPlatform()) {
|
||||
mSdkLog.printf(" Type: Platform\n");
|
||||
@@ -557,16 +718,16 @@ class Main {
|
||||
*/
|
||||
private void createAvd() {
|
||||
// find a matching target
|
||||
int targetId = mSdkCommandLine.getParamTargetId();
|
||||
IAndroidTarget target = null;
|
||||
int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
|
||||
IAndroidTarget[] targets = mSdkManager.getTargets();
|
||||
|
||||
if (targetId >= 1 && targetId <= mSdkManager.getTargets().length) {
|
||||
target = mSdkManager.getTargets()[targetId-1]; // target it is 1-based
|
||||
} else {
|
||||
if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
|
||||
errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
|
||||
SdkConstants.androidCmdName());
|
||||
}
|
||||
|
||||
IAndroidTarget target = targets[targetId-1]; // target id is 1-based
|
||||
|
||||
try {
|
||||
boolean removePrevious = mSdkCommandLine.getFlagForce();
|
||||
AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);
|
||||
@@ -587,7 +748,9 @@ class Main {
|
||||
"Android Virtual Device '%s' already exists and will be replaced.",
|
||||
avdName);
|
||||
} else {
|
||||
errorAndExit("Android Virtual Device '%s' already exists.", avdName);
|
||||
errorAndExit("Android Virtual Device '%s' already exists.\n" +
|
||||
"Use --force if you want to replace it.",
|
||||
avdName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -607,7 +770,8 @@ class Main {
|
||||
if (skin != null && skin.length() == 0) {
|
||||
skin = null;
|
||||
}
|
||||
if (skin != null) {
|
||||
|
||||
if (skin != null && target != null) {
|
||||
boolean valid = false;
|
||||
// Is it a know skin name for this target?
|
||||
for (String s : target.getSkins()) {
|
||||
@@ -639,7 +803,7 @@ class Main {
|
||||
}
|
||||
|
||||
Map<String, String> hardwareConfig = null;
|
||||
if (target.isPlatform()) {
|
||||
if (target != null && target.isPlatform()) {
|
||||
try {
|
||||
hardwareConfig = promptForHardware(target, skinHardwareConfig);
|
||||
} catch (IOException e) {
|
||||
@@ -647,11 +811,13 @@ class Main {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // oldAvdInfo is never read, yet useful for debugging
|
||||
AvdInfo oldAvdInfo = null;
|
||||
if (removePrevious) {
|
||||
oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // newAvdInfo is never read, yet useful for debugging
|
||||
AvdInfo newAvdInfo = avdManager.createAvd(avdFolder,
|
||||
avdName,
|
||||
target,
|
||||
@@ -845,13 +1011,16 @@ class Main {
|
||||
// get the list of possible hardware properties
|
||||
File hardwareDefs = new File (mOsSdkFolder + File.separator +
|
||||
SdkConstants.OS_SDK_TOOLS_LIB_FOLDER, SdkConstants.FN_HARDWARE_INI);
|
||||
List<HardwareProperty> list = HardwareProperties.parseHardwareDefinitions(hardwareDefs,
|
||||
null /*sdkLog*/);
|
||||
Map<String, HardwareProperty> hwMap = HardwareProperties.parseHardwareDefinitions(
|
||||
hardwareDefs, null /*sdkLog*/);
|
||||
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
|
||||
for (int i = 0 ; i < list.size() ;) {
|
||||
HardwareProperty property = list.get(i);
|
||||
// we just want to loop on the HardwareProperties
|
||||
HardwareProperty[] hwProperties = hwMap.values().toArray(
|
||||
new HardwareProperty[hwMap.size()]);
|
||||
for (int i = 0 ; i < hwProperties.length ;) {
|
||||
HardwareProperty property = hwProperties[i];
|
||||
|
||||
String description = property.getDescription();
|
||||
if (description != null) {
|
||||
@@ -978,4 +1147,43 @@ class Main {
|
||||
mSdkLog.error(null, format, args);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a symbolic target name (such as those accepted by --target on the command-line)
|
||||
* to an internal target index id. A valid target name is either a numeric target id (> 0)
|
||||
* or a target hash string.
|
||||
* <p/>
|
||||
* If the given target can't be mapped, {@link #INVALID_TARGET_ID} (0) is returned.
|
||||
* It's up to the caller to output an error.
|
||||
* <p/>
|
||||
* On success, returns a value > 0.
|
||||
*/
|
||||
private int resolveTargetName(String targetName) {
|
||||
|
||||
if (targetName == null) {
|
||||
return INVALID_TARGET_ID;
|
||||
}
|
||||
|
||||
targetName = targetName.trim();
|
||||
|
||||
// Case of an integer number
|
||||
if (targetName.matches("[0-9]*")) {
|
||||
try {
|
||||
int n = Integer.parseInt(targetName);
|
||||
return n < 1 ? INVALID_TARGET_ID : n;
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignore. Should not happen.
|
||||
}
|
||||
}
|
||||
|
||||
// Let's try to find a platform or addon name.
|
||||
IAndroidTarget[] targets = mSdkManager.getTargets();
|
||||
for (int i = 0; i < targets.length; i++) {
|
||||
if (targetName.equals(targets[i].hashString())) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return INVALID_TARGET_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,17 @@ import com.android.sdklib.SdkManager;
|
||||
/**
|
||||
* Specific command-line flags for the {@link SdkManager}.
|
||||
*/
|
||||
public class SdkCommandLine extends CommandLineProcessor {
|
||||
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";
|
||||
@@ -31,32 +41,39 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
public final static String VERB_DELETE = "delete";
|
||||
public final static String VERB_UPDATE = "update";
|
||||
|
||||
public static final String OBJECT_AVD = "avd";
|
||||
public static final String OBJECT_AVDS = "avds";
|
||||
public static final String OBJECT_TARGET = "target";
|
||||
public static final String OBJECT_TARGETS = "targets";
|
||||
public static final String OBJECT_PROJECT = "project";
|
||||
public static final String OBJECT_ADB = "adb";
|
||||
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";
|
||||
public static final String OBJECT_TARGETS = "targets";
|
||||
public static final String OBJECT_PROJECT = "project";
|
||||
public static final String OBJECT_TEST_PROJECT = "test-project";
|
||||
public static final String OBJECT_ADB = "adb";
|
||||
|
||||
public static final String ARG_ALIAS = "alias";
|
||||
public static final String ARG_ACTIVITY = "activity";
|
||||
public static final String ARG_ALIAS = "alias";
|
||||
public static final String ARG_ACTIVITY = "activity";
|
||||
|
||||
public static final String KEY_ACTIVITY = ARG_ACTIVITY;
|
||||
public static final String KEY_PACKAGE = "package";
|
||||
public static final String KEY_MODE = "mode";
|
||||
public static final String KEY_TARGET_ID = OBJECT_TARGET;
|
||||
public static final String KEY_NAME = "name";
|
||||
public static final String KEY_PATH = "path";
|
||||
public static final String KEY_FILTER = "filter";
|
||||
public static final String KEY_SKIN = "skin";
|
||||
public static final String KEY_SDCARD = "sdcard";
|
||||
public static final String KEY_FORCE = "force";
|
||||
public static final String KEY_RENAME = "rename";
|
||||
public static final String KEY_SUBPROJECTS = "subprojects";
|
||||
public static final String KEY_ACTIVITY = ARG_ACTIVITY;
|
||||
public static final String KEY_PACKAGE = "package";
|
||||
public static final String KEY_MODE = "mode";
|
||||
public static final String KEY_TARGET_ID = OBJECT_TARGET;
|
||||
public static final String KEY_NAME = "name";
|
||||
public static final String KEY_PATH = "path";
|
||||
public static final String KEY_FILTER = "filter";
|
||||
public static final String KEY_SKIN = "skin";
|
||||
public static final String KEY_SDCARD = "sdcard";
|
||||
public static final String KEY_FORCE = "force";
|
||||
public static final String KEY_RENAME = "rename";
|
||||
public static final String KEY_SUBPROJECTS = "subprojects";
|
||||
public static final String KEY_MAIN_PROJECT = "main";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -89,13 +106,23 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
{ VERB_UPDATE, OBJECT_PROJECT,
|
||||
"Updates an Android Project (must have an AndroidManifest.xml)." },
|
||||
|
||||
{ VERB_CREATE, OBJECT_TEST_PROJECT,
|
||||
"Creates a new Android Test Project." },
|
||||
{ VERB_UPDATE, OBJECT_TEST_PROJECT,
|
||||
"Updates an Android Test Project (must have an AndroidManifest.xml)." },
|
||||
|
||||
{ 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,
|
||||
@@ -104,7 +131,7 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
define(Mode.STRING, true,
|
||||
VERB_CREATE, OBJECT_AVD, "n", KEY_NAME,
|
||||
"Name of the new AVD", null);
|
||||
define(Mode.INTEGER, true,
|
||||
define(Mode.STRING, true,
|
||||
VERB_CREATE, OBJECT_AVD, "t", KEY_TARGET_ID,
|
||||
"Target id of the new AVD", null);
|
||||
define(Mode.STRING, false,
|
||||
@@ -154,7 +181,7 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
VERB_CREATE, OBJECT_PROJECT,
|
||||
"p", KEY_PATH,
|
||||
"Location path of new project", null);
|
||||
define(Mode.INTEGER, true,
|
||||
define(Mode.STRING, true,
|
||||
VERB_CREATE, OBJECT_PROJECT, "t", KEY_TARGET_ID,
|
||||
"Target id of the new project", null);
|
||||
define(Mode.STRING, true,
|
||||
@@ -167,16 +194,29 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
VERB_CREATE, OBJECT_PROJECT, "n", KEY_NAME,
|
||||
"Project name", null);
|
||||
|
||||
// --- create test-project ---
|
||||
|
||||
define(Mode.STRING, true,
|
||||
VERB_CREATE, OBJECT_TEST_PROJECT,
|
||||
"p", KEY_PATH,
|
||||
"Location path of new project", null);
|
||||
define(Mode.STRING, false,
|
||||
VERB_CREATE, OBJECT_TEST_PROJECT, "n", KEY_NAME,
|
||||
"Project name", null);
|
||||
define(Mode.STRING, true,
|
||||
VERB_CREATE, OBJECT_TEST_PROJECT, "m", KEY_MAIN_PROJECT,
|
||||
"Location path of the project to test, relative to the new project", null);
|
||||
|
||||
// --- update project ---
|
||||
|
||||
define(Mode.STRING, true,
|
||||
VERB_UPDATE, OBJECT_PROJECT,
|
||||
"p", KEY_PATH,
|
||||
"Location path of the project", null);
|
||||
define(Mode.INTEGER, true,
|
||||
define(Mode.STRING, false,
|
||||
VERB_UPDATE, OBJECT_PROJECT,
|
||||
"t", KEY_TARGET_ID,
|
||||
"Target id to set for the project", -1);
|
||||
"Target id to set for the project", null);
|
||||
define(Mode.STRING, false,
|
||||
VERB_UPDATE, OBJECT_PROJECT,
|
||||
"n", KEY_NAME,
|
||||
@@ -185,6 +225,17 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
VERB_UPDATE, OBJECT_PROJECT,
|
||||
"s", KEY_SUBPROJECTS,
|
||||
"Also update any projects in sub-folders, such as test projects.", false);
|
||||
|
||||
// --- update test project ---
|
||||
|
||||
define(Mode.STRING, true,
|
||||
VERB_UPDATE, OBJECT_TEST_PROJECT,
|
||||
"p", KEY_PATH,
|
||||
"Location path of the project", null);
|
||||
define(Mode.STRING, true,
|
||||
VERB_UPDATE, OBJECT_TEST_PROJECT,
|
||||
"m", KEY_MAIN_PROJECT,
|
||||
"Location path of the project to test, relative to the new project", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,27 +247,34 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
|
||||
/** Helper to retrieve the --path value. */
|
||||
public String getParamLocationPath() {
|
||||
return ((String) getValue(null, null, KEY_PATH));
|
||||
return (String) getValue(null, null, KEY_PATH);
|
||||
}
|
||||
|
||||
/** Helper to retrieve the --target id value. */
|
||||
public int getParamTargetId() {
|
||||
return ((Integer) getValue(null, null, KEY_TARGET_ID)).intValue();
|
||||
/**
|
||||
* Helper to retrieve the --target id value.
|
||||
* The id is a string. It can be one of:
|
||||
* - an integer, in which case it's the index of the target (cf "android list targets")
|
||||
* - a symbolic name such as android-N for platforn API N
|
||||
* - a symbolic add-on name such as written in the avd/*.ini files,
|
||||
* e.g. "Google Inc.:Google APIs:3"
|
||||
*/
|
||||
public String getParamTargetId() {
|
||||
return (String) getValue(null, null, KEY_TARGET_ID);
|
||||
}
|
||||
|
||||
/** Helper to retrieve the --name value. */
|
||||
public String getParamName() {
|
||||
return ((String) getValue(null, null, KEY_NAME));
|
||||
return (String) getValue(null, null, KEY_NAME);
|
||||
}
|
||||
|
||||
/** Helper to retrieve the --skin value. */
|
||||
public String getParamSkin() {
|
||||
return ((String) getValue(null, null, KEY_SKIN));
|
||||
return (String) getValue(null, null, KEY_SKIN);
|
||||
}
|
||||
|
||||
/** Helper to retrieve the --sdcard value. */
|
||||
public String getParamSdCard() {
|
||||
return ((String) getValue(null, null, KEY_SDCARD));
|
||||
return (String) getValue(null, null, KEY_SDCARD);
|
||||
}
|
||||
|
||||
/** Helper to retrieve the --force flag. */
|
||||
@@ -228,7 +286,7 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
|
||||
/** Helper to retrieve the --rename value for a move verb. */
|
||||
public String getParamMoveNewName() {
|
||||
return ((String) getValue(VERB_MOVE, null, KEY_RENAME));
|
||||
return (String) getValue(VERB_MOVE, null, KEY_RENAME);
|
||||
}
|
||||
|
||||
|
||||
@@ -248,4 +306,11 @@ public class SdkCommandLine extends CommandLineProcessor {
|
||||
public boolean getParamSubProject() {
|
||||
return ((Boolean) getValue(null, OBJECT_PROJECT, KEY_SUBPROJECTS)).booleanValue();
|
||||
}
|
||||
|
||||
// -- some helpers for test-project action flags
|
||||
|
||||
/** Helper to retrieve the --main value. */
|
||||
public String getParamTestProjectMain() {
|
||||
return ((String) getValue(null, null, KEY_MAIN_PROJECT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,20 @@
|
||||
package com.android.sdkmanager.internal.repository;
|
||||
|
||||
|
||||
import com.android.sdkmanager.*;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
/*
|
||||
* TODO list
|
||||
* - Change version to be a constant pulled from somewhere.
|
||||
*/
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class AboutPage extends Composite {
|
||||
|
||||
@@ -45,11 +49,21 @@ public class AboutPage extends Composite {
|
||||
}
|
||||
|
||||
private void createContents(Composite parent) {
|
||||
parent.setLayout(new GridLayout(1, false));
|
||||
parent.setLayout(new GridLayout(2, false));
|
||||
|
||||
Label logo = new Label(parent, SWT.NONE);
|
||||
InputStream imageStream = this.getClass().getResourceAsStream("logo.png");
|
||||
|
||||
if (imageStream != null) {
|
||||
Image img = new Image(parent.getShell().getDisplay(), imageStream);
|
||||
logo.setImage(img);
|
||||
}
|
||||
|
||||
mLabel = new Label(parent, SWT.NONE);
|
||||
mLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1));
|
||||
mLabel.setText("Android SDK Updater.\n\nVersion 0.1.\n\nCopyright (C) 2009 The Android Open Source Project.");
|
||||
mLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
|
||||
mLabel.setText(String.format(
|
||||
"Android SDK Updater.\nRevision %1$s\nCopyright (C) 2009 The Android Open Source Project.",
|
||||
getRevision()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,4 +83,28 @@ public class AboutPage extends Composite {
|
||||
|
||||
// End of hiding from SWT Designer
|
||||
//$hide<<$
|
||||
|
||||
private String getRevision() {
|
||||
Properties p = new Properties();
|
||||
try{
|
||||
String toolsdir = System.getProperty(Main.TOOLSDIR);
|
||||
File sourceProp;
|
||||
if (toolsdir == null || toolsdir.length() == 0) {
|
||||
sourceProp = new File("source.properties"); //$NON-NLS-1$
|
||||
} else {
|
||||
sourceProp = new File(toolsdir, "source.properties"); //$NON-NLS-1$
|
||||
}
|
||||
p.load(new FileInputStream(sourceProp));
|
||||
String revision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$
|
||||
if (revision != null) {
|
||||
return revision;
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
// couldn't find the file? don't ping.
|
||||
} catch (IOException e) {
|
||||
// couldn't find the file? don't ping.
|
||||
}
|
||||
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Reference in New Issue
Block a user