aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2009-08-12 18:12:33 -0700
committerRaphael <raphael@google.com>2009-08-12 18:12:33 -0700
commitd17762f1c4b242d101e91aeb8772487823c20f02 (patch)
tree2e787d21977492938feed974c73e0a2248c220bd
parent056952b60780a79cc2448ad5f2ea0c89911dc2ed (diff)
downloadsdk-d17762f1c4b242d101e91aeb8772487823c20f02.zip
sdk-d17762f1c4b242d101e91aeb8772487823c20f02.tar.gz
sdk-d17762f1c4b242d101e91aeb8772487823c20f02.tar.bz2
BUG 2040986 : SDK Updater, platform dependency on tools
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java60
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java54
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java16
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository.xsd6
-rwxr-xr-xsdkmanager/libs/sdklib/tests/com/android/sdklib/repository/repository_sample.xml2
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java14
6 files changed, 122 insertions, 30 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java
index e308a0f..f11523d 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java
@@ -33,11 +33,30 @@ import java.util.Properties;
*/
public class ExtraPackage extends Package {
- private static final String PROP_PATH = "Extra.Path"; //$NON-NLS-1$
+ private static final String PROP_PATH = "Extra.Path"; //$NON-NLS-1$
+ private static final String PROP_MIN_TOOLS_REV = "Extra.MinToolsRev"; //$NON-NLS-1$
+ /**
+ * The install folder name. It must be a single-segment path.
+ * The paths "add-ons", "platforms", "tools" and "docs" are reserved and cannot be used.
+ * This limitation cannot be written in the XML Schema and must be enforced here by using
+ * the method {@link #isPathValid()} *before* installing the package.
+ */
private final String mPath;
/**
+ * The minimal revision of the tools package required by this extra package, if > 0,
+ * or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
+ */
+ private final int mMinToolsRevision;
+
+ /**
+ * The value of {@link #mMinToolsRevision} when the {@link SdkRepository#NODE_MIN_TOOLS_REV}
+ * was not specified in the XML source.
+ */
+ public static final int MIN_TOOLS_REV_NOT_SPECIFIED = 0;
+
+ /**
* Creates a new tool package from the attributes and elements of the given XML node.
* <p/>
* This constructor should throw an exception if the package cannot be created.
@@ -45,6 +64,8 @@ public class ExtraPackage extends Package {
ExtraPackage(RepoSource source, Node packageNode, Map<String,String> licenses) {
super(source, packageNode, licenses);
mPath = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_PATH);
+ mMinToolsRevision = XmlParserUtils.getXmlInt(packageNode, SdkRepository.NODE_MIN_TOOLS_REV,
+ MIN_TOOLS_REV_NOT_SPECIFIED);
}
/**
@@ -73,6 +94,9 @@ public class ExtraPackage extends Package {
archiveOsPath);
// The path argument comes before whatever could be in the properties
mPath = path != null ? path : getProperty(props, PROP_PATH, path);
+
+ mMinToolsRevision = Integer.parseInt(getProperty(props, PROP_MIN_TOOLS_REV,
+ Integer.toString(MIN_TOOLS_REV_NOT_SPECIFIED)));
}
/**
@@ -84,6 +108,10 @@ public class ExtraPackage extends Package {
super.saveProperties(props);
props.setProperty(PROP_PATH, mPath);
+
+ if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
+ props.setProperty(PROP_MIN_TOOLS_REV, Integer.toString(mMinToolsRevision));
+ }
}
/**
@@ -109,6 +137,14 @@ public class ExtraPackage extends Package {
return mPath;
}
+ /**
+ * The minimal revision of the tools package required by this extra package, if > 0,
+ * or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
+ */
+ public int getMinToolsRevision() {
+ return mMinToolsRevision;
+ }
+
/** Returns a short description for an {@link IDescription}. */
@Override
public String getShortDescription() {
@@ -134,18 +170,32 @@ public class ExtraPackage extends Package {
}
}
- return String.format("%1$s package, revision %2$d",
+ String s = String.format("%1$s package, revision %2$d",
name,
getRevision());
+
+ if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
+ s += String.format(" (tools rev: %1$d)", mMinToolsRevision);
+ }
+
+ return s;
}
/** Returns a long description for an {@link IDescription}. */
@Override
public String getLongDescription() {
- return String.format("Extra %1$s package, revision %2$d.\n%3$s",
+ String s = String.format("Extra %1$s package, revision %2$d",
getPath(),
- getRevision(),
- super.getLongDescription());
+ getRevision());
+
+ if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
+ s += String.format(" (min tools rev.: %1$d)", mMinToolsRevision);
+ }
+
+ s += ".\n";
+ s += super.getLongDescription();
+
+ return s;
}
/**
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
index c9a58f7..1c5790d 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/PlatformPackage.java
@@ -35,12 +35,28 @@ import java.util.Properties;
*/
public class PlatformPackage extends Package {
- private static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
+ private static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
+ private static final String PROP_MIN_TOOLS_REV = "Platform.MinToolsRev"; //$NON-NLS-1$
+ /** The package version, for platform, add-on and doc packages. */
private final AndroidVersion mVersion;
+
+ /** The version, a string, for platform packages. */
private final String mVersionName;
/**
+ * The minimal revision of the tools package required by this extra package, if > 0,
+ * or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
+ */
+ private final int mMinToolsRevision;
+
+ /**
+ * The value of {@link #mMinToolsRevision} when the {@link SdkRepository#NODE_MIN_TOOLS_REV}
+ * was not specified in the XML source.
+ */
+ public static final int MIN_TOOLS_REV_NOT_SPECIFIED = 0;
+
+ /**
* Creates a new platform package from the attributes and elements of the given XML node.
* <p/>
* This constructor should throw an exception if the package cannot be created.
@@ -54,6 +70,9 @@ public class PlatformPackage extends Package {
codeName = null;
}
mVersion = new AndroidVersion(apiLevel, codeName);
+
+ mMinToolsRevision = XmlParserUtils.getXmlInt(packageNode, SdkRepository.NODE_MIN_TOOLS_REV,
+ MIN_TOOLS_REV_NOT_SPECIFIED);
}
/**
@@ -76,6 +95,9 @@ public class PlatformPackage extends Package {
mVersion = target.getVersion();
mVersionName = target.getVersionName();
+
+ mMinToolsRevision = Integer.parseInt(getProperty(props, PROP_MIN_TOOLS_REV,
+ Integer.toString(MIN_TOOLS_REV_NOT_SPECIFIED)));
}
/**
@@ -87,9 +109,14 @@ public class PlatformPackage extends Package {
super.saveProperties(props);
mVersion.saveProperties(props);
+
if (mVersionName != null) {
props.setProperty(PROP_VERSION, mVersionName);
}
+
+ if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
+ props.setProperty(PROP_MIN_TOOLS_REV, Integer.toString(mMinToolsRevision));
+ }
}
/** Returns the version, a string, for platform packages. */
@@ -102,17 +129,32 @@ public class PlatformPackage extends Package {
return mVersion;
}
+ /**
+ * The minimal revision of the tools package required by this extra package, if > 0,
+ * or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
+ */
+ public int getMinToolsRevision() {
+ return mMinToolsRevision;
+ }
+
/** Returns a short description for an {@link IDescription}. */
@Override
public String getShortDescription() {
- if (mVersion.isPreview()) {
- return String.format("SDK Platform Android %1$s (Preview)",
- getVersionName());
- }
+ String s;
- return String.format("SDK Platform Android %1$s, API %2$d",
+ if (mVersion.isPreview()) {
+ s = String.format("SDK Platform Android %1$s (Preview)", getVersionName());
+ } else {
+ s = String.format("SDK Platform Android %1$s, API %2$d",
getVersionName(),
mVersion.getApiLevel());
+ }
+
+ if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
+ s += String.format(" (tools rev: %1$d)", mMinToolsRevision);
+ }
+
+ return s;
}
/** Returns a long description for an {@link IDescription}. */
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java
index 4b12d59..2bf87d7 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepository.java
@@ -49,19 +49,21 @@ public class SdkRepository {
public static final String NODE_EXTRA = "extra"; //$NON-NLS-1$
/** The license definition. */
- public static final String NODE_LICENSE = "license"; //$NON-NLS-1$
+ public static final String NODE_LICENSE = "license"; //$NON-NLS-1$
/** The optional uses-license for all packages (platform, add-on, tool, doc) or for a lib. */
- public static final String NODE_USES_LICENSE = "uses-license"; //$NON-NLS-1$
+ public static final String NODE_USES_LICENSE = "uses-license"; //$NON-NLS-1$
/** The revision, an int > 0, for all packages (platform, add-on, tool, doc). */
- public static final String NODE_REVISION = "revision"; //$NON-NLS-1$
+ public static final String NODE_REVISION = "revision"; //$NON-NLS-1$
/** The optional description for all packages (platform, add-on, tool, doc) or for a lib. */
- public static final String NODE_DESCRIPTION = "description"; //$NON-NLS-1$
+ public static final String NODE_DESCRIPTION = "description"; //$NON-NLS-1$
/** The optional description URL for all packages (platform, add-on, tool, doc). */
- public static final String NODE_DESC_URL = "desc-url"; //$NON-NLS-1$
+ public static final String NODE_DESC_URL = "desc-url"; //$NON-NLS-1$
/** The optional release note for all packages (platform, add-on, tool, doc). */
- public static final String NODE_RELEASE_NOTE = "release-note"; //$NON-NLS-1$
+ public static final String NODE_RELEASE_NOTE = "release-note"; //$NON-NLS-1$
/** The optional release note URL for all packages (platform, add-on, tool, doc). */
- public static final String NODE_RELEASE_URL = "release-url"; //$NON-NLS-1$
+ public static final String NODE_RELEASE_URL = "release-url"; //$NON-NLS-1$
+ /** The optional minimal tools revision required by platform & extra packages. */
+ public static final String NODE_MIN_TOOLS_REV = "min-tools-rev"; //$NON-NLS-1$
/** The version, a string, for platform packages. */
public static final String NODE_VERSION = "version"; //$NON-NLS-1$
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository.xsd
index 7ca0892..f00e337 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository.xsd
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository.xsd
@@ -71,6 +71,9 @@
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
<xsd:element name="archives" type="sdk:archivesType" />
+ <!-- The minimal revision of tools required by this package.
+ Optional. If present, must be an int > 0. -->
+ <xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
</xsd:all>
</xsd:complexType>
</xsd:element>
@@ -241,6 +244,9 @@
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
<xsd:element name="archives" type="sdk:archivesType" />
+ <!-- The minimal revision of tools required by this package.
+ Optional. If present, must be an int > 0. -->
+ <xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
</xsd:all>
</xsd:complexType>
</xsd:element>
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/repository_sample.xml b/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/repository_sample.xml
index 20b8571..c90e18d 100755
--- a/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/repository_sample.xml
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/repository/repository_sample.xml
@@ -43,6 +43,7 @@
for this package. It's a free multi-line text.
</sdk:release-note>
<sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url>
+ <sdk:min-tools-rev>2</sdk:min-tools-rev>
<!-- The archives node is mandatory and it cannot be empty. -->
<sdk:archives>
<sdk:archive os="any">
@@ -268,6 +269,7 @@
</sdk:archives>
<sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description>
<sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url>
+ <sdk:min-tools-rev>3</sdk:min-tools-rev>
</sdk:extra>
</sdk:sdk-repository>
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java
index 6ea040c..636b9ab 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RemotePackagesPage.java
@@ -38,11 +38,13 @@ import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Tree;
@@ -105,18 +107,6 @@ public class RemotePackagesPage extends Composite implements ISdkListener {
mColumnSource.setWidth(289);
mColumnSource.setText("Sources, Packages and Archives");
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(
- new GridData(SWT.FILL, SWT.BEGINNING, false, false, 5, 1));
- GridLayout gl;
- composite.setLayout(gl = new GridLayout(2, false));
- gl.marginHeight = gl.marginWidth = 0;
- // add an empty composite
- Composite spacer = new Composite(composite, SWT.NONE);
- GridData gd;
- spacer.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
- gd.heightHint = 0;
-
mDescriptionContainer = new Group(parent, SWT.NONE);
mDescriptionContainer.setLayout(new GridLayout(1, false));
mDescriptionContainer.setText("Description");