aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs/sdklib/src
diff options
context:
space:
mode:
Diffstat (limited to 'sdkmanager/libs/sdklib/src')
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java90
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkAddonSource.java15
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkRepoSource.java9
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java9
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSysImgSource.java109
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-addon-5.xsd7
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-7.xsd1
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java8
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonsListConstants.java28
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java7
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkSysImgConstants.java83
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-1.xsd2
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-2.xsd106
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-sys-img-1.xsd229
14 files changed, 674 insertions, 29 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java
index 216e309..0880645 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/AddonsListFetcher.java
@@ -57,14 +57,21 @@ import javax.xml.validation.Validator;
*/
public class AddonsListFetcher {
+ public enum SiteType {
+ ADDON_SITE,
+ SYS_IMG_SITE
+ }
+
/**
* An immutable structure representing an add-on site.
*/
public static class Site {
private final String mUrl;
private final String mUiName;
+ private final SiteType mType;
- private Site(String url, String uiName) {
+ private Site(String url, String uiName, SiteType type) {
+ mType = type;
mUrl = url.trim();
mUiName = uiName;
}
@@ -76,6 +83,17 @@ public class AddonsListFetcher {
public String getUiName() {
return mUiName;
}
+
+ public SiteType getType() {
+ return mType;
+ }
+
+ /** Returns a debug string representation of this object. Not for user display. */
+ @Override
+ public String toString() {
+ return String.format("<%1$s URL='%2$s' Name='%3$s'>", //$NON-NLS-1$
+ mType, mUrl, mUiName);
+ }
}
/**
@@ -92,7 +110,7 @@ public class AddonsListFetcher {
url = url == null ? "" : url.trim();
- monitor.setProgressMax(5);
+ monitor.setProgressMax(6);
monitor.setDescription("Fetching %1$s", url);
monitor.incProgress(1);
@@ -102,7 +120,55 @@ public class AddonsListFetcher {
Document validatedDoc = null;
String validatedUri = null;
+ String[] defaultNames = new String[SdkAddonsListConstants.NS_LATEST_VERSION];
+ for (int version = SdkAddonsListConstants.NS_LATEST_VERSION, i = 0;
+ version >= 1;
+ version--, i++) {
+ defaultNames[i] = SdkAddonsListConstants.getDefaultName(version);
+ }
+
InputStream xml = fetchUrl(url, cache, monitor.createSubMonitor(1), exception);
+ if (xml != null) {
+ int version = getXmlSchemaVersion(xml);
+ if (version == 0) {
+ xml = null;
+ }
+ }
+
+ // If we can't find the latest version, try earlier schema versions.
+ if (xml == null && defaultNames.length > 0) {
+ ITaskMonitor subMonitor = monitor.createSubMonitor(1);
+ subMonitor.setProgressMax(defaultNames.length);
+
+ String baseUrl = url;
+ if (!baseUrl.endsWith("/")) { //$NON-NLS-1$
+ int pos = baseUrl.lastIndexOf('/');
+ if (pos > 0) {
+ baseUrl = baseUrl.substring(0, pos + 1);
+ }
+ }
+
+ for (String name : defaultNames) {
+ String newUrl = baseUrl + name;
+ if (newUrl.equals(url)) {
+ continue;
+ }
+ xml = fetchUrl(newUrl, cache, subMonitor.createSubMonitor(1), exception);
+ if (xml != null) {
+ int version = getXmlSchemaVersion(xml);
+ if (version == 0) {
+ xml = null;
+ } else {
+ url = newUrl;
+ subMonitor.incProgress(
+ subMonitor.getProgressMax() - subMonitor.getProgress());
+ break;
+ }
+ }
+ }
+ } else {
+ monitor.incProgress(1);
+ }
if (xml != null) {
monitor.setDescription("Validate XML");
@@ -434,8 +500,22 @@ public class AddonsListFetcher {
child != null;
child = child.getNextSibling()) {
if (child.getNodeType() == Node.ELEMENT_NODE &&
- nsUri.equals(child.getNamespaceURI()) &&
- child.getLocalName().equals(SdkAddonsListConstants.NODE_ADDON_SITE)) {
+ nsUri.equals(child.getNamespaceURI())) {
+
+ String elementName = child.getLocalName();
+ SiteType type = null;
+
+ if (SdkAddonsListConstants.NODE_SYS_IMG_SITE.equals(elementName)) {
+ type = SiteType.SYS_IMG_SITE;
+
+ } else if (SdkAddonsListConstants.NODE_ADDON_SITE.equals(elementName)) {
+ type = SiteType.ADDON_SITE;
+ }
+
+ // Not an addon-site nor a sys-img-site, don't process this.
+ if (type == null) {
+ continue;
+ }
Node url = getFirstChild(child, nsUri, SdkAddonsListConstants.NODE_URL);
Node name = getFirstChild(child, nsUri, SdkAddonsListConstants.NODE_NAME);
@@ -451,7 +531,7 @@ public class AddonsListFetcher {
}
if (strUrl.length() > 0 && strName.length() > 0) {
- sites.add(new Site(strUrl, strName));
+ sites.add(new Site(strUrl, strName, type));
}
}
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkAddonSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkAddonSource.java
index 39a134b..cff7e1a 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkAddonSource.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkAddonSource.java
@@ -34,7 +34,7 @@ public class SdkAddonSource extends SdkSource {
/**
* Constructs a new source for the given repository URL.
* @param url The source URL. Cannot be null. If the URL ends with a /, the default
- * repository.xml filename will be appended automatically.
+ * addon.xml filename will be appended automatically.
* @param uiName The UI-visible name of the source. Can be null.
*/
public SdkAddonSource(String url, String uiName) {
@@ -50,6 +50,16 @@ public class SdkAddonSource extends SdkSource {
return true;
}
+ /**
+ * Returns true if this is a system-image source.
+ * We only load system-images from these sources.
+ */
+ @Override
+ public boolean isSysImgSource() {
+ return false;
+ }
+
+
@Override
protected String[] getDefaultXmlFileUrls() {
return new String[] { SdkAddonConstants.URL_DEFAULT_FILENAME };
@@ -86,8 +96,7 @@ public class SdkAddonSource extends SdkSource {
}
/**
- * There is no support forward evolution of the sdk-addon schema yet since we
- * currently have only one version.
+ * This kind of schema does not support forward-evolution of the &lt;tool&gt; element.
*
* @param xml The input XML stream. Can be null.
* @return Always null.
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkRepoSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkRepoSource.java
index 482655f..9fe5574 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkRepoSource.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkRepoSource.java
@@ -65,6 +65,15 @@ public class SdkRepoSource extends SdkSource {
return false;
}
+ /**
+ * Returns true if this is a system-image source.
+ * We only load system-images from these sources.
+ */
+ @Override
+ public boolean isSysImgSource() {
+ return false;
+ }
+
private static String[] sDefaults = null; // lazily allocated in getDefaultXmlFileUrls
@Override
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java
index c07715b..8187480 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSource.java
@@ -126,6 +126,13 @@ public abstract class SdkSource implements IDescription, Comparable<SdkSource> {
public abstract boolean isAddonSource();
/**
+ * Returns true if this is a system-image source.
+ * We only load system-images from these sources.
+ */
+ public abstract boolean isSysImgSource();
+
+
+ /**
* Returns the basename of the default URLs to try to download the
* XML manifest.
* E.g. this is typically SdkRepoConstants.URL_DEFAULT_XML_FILE
@@ -373,7 +380,7 @@ public abstract class SdkSource implements IDescription, Comparable<SdkSource> {
}
}
- for(String name : defaultNames) {
+ for (String name : defaultNames) {
String newUrl = baseUrl + name;
if (newUrl.equals(url)) {
continue;
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSysImgSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSysImgSource.java
new file mode 100755
index 0000000..7cee61d
--- /dev/null
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/sources/SdkSysImgSource.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sdklib.internal.repository.sources;
+
+import com.android.annotations.Nullable;
+import com.android.sdklib.internal.repository.packages.Package;
+import com.android.sdklib.repository.SdkSysImgConstants;
+
+import org.w3c.dom.Document;
+
+import java.io.InputStream;
+
+
+/**
+ * An sdk-sys-img source, i.e. a download site for system-image packages.
+ * A repository describes one or more {@link Package}s available for download.
+ */
+public class SdkSysImgSource extends SdkSource {
+
+ /**
+ * Constructs a new source for the given repository URL.
+ * @param url The source URL. Cannot be null. If the URL ends with a /, the default
+ * sys-img.xml filename will be appended automatically.
+ * @param uiName The UI-visible name of the source. Can be null.
+ */
+ public SdkSysImgSource(String url, String uiName) {
+ super(url, uiName);
+ }
+
+ /**
+ * Returns true if this is an addon source.
+ * We only load addons and extras from these sources.
+ */
+ @Override
+ public boolean isAddonSource() {
+ return false;
+ }
+
+ /**
+ * Returns true if this is a system-image source.
+ * We only load system-images from these sources.
+ */
+ @Override
+ public boolean isSysImgSource() {
+ return true;
+ }
+
+
+ @Override
+ protected String[] getDefaultXmlFileUrls() {
+ return new String[] { SdkSysImgConstants.URL_DEFAULT_FILENAME };
+ }
+
+ @Override
+ protected int getNsLatestVersion() {
+ return SdkSysImgConstants.NS_LATEST_VERSION;
+ }
+
+ @Override
+ protected String getNsUri() {
+ return SdkSysImgConstants.NS_URI;
+ }
+
+ @Override
+ protected String getNsPattern() {
+ return SdkSysImgConstants.NS_PATTERN;
+ }
+
+ @Override
+ protected String getSchemaUri(int version) {
+ return SdkSysImgConstants.getSchemaUri(version);
+ }
+
+ @Override
+ protected String getRootElementName() {
+ return SdkSysImgConstants.NODE_SDK_SYS_IMG;
+ }
+
+ @Override
+ protected InputStream getXsdStream(int version) {
+ return SdkSysImgConstants.getXsdStream(version);
+ }
+
+ /**
+ * This kind of schema does not support forward-evolution of the &lt;tool&gt; element.
+ *
+ * @param xml The input XML stream. Can be null.
+ * @return Always null.
+ * @null This implementation always return null.
+ */
+ @Override
+ protected Document findAlternateToolsXml(@Nullable InputStream xml) {
+ return null;
+ }
+}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-addon-5.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-addon-5.xsd
index 6250789..546b00d 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-addon-5.xsd
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-addon-5.xsd
@@ -70,12 +70,13 @@
</xsd:documentation>
</xsd:annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="add-on" type="sdk:addonType" />
- <xsd:element name="extra" type="sdk:extraType" />
- <xsd:element name="license" type="sdk:licenseType" />
+ <xsd:element name="add-on" type="sdk:addonType" />
+ <xsd:element name="extra" type="sdk:extraType" />
+ <xsd:element name="license" type="sdk:licenseType" />
</xsd:choice>
</xsd:complexType>
+
<!-- The definition of an SDK Add-on package. -->
<xsd:complexType name="addonType">
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-7.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-7.xsd
index ca41b36..ea18070 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-7.xsd
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/-sdk-repository-7.xsd
@@ -212,6 +212,7 @@
</xsd:all>
</xsd:complexType>
+
<!-- The definition of the ABI supported by a platform's system image. -->
<xsd:simpleType name="abiType">
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
index 53db79f..703cc9d 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
@@ -44,6 +44,14 @@ public class RepoConstants {
/** The optional project-files provided by extra packages. */
public static final String NODE_PROJECT_FILES = "project-files"; //$NON-NLS-1$
+ /** A system-image package. */
+ public static final String NODE_SYSTEM_IMAGE = "system-image"; //$NON-NLS-1$
+
+ /* An included-ABI element for a system-image package. */
+ public static final String NODE_ABI_INCLUDED = "included-abi"; //$NON-NLS-1$
+ /* An ABI element for a system-image package. */
+ public static final String NODE_ABI = "abi"; //$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 optional minimal platform-tools revision required by tool packages. */
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonsListConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonsListConstants.java
index b5b0249..6b4498f 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonsListConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonsListConstants.java
@@ -24,13 +24,6 @@ import java.io.InputStream;
*/
public class SdkAddonsListConstants {
- /** The canonical URL filename for addons-list XML files. */
- public static final String URL_DEFAULT_FILENAME = "addons_list-1.xml"; //$NON-NLS-1$
-
- /** The URL where to find the official addons list fle. */
- public static final String URL_ADDON_LIST =
- SdkRepoConstants.URL_GOOGLE_SDK_SITE + URL_DEFAULT_FILENAME;
-
/** The base of our sdk-addons-list XML namespace. */
private static final String NS_BASE =
"http://schemas.android.com/sdk/android/addons-list/"; //$NON-NLS-1$
@@ -43,17 +36,30 @@ public class SdkAddonsListConstants {
/** The latest version of the sdk-addons-list XML Schema.
* Valid version numbers are between 1 and this number, included. */
- public static final int NS_LATEST_VERSION = 1;
+ public static final int NS_LATEST_VERSION = 2;
/** The XML namespace of the latest sdk-addons-list XML. */
public static final String NS_URI = getSchemaUri(NS_LATEST_VERSION);
+
+ /** The canonical URL filename for addons-list XML files. */
+ public static final String URL_DEFAULT_FILENAME = getDefaultName(NS_LATEST_VERSION);
+
+ /** The URL where to find the official addons list fle. */
+ public static final String URL_ADDON_LIST =
+ SdkRepoConstants.URL_GOOGLE_SDK_SITE + URL_DEFAULT_FILENAME;
+
+
+
/** The root sdk-addons-list element */
public static final String NODE_SDK_ADDONS_LIST = "sdk-addons-list"; //$NON-NLS-1$
/** An add-on site. */
public static final String NODE_ADDON_SITE = "addon-site"; //$NON-NLS-1$
+ /** A system image site. */
+ public static final String NODE_SYS_IMG_SITE = "sys-img-site"; //$NON-NLS-1$
+
/** The UI-visible name of the add-on site. */
public static final String NODE_NAME = "name"; //$NON-NLS-1$
@@ -84,7 +90,7 @@ public class SdkAddonsListConstants {
* null if there is no schema for the requested version.
*/
public static InputStream getXsdStream(int version) {
- String filename = String.format("sdk-addons-list-%d.xsd", version); //$NON-NLS-1$
+ String filename = String.format("sdk-addons-list-%d.xsd", version); //$NON-NLS-1$
return SdkAddonsListConstants.class.getResourceAsStream(filename);
}
@@ -95,4 +101,8 @@ public class SdkAddonsListConstants {
public static String getSchemaUri(int version) {
return String.format(NS_BASE + "%d", version); //$NON-NLS-1$
}
+
+ public static String getDefaultName(int version) {
+ return String.format("addons_list-%1$d.xml", version); //$NON-NLS-1$
+ }
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
index 5ad6285..e45da76 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
@@ -107,16 +107,9 @@ public class SdkRepoConstants extends RepoConstants {
public static final String NODE_DOC = "doc"; //$NON-NLS-1$
/** A sample package. */
public static final String NODE_SAMPLE = "sample"; //$NON-NLS-1$
- /** A system-image package. */
- public static final String NODE_SYSTEM_IMAGE = "system-image"; //$NON-NLS-1$
/** A source package. */
public static final String NODE_SOURCE = "source"; //$NON-NLS-1$
- /* An included-ABI element for a system-image package. */
- public static final String NODE_ABI_INCLUDED = "included-abi"; //$NON-NLS-1$
- /* An ABI element for a system-image package. */
- public static final String NODE_ABI = "abi"; //$NON-NLS-1$
-
/**
* List of possible nodes in a repository XML. Used to populate options automatically
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkSysImgConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkSysImgConstants.java
new file mode 100755
index 0000000..cf84d60
--- /dev/null
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkSysImgConstants.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sdklib.repository;
+
+
+import com.android.sdklib.internal.repository.sources.SdkSource;
+
+import java.io.InputStream;
+
+/**
+ * Public constants for the sdk-sys-img XML Schema.
+ */
+public class SdkSysImgConstants extends RepoConstants {
+
+ /**
+ * The default name looked for by {@link SdkSource} when trying to load an
+ * sdk-sys-img XML if the URL doesn't match an existing resource.
+ */
+ public static final String URL_DEFAULT_FILENAME = "sys-img.xml"; //$NON-NLS-1$
+
+ /** The base of our sdk-sys-img XML namespace. */
+ private static final String NS_BASE =
+ "http://schemas.android.com/sdk/android/sys-img/"; //$NON-NLS-1$
+
+ /**
+ * The pattern of our sdk-sys-img XML namespace.
+ * Matcher's group(1) is the schema version (integer).
+ */
+ public static final String NS_PATTERN = NS_BASE + "([1-9][0-9]*)"; //$NON-NLS-1$
+
+ /**
+ * The latest version of the sdk-sys-img XML Schema.
+ * Valid version numbers are between 1 and this number, included.
+ */
+ public static final int NS_LATEST_VERSION = 1;
+
+ /** The XML namespace of the latest sdk-sys-img XML. */
+ public static final String NS_URI = getSchemaUri(NS_LATEST_VERSION);
+
+ /** The root sdk-sys-img element */
+ public static final String NODE_SDK_SYS_IMG = "sdk-sys-img"; //$NON-NLS-1$
+
+ /**
+ * List of possible nodes in a repository XML. Used to populate options automatically
+ * in the no-GUI mode.
+ */
+ public static final String[] NODES = {
+ NODE_SYSTEM_IMAGE,
+ };
+
+ /**
+ * Returns a stream to the requested {@code sdk-sys-img} XML Schema.
+ *
+ * @param version Between 1 and {@link #NS_LATEST_VERSION}, included.
+ * @return An {@link InputStream} object for the local XSD file or
+ * null if there is no schema for the requested version.
+ */
+ public static InputStream getXsdStream(int version) {
+ return getXsdStream(NODE_SDK_SYS_IMG, version);
+ }
+
+ /**
+ * Returns the URI of the sdk-sys-img schema for the given version number.
+ * @param version Between 1 and {@link #NS_LATEST_VERSION} included.
+ */
+ public static String getSchemaUri(int version) {
+ return String.format(NS_BASE + "%d", version); //$NON-NLS-1$
+ }
+}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-1.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-1.xsd
index ac2113c..176fb60 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-1.xsd
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-1.xsd
@@ -23,7 +23,7 @@
version="1">
<!--
- A simple list of add-ons site that is loaded by default by the SDK Manager.
+ A simple list of add-ons sites that is loaded by default by the SDK Manager.
-->
<xsd:element name="sdk-addons-list" type="sa1:addonsListType" />
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-2.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-2.xsd
new file mode 100755
index 0000000..dde7214
--- /dev/null
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addons-list-2.xsd
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<xsd:schema
+ targetNamespace="http://schemas.android.com/sdk/android/addons-list/2"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:sa1="http://schemas.android.com/sdk/android/addons-list/2"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1">
+
+ <!--
+ A simple list of add-ons sites that is loaded by default by the SDK Manager.
+
+ - v1: Defines <addon-site>
+ - v2: Adds support for <sys-img-site>
+ -->
+
+ <xsd:element name="sdk-addons-list" type="sa1:addonsListType" />
+
+ <xsd:complexType name="addonsListType">
+ <xsd:annotation>
+ <xsd:documentation>
+ A simple list of add-ons site.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="addon-site" type="sa1:addonSiteType" />
+ <xsd:element name="sys-img-site" type="sa1:sysImgSiteType" />
+ </xsd:choice>
+ </xsd:complexType>
+
+ <!-- The definition of an Add-on Site. -->
+
+ <xsd:complexType name="addonSiteType">
+ <xsd:annotation>
+ <xsd:documentation>An SDK add-on site.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:all>
+ <!-- The URL of the site.
+
+ This can be either the exact URL of the an XML resource conforming
+ to the latest sdk-addon-N.xsd schema, or it can be the URL of a
+ 'directory', in which case the manager will look for a resource
+ named 'addon.xml' at this location.
+
+ Examples:
+ http://www.example.com/android/my_addons.xml
+ or
+ http://www.example.com/android/
+
+ In the second example, the manager will actually look for:
+ http://www.example.com/android/addon.xml
+ -->
+ <xsd:element name="url" type="xsd:token" />
+
+ <!-- The UI-visible name of the add-on site. -->
+ <xsd:element name="name" type="xsd:normalizedString" />
+
+ </xsd:all>
+ </xsd:complexType>
+
+ <!-- The definition of an Sys-Img Site. -->
+
+ <xsd:complexType name="sysImgSiteType">
+ <xsd:annotation>
+ <xsd:documentation>An SDK sys-img site.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:all>
+ <!-- The URL of the site.
+
+ This can be either the exact URL of the an XML resource conforming
+ to the latest sdk-sys-img-N.xsd schema, or it can be the URL of a
+ 'directory', in which case the manager will look for a resource
+ named 'sysimg.xml' at this location.
+
+ Examples:
+ http://www.example.com/android/my_sys_img.xml
+ or
+ http://www.example.com/android/
+
+ In the second example, the manager will actually look for:
+ http://www.example.com/android/sysimg.xml
+ -->
+ <xsd:element name="url" type="xsd:token" />
+
+ <!-- The UI-visible name of the sys-img site. -->
+ <xsd:element name="name" type="xsd:normalizedString" />
+
+ </xsd:all>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-sys-img-1.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-sys-img-1.xsd
new file mode 100755
index 0000000..a19aa49
--- /dev/null
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-sys-img-1.xsd
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<xsd:schema
+ targetNamespace="http://schemas.android.com/sdk/android/sys-img/1"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:sdk="http://schemas.android.com/sdk/android/sys-img/1"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1">
+
+ <!-- The repository contains a collection of downloadable items known as
+ "packages". Each package has a type and various attributes and contains
+ a list of file "archives" that can be downloaded for specific OSes.
+
+ An Android Addon repository is a web site that contains an "addon.xml"
+ file that conforms to this XML Schema.
+
+ History:
+ - v1 is used by the SDK Updater in Tools r20. It is split out of the
+ main SDK Repository XML Schema and can only contain <system-image> packages.
+ -->
+
+ <xsd:element name="sdk-sys-img" type="sdk:repositoryType" />
+
+ <xsd:complexType name="repositoryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ The repository contains a collection of downloadable system images.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="system-image" type="sdk:systemImageType" />
+ <xsd:element name="license" type="sdk:licenseType" />
+ </xsd:choice>
+ </xsd:complexType>
+
+
+ <!-- The definition of a system image used by a platform. -->
+
+ <xsd:complexType name="systemImageType" >
+ <xsd:annotation>
+ <xsd:documentation>
+ System Image for a platform.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:all>
+ <!-- api-level+codename identifies the platform to which this system image belongs. -->
+
+ <!-- The Android API Level for the platform. An int > 0. -->
+ <xsd:element name="api-level" type="xsd:positiveInteger" />
+ <!-- The optional codename for this platform, if it's a preview. -->
+ <xsd:element name="codename" type="xsd:string" minOccurs="0" />
+
+ <!-- The revision, an int > 0, incremented each time a new
+ package is generated. -->
+ <xsd:element name="revision" type="xsd:positiveInteger" />
+
+ <!-- The ABI of the system emulated by this image. -->
+ <xsd:element name="abi" type="sdk:abiType" />
+
+ <!-- The optional license of this package. If present, users will have
+ to agree to it before downloading. -->
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
+ <!-- The optional description of this package. -->
+ <xsd:element name="description" type="xsd:string" minOccurs="0" />
+ <!-- The optional description URL of this package -->
+ <xsd:element name="desc-url" type="xsd:token" minOccurs="0" />
+ <!-- The optional release note for this package. -->
+ <xsd:element name="release-note" type="xsd:string" minOccurs="0" />
+ <!-- The optional release note URL of this package -->
+ <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" />
+
+ <!-- An optional element indicating the package is obsolete.
+ The string content is however currently not defined and ignored. -->
+ <xsd:element name="obsolete" type="xsd:string" minOccurs="0" />
+ </xsd:all>
+ </xsd:complexType>
+
+
+ <!-- The definition of the ABI supported by a platform's system image. -->
+
+ <xsd:simpleType name="abiType">
+ <xsd:annotation>
+ <xsd:documentation>The ABI of a platform's system image.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="armeabi" />
+ <xsd:enumeration value="armeabi-v7a" />
+ <xsd:enumeration value="x86" />
+ <xsd:enumeration value="mips" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <!-- The definition of a license to be referenced by the uses-license element. -->
+
+ <xsd:complexType name="licenseType">
+ <xsd:annotation>
+ <xsd:documentation>
+ A license definition. Such a license must be used later as a reference
+ using a uses-license element in one of the package elements.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string">
+ <xsd:attribute name="id" type="xsd:ID" />
+ <xsd:attribute name="type" type="xsd:token" fixed="text" />
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+
+ <!-- Type describing the license used by a package.
+ The license MUST be defined using a license node and referenced
+ using the ref attribute of the license element inside a package.
+ -->
+
+ <xsd:complexType name="usesLicenseType">
+ <xsd:annotation>
+ <xsd:documentation>
+ Describes the license used by a package. The license MUST be defined
+ using a license node and referenced using the ref attribute of the
+ license element inside a package.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:attribute name="ref" type="xsd:IDREF" />
+ </xsd:complexType>
+
+
+ <!-- A collection of files that can be downloaded for a given architecture.
+ The <archives> node is mandatory in the repository elements and the
+ collection must have at least one <archive> declared.
+ Each archive is a zip file that will be unzipped in a location that depends
+ on its package type.
+ -->
+
+ <xsd:complexType name="archivesType">
+ <xsd:annotation>
+ <xsd:documentation>
+ A collection of files that can be downloaded for a given architecture.
+ The &lt;archives&gt; node is mandatory in the repository packages and the
+ collection must have at least one &lt;archive&gt; declared.
+ Each archive is a zip file that will be unzipped in a location that depends
+ on its package type.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence minOccurs="1" maxOccurs="unbounded">
+ <!-- One archive file -->
+ <xsd:element name="archive">
+ <xsd:complexType>
+ <!-- Properties of the archive file -->
+ <xsd:all>
+ <!-- The size in bytes of the archive to download. -->
+ <xsd:element name="size" type="xsd:positiveInteger" />
+ <!-- The checksum of the archive file. -->
+ <xsd:element name="checksum" type="sdk:checksumType" />
+ <!-- The URL is an absolute URL if it starts with http://, https://
+ or ftp://. Otherwise it is relative to the parent directory that
+ contains this repository.xml -->
+ <xsd:element name="url" type="xsd:token" />
+ </xsd:all>
+
+ <!-- Attributes that identify the OS and architecture -->
+ <xsd:attribute name="os" use="required">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="any" />
+ <xsd:enumeration value="linux" />
+ <xsd:enumeration value="macosx" />
+ <xsd:enumeration value="windows" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="arch" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="any" />
+ <xsd:enumeration value="ppc" />
+ <xsd:enumeration value="x86" />
+ <xsd:enumeration value="x86_64" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+ <!-- The definition of a file checksum -->
+
+ <xsd:simpleType name="sha1Number">
+ <xsd:annotation>
+ <xsd:documentation>A SHA1 checksum.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:pattern value="([0-9a-fA-F]){40}"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:complexType name="checksumType">
+ <xsd:annotation>
+ <xsd:documentation>A file checksum, currently only SHA1.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleContent>
+ <xsd:extension base="sdk:sha1Number">
+ <xsd:attribute name="type" type="xsd:token" fixed="sha1" />
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+</xsd:schema>