aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2012-02-11 00:08:59 -0800
committerRaphael <raphael@google.com>2012-02-15 10:34:55 -0800
commit957ac03267ebc574c1389fd0c7f672c9a3a111a3 (patch)
tree0aee1b4bbcd46df0516517cc0767f78c608c1ecc /sdkmanager/libs
parent696a2e8896cf79749a5fb429331adf5b1b64d874 (diff)
downloadsdk-957ac03267ebc574c1389fd0c7f672c9a3a111a3.zip
sdk-957ac03267ebc574c1389fd0c7f672c9a3a111a3.tar.gz
sdk-957ac03267ebc574c1389fd0c7f672c9a3a111a3.tar.bz2
SDK Repository: vendor id/display name for extras.
SDK Bug: 21942, part 1 of 2. Change-Id: Id9c026965b365e57302c56620f4ec8f88573d633
Diffstat (limited to 'sdkmanager/libs')
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java14
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ArchiveInstaller.java7
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java264
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java2
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java2
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/PkgProps.java10
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java17
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonConstants.java5
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java1
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-4.xsd403
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ArchiveInstallerTest.java32
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest_v3.java177
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest_v4.java (renamed from sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java)19
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java2
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkAddonSourceTest.java177
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java64
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java14
-rwxr-xr-xsdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_4.xml215
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java2
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java4
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java21
-rwxr-xr-xsdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java64
22 files changed, 1273 insertions, 243 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
index 4fa7c38..617ba42 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
@@ -354,6 +354,13 @@ public class Archive implements IDescription, Comparable<Archive> {
*/
@Override
public String getLongDescription() {
+ return String.format("%1$s\n%2$s\n%3$s",
+ getShortDescription(),
+ getSizeDescription(),
+ getSha1Description());
+ }
+
+ public String getSizeDescription() {
long size = getSize();
String sizeStr;
if (size < 1024) {
@@ -368,8 +375,11 @@ public class Archive implements IDescription, Comparable<Archive> {
Math.round(10.0 * size / (1024 * 1024 * 1024.0))/ 10.0);
}
- return String.format("%1$s\nSize: %2$s\nSHA1: %3$s",
- getShortDescription(), sizeStr, getChecksum());
+ return String.format("Size: %1$s", sizeStr);
+ }
+
+ public String getSha1Description() {
+ return String.format("SHA1: %1$s", getChecksum());
}
/**
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ArchiveInstaller.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ArchiveInstaller.java
index 911c475..9e50430 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ArchiveInstaller.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ArchiveInstaller.java
@@ -103,13 +103,6 @@ public class ArchiveInstaller {
File archiveFile = null;
String name = pkg.getShortDescription();
- if (pkg instanceof ExtraPackage && !((ExtraPackage) pkg).isPathValid()) {
- monitor.log("Skipping %1$s: %2$s is not a valid install path.",
- name,
- ((ExtraPackage) pkg).getPath());
- return false;
- }
-
if (newArchive.isLocal()) {
// This should never happen.
monitor.log("Skipping already installed archive: %1$s for %2$s",
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 4bcaa6d..b7c416c 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
@@ -16,6 +16,7 @@
package com.android.sdklib.internal.repository;
+import com.android.annotations.Nullable;
import com.android.annotations.VisibleForTesting;
import com.android.annotations.VisibleForTesting.Visibility;
import com.android.sdklib.NullSdkLog;
@@ -42,18 +43,22 @@ public class ExtraPackage extends MinToolsPackage
implements IMinApiLevelDependency {
/**
- * The vendor folder name. It must be a non-empty single-segment path.
- * <p/>
- * The paths "add-ons", "platforms", "platform-tools", "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.
+ * The extra display name. Used in the UI to represent the package. It can be anything.
+ */
+ private final String mDisplayName;
+
+ /**
+ * The vendor id name. It is a simple alphanumeric string [a-zA-Z0-9_-].
*/
- private final String mVendor;
+ private final String mVendorId;
/**
- * The sub-folder name. It must be a non-empty single-segment path and has the same
- * rules as {@link #mVendor}.
+ * The vendor display name. Used in the UI to represent the vendor. It can be anything.
+ */
+ private final String mVendorDisplay;
+
+ /**
+ * The sub-folder name. It must be a non-empty single-segment path.
*/
private final String mPath;
@@ -85,14 +90,49 @@ public class ExtraPackage extends MinToolsPackage
* parameters that vary according to the originating XML schema.
* @param licenses The licenses loaded from the XML originating document.
*/
- ExtraPackage(SdkSource source, Node packageNode, String nsUri, Map<String,String> licenses) {
+ ExtraPackage(
+ SdkSource source,
+ Node packageNode,
+ String nsUri,
+ Map<String,String> licenses) {
super(source, packageNode, nsUri, licenses);
mPath = XmlParserUtils.getXmlString(packageNode, RepoConstants.NODE_PATH);
- mVendor = XmlParserUtils.getXmlString(packageNode, RepoConstants.NODE_VENDOR);
- mMinApiLevel = XmlParserUtils.getXmlInt(packageNode, RepoConstants.NODE_MIN_API_LEVEL,
- MIN_API_LEVEL_NOT_SPECIFIED);
+ // Read name-display, vendor-display and vendor-id, introduced in addon-4.xsd.
+ // These are not optional, they are mandatory in addon-4 but we still treat them
+ // as optional so that we can fallback on using <vendor> which was the only one
+ // defined in addon-3.xsd.
+ String name = XmlParserUtils.getXmlString(packageNode, RepoConstants.NODE_NAME_DISPLAY);
+ String vname = XmlParserUtils.getXmlString(packageNode, RepoConstants.NODE_VENDOR_DISPLAY);
+ String vid = XmlParserUtils.getXmlString(packageNode, RepoConstants.NODE_VENDOR_ID);
+
+ if (vid.length() == 0) {
+ // If vid is missing, use the old <vendor> attribute.
+ // Note that in a valid XML, vendor-id cannot be an empty string.
+ // The only reason vid can be empty is when <vendor-id> is missing, which
+ // happens in an addon-3 schema, in which case the old <vendor> needs to be used.
+ String vendor = XmlParserUtils.getXmlString(packageNode, RepoConstants.NODE_VENDOR);
+ vid = sanitizeLegacyVendor(vendor);
+ if (vname.length() == 0) {
+ vname = vendor;
+ }
+ }
+ if (vname.length() == 0) {
+ // The vendor-display name can be empty, in which case we use the vendor-id.
+ vname = vid;
+ }
+ mVendorDisplay = vname;
+ mVendorId = vid;
+
+ if (name.length() == 0) {
+ // If name is missing, use the <path> attribute as done in an addon-3 schema.
+ name = getPrettyName();
+ }
+ mDisplayName = name;
+
+ mMinApiLevel = XmlParserUtils.getXmlInt(
+ packageNode, RepoConstants.NODE_MIN_API_LEVEL, MIN_API_LEVEL_NOT_SPECIFIED);
mProjectFiles = parseProjectFiles(
XmlParserUtils.getFirstChild(packageNode, RepoConstants.NODE_PROJECT_FILES));
@@ -146,30 +186,18 @@ public class ExtraPackage extends MinToolsPackage
String archiveOsPath) {
ExtraPackage ep = new ExtraPackage(source, props, vendor, path, revision, license,
description, descUrl, archiveOs, archiveArch, archiveOsPath);
-
- if (ep.isPathValid()) {
- return ep;
- } else {
- String shortDesc = ep.getShortDescription() + " [*]"; //$NON-NLS-1$
-
- String longDesc = String.format(
- "Broken Extra Package: %1$s\n" +
- "[*] Package cannot be used due to error: Invalid install path %2$s",
- description,
- ep.getPath());
-
- BrokenPackage ba = new BrokenPackage(props, shortDesc, longDesc,
- ep.getMinApiLevel(),
- IExactApiLevelDependency.API_LEVEL_INVALID,
- archiveOsPath);
- return ba;
- }
+ return ep;
}
+ /**
+ * Constructor used to create a mock {@link ExtraPackage}.
+ * Most of the attributes here are optional.
+ * When not defined, they will be extracted from the {@code props} properties.
+ */
@VisibleForTesting(visibility=Visibility.PRIVATE)
protected ExtraPackage(SdkSource source,
Properties props,
- String vendor,
+ String vendorId,
String path,
int revision,
String license,
@@ -188,15 +216,36 @@ public class ExtraPackage extends MinToolsPackage
archiveArch,
archiveOsPath);
- // The vendor argument is not supposed to be empty. However this attribute did not
- // exist prior to schema repo-v3 and tools r8, which means we need to cope with a
- // lack of it when reading back old local repositories. In this case we allow an
- // empty string.
- mVendor = vendor != null ? vendor : getProperty(props, PkgProps.EXTRA_VENDOR, "");
-
// The path argument comes before whatever could be in the properties
mPath = path != null ? path : getProperty(props, PkgProps.EXTRA_PATH, path);
+ String name = getProperty(props, PkgProps.EXTRA_NAME_DISPLAY, "");
+ String vname = getProperty(props, PkgProps.EXTRA_VENDOR_DISPLAY, "");
+ String vid = vendorId != null ? vendorId :
+ getProperty(props, PkgProps.EXTRA_VENDOR_ID, "");
+
+ if (vid.length() == 0) {
+ // If vid is missing, use the old <vendor> attribute.
+ // <vendor> did not exist prior to schema repo-v3 and tools r8.
+ String vendor = getProperty(props, PkgProps.EXTRA_VENDOR, "");
+ vid = sanitizeLegacyVendor(vendor);
+ if (vname.length() == 0) {
+ vname = vendor;
+ }
+ }
+ if (vname.length() == 0) {
+ // The vendor-display name can be empty, in which case we use the vendor-id.
+ vname = vid;
+ }
+ mVendorDisplay = vname;
+ mVendorId = vid;
+
+ if (name.length() == 0) {
+ // If name is missing, use the <path> attribute as done in an addon-3 schema.
+ name = getPrettyName();
+ }
+ mDisplayName = name;
+
mOldPaths = getProperty(props, PkgProps.EXTRA_OLD_PATHS, null);
mMinApiLevel = Integer.parseInt(
@@ -226,9 +275,9 @@ public class ExtraPackage extends MinToolsPackage
super.saveProperties(props);
props.setProperty(PkgProps.EXTRA_PATH, mPath);
- if (mVendor != null) {
- props.setProperty(PkgProps.EXTRA_VENDOR, mVendor);
- }
+ props.setProperty(PkgProps.EXTRA_NAME_DISPLAY, mDisplayName);
+ props.setProperty(PkgProps.EXTRA_VENDOR_DISPLAY, mVendorDisplay);
+ props.setProperty(PkgProps.EXTRA_VENDOR_ID, mVendorId);
if (getMinApiLevel() != MIN_API_LEVEL_NOT_SPECIFIED) {
props.setProperty(PkgProps.EXTRA_MIN_API_LEVEL, Integer.toString(getMinApiLevel()));
@@ -296,32 +345,9 @@ public class ExtraPackage extends MinToolsPackage
}
/**
- * Static helper to check if a given vendor and path is acceptable for an "extra" package.
- */
- public boolean isPathValid() {
- return isSegmentValid(mVendor) && isSegmentValid(mPath);
- }
-
- private boolean isSegmentValid(String segment) {
- if (SdkConstants.FD_ADDONS.equals(segment) ||
- SdkConstants.FD_PLATFORMS.equals(segment) ||
- SdkConstants.FD_PLATFORM_TOOLS.equals(segment) ||
- SdkConstants.FD_TOOLS.equals(segment) ||
- SdkConstants.FD_DOCS.equals(segment) ||
- RepoConstants.FD_TEMP.equals(segment)) {
- return false;
- }
- return segment != null && segment.indexOf('/') == -1 && segment.indexOf('\\') == -1;
- }
-
- /**
* Returns the sanitized path folder name. It is a single-segment path.
* <p/>
* The package is installed in SDK/extras/vendor_name/path_name.
- * <p/>
- * 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.
*/
public String getPath() {
// The XSD specifies the XML vendor and path should only contain [a-zA-Z0-9]+
@@ -339,20 +365,28 @@ public class ExtraPackage extends MinToolsPackage
}
/**
- * Returns the sanitized vendor folder name. It is a single-segment path.
- * <p/>
- * The package is installed in SDK/extras/vendor_name/path_name.
- * <p/>
- * An empty string is returned in case of error.
+ * Returns the vendor id.
*/
- public String getVendor() {
+ public String getVendorId() {
+ return mVendorId;
+ }
+
+ public String getVendorDisplay() {
+ return mVendorDisplay;
+ }
+ public String getDisplayName() {
+ return mDisplayName;
+ }
+
+ /** Transforms the legacy vendor name into a usable vendor id. */
+ private String sanitizeLegacyVendor(String vendorDisplay) {
// The XSD specifies the XML vendor and path should only contain [a-zA-Z0-9]+
// and cannot be empty. Let's be defensive and enforce that anyway since things
// like "____" are still valid values that we don't want to allow.
- if (mVendor != null && mVendor.length() > 0) {
- String vendor = mVendor;
+ if (vendorDisplay != null && vendorDisplay.length() > 0) {
+ String vendor = vendorDisplay.trim();
// Sanitize the vendor
vendor = vendor.replaceAll("[^a-zA-Z0-9-]+", "_"); //$NON-NLS-1$
if (vendor.equals("_")) { //$NON-NLS-1$
@@ -364,17 +398,22 @@ public class ExtraPackage extends MinToolsPackage
}
return ""; //$NON-NLS-1$
+
}
+ /**
+ * Used to produce a suitable name-display based on the current {@link #mPath}
+ * and {@link #mVendorDisplay} in addon-3 schemas.
+ */
private String getPrettyName() {
String name = mPath;
// In the past, we used to save the extras in a folder vendor-path,
// and that "vendor" would end up in the path when we reload the extra from
// disk. Detect this and compensate.
- if (mVendor != null && mVendor.length() > 0) {
- if (name.startsWith(mVendor + "-")) { //$NON-NLS-1$
- name = name.substring(mVendor.length() + 1);
+ if (mVendorDisplay != null && mVendorDisplay.length() > 0) {
+ if (name.startsWith(mVendorDisplay + "-")) { //$NON-NLS-1$
+ name = name.substring(mVendorDisplay.length() + 1);
}
}
@@ -383,11 +422,11 @@ public class ExtraPackage extends MinToolsPackage
name = name.replaceAll("[ _\t\f-]+", " ").trim(); //$NON-NLS-1$ //$NON-NLS-2$
}
if (name == null || name.length() == 0) {
- name = "Unkown Extra";
+ name = "Unknown Extra";
}
- if (mVendor != null && mVendor.length() > 0) {
- name = mVendor + " " + name; //$NON-NLS-1$
+ if (mVendorDisplay != null && mVendorDisplay.length() > 0) {
+ name = mVendorDisplay + " " + name; //$NON-NLS-1$
name = name.replaceAll("[ _\t\f-]+", " ").trim(); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -422,7 +461,7 @@ public class ExtraPackage extends MinToolsPackage
@Override
public String installId() {
return String.format("extra-%1$s-%2$s", //$NON-NLS-1$
- getVendor(),
+ getVendorId(),
getPath());
}
@@ -433,8 +472,8 @@ public class ExtraPackage extends MinToolsPackage
*/
@Override
public String getListDescription() {
- String s = String.format("%1$s package%2$s",
- getPrettyName(),
+ String s = String.format("%1$s%2$s",
+ getDisplayName(),
isObsolete() ? " (Obsolete)" : ""); //$NON-NLS-2$
return s;
@@ -445,9 +484,8 @@ public class ExtraPackage extends MinToolsPackage
*/
@Override
public String getShortDescription() {
-
- String s = String.format("%1$s package, revision %2$d%3$s",
- getPrettyName(),
+ String s = String.format("%1$s, revision %2$d%3$s",
+ getDisplayName(),
getRevision(),
isObsolete() ? " (Obsolete)" : ""); //$NON-NLS-2$
@@ -462,15 +500,15 @@ public class ExtraPackage extends MinToolsPackage
*/
@Override
public String getLongDescription() {
- String s = getDescription();
- if (s == null || s.length() == 0) {
- s = String.format("Extra %1$s package by %2$s", getPath(), getVendor());
- }
+ String s = String.format("%1$s, revision %2$d%3$s\nBy %4$s",
+ getDisplayName(),
+ getRevision(),
+ isObsolete() ? " (Obsolete)" : "", //$NON-NLS-2$
+ getVendorDisplay());
- if (s.indexOf("revision") == -1) {
- s += String.format("\nRevision %1$d%2$s",
- getRevision(),
- isObsolete() ? " (Obsolete)" : ""); //$NON-NLS-2$
+ String d = getDescription();
+ if (d != null && d.length() > 0) {
+ s += "\n" + d; //$NON-NLS-1$
}
if (getMinToolsRevision() != MIN_TOOLS_REV_NOT_SPECIFIED) {
@@ -481,11 +519,15 @@ public class ExtraPackage extends MinToolsPackage
s += String.format("\nRequires SDK Platform Android API %1$s", getMinApiLevel());
}
- // For a local archive, also put the install path in the long description.
- // This should help users locate the extra on their drive.
File localPath = getLocalArchivePath();
if (localPath != null) {
+ // For a local archive, also put the install path in the long description.
+ // This should help users locate the extra on their drive.
s += String.format("\nLocation: %1$s", localPath.getAbsolutePath());
+ } else {
+ // For a non-installed archive, indicate where it would be installed.
+ s += String.format("\nInstall path: %1$s",
+ getInstallSubFolder(null/*sdk root*/).getPath());
}
return s;
@@ -497,7 +539,7 @@ public class ExtraPackage extends MinToolsPackage
* <p/>
* A "tool" package should always be located in SDK/tools.
*
- * @param osSdkRoot The OS path of the SDK root folder.
+ * @param osSdkRoot The OS path of the SDK root folder. Must NOT be null.
* @param sdkManager An existing SDK manager to list current platforms and addons.
* Not used in this implementation.
* @return A new {@link File} corresponding to the directory to use to install this package.
@@ -521,10 +563,22 @@ public class ExtraPackage extends MinToolsPackage
}
}
+ return getInstallSubFolder(osSdkRoot);
+ }
+
+ /**
+ * Computes the "sub-folder" install path, relative to the given SDK root.
+ * For an extra package, this is generally ".../extra/vendor-id/path".
+ *
+ * @param osSdkRoot The OS path of the SDK root folder if known.
+ * This CAN be null, in which case the path will start at /extra.
+ * @return Either /extra/vendor/path or sdk-root/extra/vendor-id/path.
+ */
+ private File getInstallSubFolder(@Nullable String osSdkRoot) {
// The /extras dir at the root of the SDK
File path = new File(osSdkRoot, SdkConstants.FD_EXTRAS);
- String vendor = getVendor();
+ String vendor = getVendorId();
if (vendor != null && vendor.length() > 0) {
path = new File(path, vendor);
}
@@ -547,8 +601,8 @@ public class ExtraPackage extends MinToolsPackage
int lenEpOldPaths = epOldPaths.length;
for (int indexEp = -1; indexEp < lenEpOldPaths; indexEp++) {
if (sameVendorAndPath(
- mVendor, mPath,
- ep.mVendor, indexEp < 0 ? ep.mPath : epOldPaths[indexEp])) {
+ mVendorId, mPath,
+ ep.mVendorId, indexEp < 0 ? ep.mPath : epOldPaths[indexEp])) {
return true;
}
}
@@ -557,8 +611,8 @@ public class ExtraPackage extends MinToolsPackage
int lenThisOldPaths = thisOldPaths.length;
for (int indexThis = -1; indexThis < lenThisOldPaths; indexThis++) {
if (sameVendorAndPath(
- mVendor, indexThis < 0 ? mPath : thisOldPaths[indexThis],
- ep.mVendor, ep.mPath)) {
+ mVendorId, indexThis < 0 ? mPath : thisOldPaths[indexThis],
+ ep.mVendorId, ep.mPath)) {
return true;
}
}
@@ -617,7 +671,7 @@ public class ExtraPackage extends MinToolsPackage
int pos = s.indexOf("|r:"); //$NON-NLS-1$
assert pos > 0;
s = s.substring(0, pos) +
- "|ve:" + getVendor() + //$NON-NLS-1$
+ "|ve:" + getVendorId() + //$NON-NLS-1$
"|pa:" + getPath() + //$NON-NLS-1$
s.substring(pos);
return s;
@@ -648,7 +702,7 @@ public class ExtraPackage extends MinToolsPackage
result = prime * result + mMinApiLevel;
result = prime * result + ((mPath == null) ? 0 : mPath.hashCode());
result = prime * result + Arrays.hashCode(mProjectFiles);
- result = prime * result + ((mVendor == null) ? 0 : mVendor.hashCode());
+ result = prime * result + ((mVendorDisplay == null) ? 0 : mVendorDisplay.hashCode());
return result;
}
@@ -677,11 +731,11 @@ public class ExtraPackage extends MinToolsPackage
if (!Arrays.equals(mProjectFiles, other.mProjectFiles)) {
return false;
}
- if (mVendor == null) {
- if (other.mVendor != null) {
+ if (mVendorDisplay == null) {
+ if (other.mVendorDisplay != null) {
return false;
}
- } else if (!mVendor.equals(other.mVendor)) {
+ } else if (!mVendorDisplay.equals(other.mVendorDisplay)) {
return false;
}
return true;
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
index 2e65388..661552b 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
@@ -235,7 +235,7 @@ public class LocalSdkParser {
dir.getName(), //path
0, //revision
null, //license
- "Tools", //description
+ null, //description
null, //descUrl
Os.getCurrentOs(), //archiveOs
Arch.getCurrentArch(), //archiveArch
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java
index f757bfb..7933602 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/SdkSource.java
@@ -826,7 +826,7 @@ public abstract class SdkSource implements IDescription, Comparable<SdkSource> {
if (SdkAddonConstants.NODE_ADD_ON.equals(name)) {
p = new AddonPackage(this, child, nsUri, licenses);
- } else if (RepoConstants.NODE_EXTRA.equals(name)) {
+ } else if (SdkAddonConstants.NODE_EXTRA.equals(name)) {
p = new ExtraPackage(this, child, nsUri, licenses);
} else if (!isAddonSource()) {
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/PkgProps.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/PkgProps.java
index d16a35f..579656a 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/PkgProps.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/PkgProps.java
@@ -47,7 +47,12 @@ public class PkgProps {
// AddonPackage
public static final String ADDON_NAME = "Addon.Name"; //$NON-NLS-1$
+ public static final String ADDON_NAME_ID = "Addon.NameId"; //$NON-NLS-1$
+ public static final String ADDON_NAME_DISPLAY = "Addon.NameDisplay"; //$NON-NLS-1$
+
public static final String ADDON_VENDOR = "Addon.Vendor"; //$NON-NLS-1$
+ public static final String ADDON_VENDOR_ID = "Addon.VendorId"; //$NON-NLS-1$
+ public static final String ADDON_VENDOR_DISPLAY = "Addon.VendorDisplay"; //$NON-NLS-1$
// DocPackage
@@ -55,9 +60,12 @@ public class PkgProps {
public static final String EXTRA_PATH = "Extra.Path"; //$NON-NLS-1$
public static final String EXTRA_OLD_PATHS = "Extra.OldPaths"; //$NON-NLS-1$
- public static final String EXTRA_VENDOR = "Extra.Vendor"; //$NON-NLS-1$
public static final String EXTRA_MIN_API_LEVEL = "Extra.MinApiLevel"; //$NON-NLS-1$
public static final String EXTRA_PROJECT_FILES = "Extra.ProjectFiles"; //$NON-NLS-1$
+ public static final String EXTRA_VENDOR = "Extra.Vendor"; //$NON-NLS-1$
+ public static final String EXTRA_VENDOR_ID = "Extra.VendorId"; //$NON-NLS-1$
+ public static final String EXTRA_VENDOR_DISPLAY = "Extra.VendorDisplay"; //$NON-NLS-1$
+ public static final String EXTRA_NAME_DISPLAY = "Extra.NameDisplay"; //$NON-NLS-1$
// ILayoutlibVersion
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 b7f8774..53db79f 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
@@ -25,9 +25,6 @@ import java.io.InputStream;
*/
public class RepoConstants {
- /** An extra package. */
- public static final String NODE_EXTRA = "extra"; //$NON-NLS-1$
-
/** The license definition. */
public static final String NODE_LICENSE = "license"; //$NON-NLS-1$
/** The optional uses-license for all packages or for a lib. */
@@ -60,10 +57,20 @@ public class RepoConstants {
public static final String NODE_API_LEVEL = "api-level"; //$NON-NLS-1$
/** The codename, a string, for platform packages. */
public static final String NODE_CODENAME = "codename"; //$NON-NLS-1$
- /** The vendor, a string, for add-on and extra packages. */
+ /** The *old* vendor, a string, for add-on and extra packages.
+ * Replaced by {@link #NODE_VENDOR_DISPLAY} and {@link #NODE_VENDOR_ID} in addon-v4.xsd. */
public static final String NODE_VENDOR = "vendor"; //$NON-NLS-1$
- /** The name, a string, for add-on packages or for libraries. */
+ /** The vendor display string, for add-on and extra packages. */
+ public static final String NODE_VENDOR_DISPLAY = "vendor-display"; //$NON-NLS-1$
+ /** The unique vendor id string, for add-on and extra packages. */
+ public static final String NODE_VENDOR_ID = "vendor-id"; //$NON-NLS-1$
+ /** The name, a string, for add-on packages or for libraries.
+ * Replaced by {@link #NODE_NAME_DISPLAY} and {@link #NODE_NAME_ID} in addon-v4.xsd. */
public static final String NODE_NAME = "name"; //$NON-NLS-1$
+ /** The name display string, for add-on packages or for libraries. */
+ public static final String NODE_NAME_DISPLAY = "name-display"; //$NON-NLS-1$
+ /** The unique name id string, for add-on packages or for libraries. */
+ public static final String NODE_NAME_ID = "name-id"; //$NON-NLS-1$
/** A layoutlib package. */
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonConstants.java
index 122d40a..4c7fadb 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkAddonConstants.java
@@ -42,7 +42,7 @@ public class SdkAddonConstants extends RepoConstants {
/** The latest version of the sdk-addon XML Schema.
* Valid version numbers are between 1 and this number, included. */
- public static final int NS_LATEST_VERSION = 3;
+ public static final int NS_LATEST_VERSION = 4;
/** The XML namespace of the latest sdk-addon XML. */
public static final String NS_URI = getSchemaUri(NS_LATEST_VERSION);
@@ -53,6 +53,9 @@ public class SdkAddonConstants extends RepoConstants {
/** An add-on package. */
public static final String NODE_ADD_ON = "add-on"; //$NON-NLS-1$
+ /** An extra package. */
+ public static final String NODE_EXTRA = "extra"; //$NON-NLS-1$
+
/**
* List of possible nodes in a repository XML. Used to populate options automatically
* in the no-GUI mode.
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 e04d285..31ec8c7 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/SdkRepoConstants.java
@@ -94,7 +94,6 @@ public class SdkRepoConstants extends RepoConstants {
NODE_PLATFORM_TOOL,
NODE_DOC,
NODE_SAMPLE,
- NODE_EXTRA,
NODE_SOURCE,
};
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-4.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-4.xsd
new file mode 100755
index 0000000..b8d95f2
--- /dev/null
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-4.xsd
@@ -0,0 +1,403 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright (C) 2011 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/addon/4"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:sdk="http://schemas.android.com/sdk/android/addon/4"
+ 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 r8. It is split out of the
+ main SDK Repository XML Schema and can only contain <addon> and
+ <extra> packages.
+
+ - v2 is used by the SDK Updater in Tools r12.
+ - <extra> element now has a <project-files> element that contains 1 or
+ or more <path>, each indicating the relative path of a file that this package
+ can contribute to installed projects.
+ - <addon> element now has an optional <layoutlib> that indicates the API
+ and revision of the layout library for this particular add-on, if any.
+
+ - v3 is used by the SDK Updater in Tools R14:
+ - <extra> now has an <old-paths> element, a ;-separated list of old paths that
+ should be detected and migrated to the new <path> for that package.
+ -->
+
+ <xsd:element name="sdk-addon" type="sdk:repositoryType" />
+
+ <xsd:complexType name="repositoryType">
+ <xsd:annotation>
+ <xsd:documentation>
+ The repository contains a collection of downloadable packages.
+ </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:choice>
+ </xsd:complexType>
+
+ <!-- The definition of an SDK Add-on package. -->
+
+ <xsd:complexType name="addonType">
+ <xsd:annotation>
+ <xsd:documentation>An SDK add-on package.</xsd:documentation>
+ </xsd:annotation>
+ <xsd:all>
+ <!-- The name of the add-on. -->
+ <xsd:element name="name" type="xsd:normalizedString" />
+ <!-- The vendor of the add-on. -->
+ <xsd:element name="vendor" type="xsd:normalizedString" />
+
+ <!-- TODO The next CL will deal with addon properties.
+ <!- - The internal name id of the add-on. Must be unique per vendor. - ->
+ <xsd:element name="name-id" type="sdk:idType" />
+ <!- - The displayed name of the add-on. - ->
+ <xsd:element name="name-display" type="xsd:normalizedString" />
+
+ <!- - The internal vendor id of the add-on. Must be unique amongst vendors. - ->
+ <xsd:element name="vendor-id" type="sdk:idType" />
+ <!- - The displayed vendor name of the add-on. - ->
+ <xsd:element name="vendor-display" type="xsd:normalizedString" />
+ -->
+
+ <!-- The Android API Level for the add-on. An int > 0. -->
+ <xsd:element name="api-level" type="xsd:positiveInteger" />
+ <!-- Note: Add-ons do not support 'codenames' (a.k.a. API previews). -->
+ <!-- The revision, an int > 0, incremented each time a new
+ package is generated. -->
+ <xsd:element name="revision" type="xsd:positiveInteger" />
+
+ <!-- An add-on can declare 0 or more libraries.
+ This element is mandatory but it can be empty.
+ -->
+
+ <xsd:element name="libs">
+ <xsd:complexType>
+ <xsd:sequence minOccurs="0" maxOccurs="unbounded">
+ <xsd:element name="lib">
+ <xsd:complexType>
+ <xsd:all>
+ <!-- The name of the library. -->
+ <xsd:element name="name" type="xsd:normalizedString" />
+ <!-- The optional description of this add-on library. -->
+ <xsd:element name="description" type="xsd:string" minOccurs="0" />
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- optional elements -->
+
+ <!-- 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" />
+
+ <!-- Optional information on the layoutlib packaged in this platform. -->
+ <xsd:element name="layoutlib" type="sdk:layoutlibType" minOccurs="0" />
+ </xsd:all>
+ </xsd:complexType>
+
+
+ <xsd:simpleType name="idType">
+ <xsd:annotation>
+ <xsd:documentation>
+ An ID string for an addon/extra name-id or vendor-id
+ can only be simple alphanumeric string.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[a-zA-Z0-9_-]+"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <!-- The definition of a layout library used by an addon. -->
+
+ <xsd:complexType name="layoutlibType" >
+ <xsd:annotation>
+ <xsd:documentation>
+ Version information for a layoutlib included in an addon.
+ .</xsd:documentation>
+ </xsd:annotation>
+ <xsd:all>
+ <!-- The layoutlib API level, an int > 0,
+ incremented with each new incompatible lib. -->
+ <xsd:element name="api" type="xsd:positiveInteger" />
+ <!-- The incremental minor revision for that API, e.g. in case of bug fixes.
+ Optional. An int >= 0, assumed to be 0 if the element is missing. -->
+ <xsd:element name="revision" type="xsd:nonNegativeInteger" minOccurs="0" />
+ </xsd:all>
+ </xsd:complexType>
+
+
+ <!-- The definition of an SDK extra package. This kind of package is for
+ "free" content. Such packages are installed in SDK/extras/vendor/path.
+ -->
+
+ <xsd:complexType name="extraType" >
+ <xsd:annotation>
+ <xsd:documentation>
+ An SDK extra package. This kind of package is for "free" content.
+ Such packages are installed in SDK/vendor/path.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:all>
+ <!-- The displayed name of the extra. -->
+ <xsd:element name="name-display" type="xsd:normalizedString" />
+
+ <!-- The internal vendor id of the extra. Must be unique amongst vendors. -->
+ <xsd:element name="vendor-id" type="sdk:idType" />
+ <!-- The displayed vendor name of the extra. -->
+ <xsd:element name="vendor-display" type="xsd:normalizedString" />
+
+ <!-- The install path sub-folder name. It must not be empty. -->
+ <xsd:element name="path" type="sdk:segmentType" />
+
+ <!-- A semi-colon separated list of "obsolete" path names which are equivalent
+ to the current 'path' name. When a package is seen using an old-paths' name,
+ the package manager will try to upgrade it to the new path. -->
+ <xsd:element name="old-paths" type="sdk:segmentListType" minOccurs="0" />
+
+ <!-- The revision, an int > 0, incremented each time a new
+ package is generated. -->
+ <xsd:element name="revision" type="xsd:positiveInteger" />
+
+ <!-- A list of file archives for this package. -->
+ <xsd:element name="archives" type="sdk:archivesType" />
+
+ <!-- optional elements -->
+
+ <!-- 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" />
+ <!-- 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" />
+ <!-- The minimal API level required by this package.
+ Optional. If present, must be an int > 0. -->
+ <xsd:element name="min-api-level" type="xsd:positiveInteger" minOccurs="0" />
+ <!-- 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" />
+
+ <!-- A list of project files contributed by this package. Optional. -->
+ <xsd:element name="project-files" type="sdk:projectFilesType" minOccurs="0" />
+ </xsd:all>
+ </xsd:complexType>
+
+
+ <!-- The definition of a path segment used by the extra element. -->
+
+ <xsd:simpleType name="segmentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ One path segment for the install path of an extra element.
+ It must be a single-segment path. It must not be empty.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[a-zA-Z0-9_]+"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="segmentListType">
+ <xsd:annotation>
+ <xsd:documentation>
+ A semi-colon separated list of a segmentTypes.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[a-zA-Z0-9_;]+"/>
+ </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>
+
+
+ <!-- A collection of file paths available in an &lt;extra&gt; package
+ that can be installed in an Android project.
+ If present, the &lt;project-files&gt; collection must contain at least one path.
+ Each path is relative to the root directory of the package.
+ -->
+
+ <xsd:complexType name="projectFilesType">
+ <xsd:annotation>
+ <xsd:documentation>
+ A collection of file paths available in an &lt;extra&gt; package
+ that can be installed in an Android project.
+ If present, the &lt;project-files&gt; collection must contain at least one path.
+ Each path is relative to the root directory of the package.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence minOccurs="1" maxOccurs="unbounded">
+ <!-- One JAR Path, relative to the root folder of the package. -->
+ <xsd:element name="path" type="xsd:string" />
+ </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>
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ArchiveInstallerTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ArchiveInstallerTest.java
index 91fc2e6..46390b5 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ArchiveInstallerTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ArchiveInstallerTest.java
@@ -108,7 +108,7 @@ public class ArchiveInstallerTest extends TestCase {
/** Test we can install a simple new archive. */
public void testInstall_NewArchive() throws Exception {
- SdkSource src1 = new SdkRepoSource("http://repo.com/url", "repo1");
+ SdkSource src1 = new SdkRepoSource("http://repo.example.com/url", "repo1");
MockEmptyPackage p = createRemoteEmptyPackage(src1, "testPkg");
ArchiveReplacement ar = new ArchiveReplacement(p.getArchives()[0], null /*replaced*/);
@@ -133,7 +133,7 @@ public class ArchiveInstallerTest extends TestCase {
"Archive.Os=ANY\n" +
"Pkg.Revision=0\n" +
"Archive.Arch=ANY\n" +
- "Pkg.SourceUrl=http\\://repo.com/url\n" +
+ "Pkg.SourceUrl=http\\://repo.example.com/url\n" +
"'>]",
stripDate(Arrays.toString(mFile.getOutputStreams())));
@@ -145,7 +145,7 @@ public class ArchiveInstallerTest extends TestCase {
/** Test we can replace and rename an Extra package. */
public void testInstall_InstallExtraArchive() throws Exception {
- SdkSource src1 = new SdkRepoSource("http://repo.com/url", "repo1");
+ SdkSource src1 = new SdkRepoSource("http://repo.example.com/url", "repo1");
MockExtraPackage newPkg = createRemoteExtraPackage(src1, "vendor1", "oldPath", 2, 1);
MockExtraPackage oldPkg = new MockExtraPackage(src1, "vendor1", "oldPath", 1, 1);
@@ -181,26 +181,28 @@ public class ArchiveInstallerTest extends TestCase {
"[</sdk/extras/vendor1/oldPath/source.properties: " +
"'### Android Tool: Source of this archive.\n" +
"#...date...\n" +
- "Extra.Vendor=vendor1\n" +
+ "Extra.VendorDisplay=vendor1\n" +
"Pkg.Desc=desc\n" +
+ "Extra.Path=oldPath\n" +
+ "Archive.Arch=ANY\n" +
"Pkg.DescUrl=url\n" +
+ "Extra.NameDisplay=Vendor1 OldPath\n" +
"Archive.Os=ANY\n" +
+ "Pkg.SourceUrl=http\\://repo.example.com/url\n" +
"Pkg.Revision=2\n" +
- "Archive.Arch=ANY\n" +
- "Extra.Path=oldPath\n" +
- "Pkg.SourceUrl=http\\://repo.com/url\n" +
+ "Extra.VendorId=vendor1\n" +
"'>]"),
stripDate(Arrays.toString(mFile.getOutputStreams())));
assertEquals(
- "Installing Vendor1 OldPath package, revision 2\n" +
- "Installed Vendor1 OldPath package, revision 2\n",
+ "Installing Vendor1 OldPath, revision 2\n" +
+ "Installed Vendor1 OldPath, revision 2\n",
mMon.getCapturedLog());
}
/** Test we can replace and rename an Extra package. */
public void testInstall_InstallRenamedExtraArchive() throws Exception {
- SdkSource src1 = new SdkRepoSource("http://repo.com/url", "repo1");
+ SdkSource src1 = new SdkRepoSource("http://repo.example.com/url", "repo1");
MockExtraPackage newPkg = createRemoteExtraPackage(
src1,
@@ -254,21 +256,23 @@ public class ArchiveInstallerTest extends TestCase {
"[</sdk/extras/vendor1/newPath/source.properties: " +
"'### Android Tool: Source of this archive.\n" +
"#...date...\n" +
+ "Extra.VendorDisplay=vendor1\n" +
"Pkg.Desc=desc\n" +
"Extra.OldPaths=oldPath\n" +
- "Extra.Vendor=vendor1\n" +
"Extra.Path=newPath\n" +
"Archive.Arch=ANY\n" +
"Pkg.DescUrl=url\n" +
+ "Extra.NameDisplay=Vendor1 NewPath\n" +
"Archive.Os=ANY\n" +
- "Pkg.SourceUrl=http\\://repo.com/url\n" +
+ "Pkg.SourceUrl=http\\://repo.example.com/url\n" +
"Pkg.Revision=2\n" +
+ "Extra.VendorId=vendor1\n" +
"'>]"),
stripDate(Arrays.toString(mFile.getOutputStreams())));
assertEquals(
- "Installing Vendor1 NewPath package, revision 2\n" +
- "Installed Vendor1 NewPath package, revision 2\n",
+ "Installing Vendor1 NewPath, revision 2\n" +
+ "Installed Vendor1 NewPath, revision 2\n",
mMon.getCapturedLog());
}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest_v3.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest_v3.java
new file mode 100755
index 0000000..c895fc9
--- /dev/null
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest_v3.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2011 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;
+
+import com.android.sdklib.internal.repository.Archive.Arch;
+import com.android.sdklib.internal.repository.Archive.Os;
+import com.android.sdklib.repository.PkgProps;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Properties;
+
+/**
+ * Tests {@link ExtraPackage} using anddon-3.xsd: it has a {@code <path>} and {@code <vendor>}.
+ * (it lacks name-display, vendor-id and vendor-display with are in addon-4.xsd)
+ */
+public class ExtraPackageTest_v3 extends MinToolsPackageTest {
+
+ private static final char PS = File.pathSeparatorChar;
+
+ private ExtraPackage createExtraPackage(Properties props) {
+ ExtraPackage p = (ExtraPackage) ExtraPackage.create(
+ null, //source
+ props,
+ null, //vendor
+ null, //path
+ -1, //revision
+ null, //license
+ null, //description
+ null, //descUrl
+ Os.ANY, //archiveOs
+ Arch.ANY, //archiveArch
+ "/local/archive/path" //archiveOsPath
+ );
+ return p;
+ }
+
+ /** Properties used to "load" the package. When saved, they become different. */
+ private Properties createLoadedProps() {
+ Properties props = super.createProps();
+
+ // ExtraPackage properties
+ props.setProperty(PkgProps.EXTRA_VENDOR, "vendor");
+ props.setProperty(PkgProps.EXTRA_PATH, "the_path");
+ props.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;oldpath2");
+ props.setProperty(PkgProps.EXTRA_MIN_API_LEVEL, "11");
+ props.setProperty(PkgProps.EXTRA_PROJECT_FILES,
+ "path1.jar" + PS + "dir2/jar 2.jar" + PS + "dir/3/path");
+
+ return props;
+ }
+
+ /** Properties saved by the package. They differ from loaded ones in name and vendor. */
+ private Properties createSavedProps() {
+ Properties props = super.createProps();
+
+ // ExtraPackage properties
+ props.setProperty(PkgProps.EXTRA_VENDOR_ID, "vendor");
+ props.setProperty(PkgProps.EXTRA_VENDOR_DISPLAY, "vendor");
+ props.setProperty(PkgProps.EXTRA_NAME_DISPLAY, "Vendor The Path");
+ props.setProperty(PkgProps.EXTRA_PATH, "the_path");
+ props.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;oldpath2");
+ props.setProperty(PkgProps.EXTRA_MIN_API_LEVEL, "11");
+ props.setProperty(PkgProps.EXTRA_PROJECT_FILES,
+ "path1.jar" + PS + "dir2/jar 2.jar" + PS + "dir/3/path");
+
+ return props;
+ }
+
+ protected void testCreatedExtraPackage(ExtraPackage p) {
+ super.testCreatedPackage(p);
+
+ // Package properties
+ // vendor becomes both vendor-id and vendor-display
+ assertEquals("vendor", p.getVendorId());
+ assertEquals("vendor", p.getVendorDisplay());
+ assertEquals("the_path", p.getPath());
+ // path and vendor are combined in the default display name
+ assertEquals("Vendor The Path", p.getDisplayName());
+ assertEquals("[old_path1, oldpath2]", Arrays.toString(p.getOldPaths()));
+ assertEquals(11, p.getMinApiLevel());
+ assertEquals(
+ "[path1.jar, dir2/jar 2.jar, dir/3/path]",
+ Arrays.toString(p.getProjectFiles()));
+ }
+
+ // ----
+
+ @Override
+ public final void testCreate() {
+ Properties props = createLoadedProps();
+ ExtraPackage p = createExtraPackage(props);
+
+ testCreatedExtraPackage(p);
+ }
+
+ @Override
+ public void testSaveProperties() {
+ Properties props = createLoadedProps();
+ ExtraPackage p = createExtraPackage(props);
+
+ Properties props2 = new Properties();
+ p.saveProperties(props2);
+
+ assertEquals(props2, createSavedProps());
+ }
+
+ public void testSameItemAs() {
+ Properties props1 = createLoadedProps();
+ ExtraPackage p1 = createExtraPackage(props1);
+ assertTrue(p1.sameItemAs(p1));
+
+ // different vendor, same path
+ Properties props2 = new Properties(props1);
+ props2.setProperty(PkgProps.EXTRA_VENDOR, "vendor2");
+ ExtraPackage p2 = createExtraPackage(props2);
+ assertFalse(p1.sameItemAs(p2));
+ assertFalse(p2.sameItemAs(p1));
+
+ // different vendor, different path
+ props2.setProperty(PkgProps.EXTRA_PATH, "new_path2");
+ p2 = createExtraPackage(props2);
+ assertFalse(p1.sameItemAs(p2));
+ assertFalse(p2.sameItemAs(p1));
+
+ // same vendor, but single path using the old paths from p1
+ Properties props3 = new Properties(props1);
+ props3.setProperty(PkgProps.EXTRA_OLD_PATHS, "");
+ props3.setProperty(PkgProps.EXTRA_PATH, "old_path1");
+ ExtraPackage p3 = createExtraPackage(props3);
+ assertTrue(p1.sameItemAs(p3));
+ assertTrue(p3.sameItemAs(p1));
+
+ props3.setProperty(PkgProps.EXTRA_PATH, "oldpath2");
+ p3 = createExtraPackage(props3);
+ assertTrue(p1.sameItemAs(p3));
+ assertTrue(p3.sameItemAs(p1));
+
+ // same vendor, different old paths but there's a path=>old_path match
+ Properties props4 = new Properties(props1);
+ props4.setProperty(PkgProps.EXTRA_OLD_PATHS, "new_path4;new_path5");
+ props4.setProperty(PkgProps.EXTRA_PATH, "old_path1");
+ ExtraPackage p4 = createExtraPackage(props4);
+ assertTrue(p1.sameItemAs(p4));
+ assertTrue(p4.sameItemAs(p1));
+
+ // same vendor, incompatible paths
+ Properties props5 = new Properties(props1);
+ // and the only match is between old_paths, which doesn't count.
+ props5.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;new_path5");
+ props5.setProperty(PkgProps.EXTRA_PATH, "new_path4");
+ ExtraPackage p5 = createExtraPackage(props5);
+ assertFalse(p1.sameItemAs(p5));
+ assertFalse(p5.sameItemAs(p1));
+ }
+
+ public void testInstallId() {
+ Properties props = createLoadedProps();
+ ExtraPackage p = createExtraPackage(props);
+
+ assertEquals("extra-vendor-the_path", p.installId());
+ }
+}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest_v4.java
index 230e366..19e50f0 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/ExtraPackageTest_v4.java
@@ -24,7 +24,11 @@ import java.io.File;
import java.util.Arrays;
import java.util.Properties;
-public class ExtraPackageTest extends MinToolsPackageTest {
+/**
+ * Tests {@link ExtraPackage} using anddon-4.xsd:
+ * it has name-display, vendor-id and vendor-display.
+ */
+public class ExtraPackageTest_v4 extends MinToolsPackageTest {
private static final char PS = File.pathSeparatorChar;
@@ -50,7 +54,9 @@ public class ExtraPackageTest extends MinToolsPackageTest {
Properties props = super.createProps();
// ExtraPackage properties
- props.setProperty(PkgProps.EXTRA_VENDOR, "vendor");
+ props.setProperty(PkgProps.EXTRA_VENDOR_ID, "the_vendor");
+ props.setProperty(PkgProps.EXTRA_VENDOR_DISPLAY, "The Company, Inc.");
+ props.setProperty(PkgProps.EXTRA_NAME_DISPLAY, "Some Extra Package");
props.setProperty(PkgProps.EXTRA_PATH, "the_path");
props.setProperty(PkgProps.EXTRA_OLD_PATHS, "old_path1;oldpath2");
props.setProperty(PkgProps.EXTRA_MIN_API_LEVEL, "11");
@@ -64,7 +70,9 @@ public class ExtraPackageTest extends MinToolsPackageTest {
super.testCreatedPackage(p);
// Package properties
- assertEquals("vendor", p.getVendor());
+ assertEquals("the_vendor", p.getVendorId());
+ assertEquals("The Company, Inc.", p.getVendorDisplay());
+ assertEquals("Some Extra Package", p.getDisplayName());
assertEquals("the_path", p.getPath());
assertEquals("[old_path1, oldpath2]", Arrays.toString(p.getOldPaths()));
assertEquals(11, p.getMinApiLevel());
@@ -101,7 +109,8 @@ public class ExtraPackageTest extends MinToolsPackageTest {
// different vendor, same path
Properties props2 = new Properties(props1);
- props2.setProperty(PkgProps.EXTRA_VENDOR, "vendor2");
+ props2.setProperty(PkgProps.EXTRA_VENDOR_ID, "vendor2");
+ props2.setProperty(PkgProps.EXTRA_VENDOR_DISPLAY, "Another Vendor Name");
ExtraPackage p2 = createExtraPackage(props2);
assertFalse(p1.sameItemAs(p2));
assertFalse(p2.sameItemAs(p1));
@@ -147,6 +156,6 @@ public class ExtraPackageTest extends MinToolsPackageTest {
Properties props = createProps();
ExtraPackage p = createExtraPackage(props);
- assertEquals("extra-vendor-the_path", p.installId());
+ assertEquals("extra-the_vendor-the_path", p.installId());
}
}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java
index ab560f6..717877b 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/PackageTest.java
@@ -189,7 +189,7 @@ public class PackageTest extends TestCase {
"Intel x86 Atom System Image, Android API 1, revision 4, " +
"addon by vendor 1, Android API 1, revision 3, " +
"Broken package for API 1, " +
- "Vendor Path package, revision 5]",
+ "Vendor Path, revision 5]",
Arrays.toString(list.toArray()));
}
}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkAddonSourceTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkAddonSourceTest.java
index c11ff0d..5ee62c0 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkAddonSourceTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkAddonSourceTest.java
@@ -145,9 +145,9 @@ public class SdkAddonSourceTest extends TestCase {
}
/**
- * Validate we can still load a valid add-on schema version 1
+ * Validate we can load a valid add-on schema version 1
*/
- public void testLoadOldXml_1() throws Exception {
+ public void testLoadAddonXml_1() throws Exception {
InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_1.xml");
// guess the version from the XML document
@@ -174,9 +174,9 @@ public class SdkAddonSourceTest extends TestCase {
assertEquals("Found My First add-on by John Doe, Android API 1, revision 1\n" +
"Found My Second add-on by John Deer, Android API 2, revision 42\n" +
"Found This add-on has no libraries by Joe Bar, Android API 4, revision 3\n" +
- "Found G USB Driver package, revision 43 (Obsolete)\n" +
- "Found Android Vendor Extra API Dep package, revision 2 (Obsolete)\n" +
- "Found Unkown Extra package, revision 2 (Obsolete)\n",
+ "Found G USB Driver, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" +
+ "Found Unknown Extra, revision 2 (Obsolete)\n",
monitor.getCapturedVerboseLog());
assertEquals("", monitor.getCapturedLog());
assertEquals("", monitor.getCapturedErrorLog());
@@ -199,16 +199,19 @@ public class SdkAddonSourceTest extends TestCase {
ArrayList<File> extraInstall = new ArrayList<File>();
for (Package p : pkgs) {
if (p instanceof ExtraPackage) {
- extraPaths.add(((ExtraPackage) p).getPath());
- extraVendors.add(((ExtraPackage) p).getVendor());
- extraInstall.add(((ExtraPackage) p).getInstallFolder(osSdkPath, sdkManager));
+ ExtraPackage ep = (ExtraPackage) p;
+ extraPaths.add(ep.getPath());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
+ extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
}
}
assertEquals(
"[extra_api_dep, usb_driver, extra0000005f]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[android_vendor, g, vendor0000005f]",
+ "[android_vendor/android_vendor, " +
+ "g/g, " +
+ "vendor0000005f/____]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
("[SDK/extras/android_vendor/extra_api_dep, " +
@@ -220,7 +223,7 @@ public class SdkAddonSourceTest extends TestCase {
/**
* Validate we can still load a valid add-on schema version 2
*/
- public void testLoadOldXml_2() throws Exception {
+ public void testLoadAddonXml_2() throws Exception {
InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_2.xml");
// guess the version from the XML document
@@ -247,9 +250,9 @@ public class SdkAddonSourceTest extends TestCase {
assertEquals("Found My First add-on by John Doe, Android API 1, revision 1\n" +
"Found My Second add-on by John Deer, Android API 2, revision 42\n" +
"Found This add-on has no libraries by Joe Bar, Android API 4, revision 3\n" +
- "Found G USB Driver package, revision 43 (Obsolete)\n" +
- "Found Android Vendor Extra API Dep package, revision 2 (Obsolete)\n" +
- "Found Unkown Extra package, revision 2 (Obsolete)\n",
+ "Found G USB Driver, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" +
+ "Found Unknown Extra, revision 2 (Obsolete)\n",
monitor.getCapturedVerboseLog());
assertEquals("", monitor.getCapturedLog());
assertEquals("", monitor.getCapturedErrorLog());
@@ -275,8 +278,8 @@ public class SdkAddonSourceTest extends TestCase {
}
assertEquals(
"[Pair [first=3, second=42], " + // for #3 "This add-on has no libraries"
- "Pair [first=0, second=0], " + // for #2 "My Second add-on"
- "Pair [first=5, second=0]]", // for #1 "My First add-on"
+ "Pair [first=0, second=0], " + // for #2 "My Second add-on"
+ "Pair [first=5, second=0]]", // for #1 "My First add-on"
Arrays.toString(layoutlibVers.toArray()));
@@ -290,16 +293,19 @@ public class SdkAddonSourceTest extends TestCase {
ArrayList<File> extraInstall = new ArrayList<File>();
for (Package p : pkgs) {
if (p instanceof ExtraPackage) {
- extraPaths.add(((ExtraPackage) p).getPath());
- extraVendors.add(((ExtraPackage) p).getVendor());
- extraInstall.add(((ExtraPackage) p).getInstallFolder(osSdkPath, sdkManager));
+ ExtraPackage ep = (ExtraPackage) p;
+ extraPaths.add(ep.getPath());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
+ extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
}
}
assertEquals(
"[extra_api_dep, usb_driver, extra0000005f]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[android_vendor, g, vendor0000005f]",
+ "[android_vendor/android_vendor, " +
+ "g/g, " +
+ "vendor0000005f/____]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
("[SDK/extras/android_vendor/extra_api_dep, " +
@@ -309,9 +315,9 @@ public class SdkAddonSourceTest extends TestCase {
}
/**
- * Validate we can still load a valid add-on schema version 3
+ * Validate we can load a valid add-on schema version 3
*/
- public void testLoadOldXml_3() throws Exception {
+ public void testLoadAddonXml_3() throws Exception {
InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_3.xml");
// guess the version from the XML document
@@ -338,9 +344,9 @@ public class SdkAddonSourceTest extends TestCase {
assertEquals("Found My First add-on by John Doe, Android API 1, revision 1\n" +
"Found My Second add-on by John Deer, Android API 2, revision 42\n" +
"Found This add-on has no libraries by Joe Bar, Android API 4, revision 3\n" +
- "Found G USB Driver package, revision 43 (Obsolete)\n" +
- "Found Android Vendor Extra API Dep package, revision 2 (Obsolete)\n" +
- "Found Unkown Extra package, revision 2 (Obsolete)\n",
+ "Found G USB Driver, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" +
+ "Found Unknown Extra, revision 2 (Obsolete)\n",
monitor.getCapturedVerboseLog());
assertEquals("", monitor.getCapturedLog());
assertEquals("", monitor.getCapturedErrorLog());
@@ -366,8 +372,8 @@ public class SdkAddonSourceTest extends TestCase {
}
assertEquals(
"[Pair [first=3, second=42], " + // for #3 "This add-on has no libraries"
- "Pair [first=0, second=0], " + // for #2 "My Second add-on"
- "Pair [first=5, second=0]]", // for #1 "My First add-on"
+ "Pair [first=0, second=0], " + // for #2 "My Second add-on"
+ "Pair [first=5, second=0]]", // for #1 "My First add-on"
Arrays.toString(layoutlibVers.toArray()));
@@ -385,7 +391,7 @@ public class SdkAddonSourceTest extends TestCase {
ExtraPackage ep = (ExtraPackage) p;
// combine path and old-paths in the form "path [old_path1, old_path2]"
extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths()));
- extraVendors.add(ep.getVendor());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
ArrayList<String> filePaths = new ArrayList<String>();
@@ -401,9 +407,9 @@ public class SdkAddonSourceTest extends TestCase {
"extra0000005f []]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[android_vendor, " +
- "g, " +
- "vendor0000005f]",
+ "[android_vendor/android_vendor, " +
+ "g/g, " +
+ "vendor0000005f/____]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
("[SDK/extras/android_vendor/extra_api_dep, " +
@@ -418,6 +424,117 @@ public class SdkAddonSourceTest extends TestCase {
}
/**
+ * Validate we can load a valid add-on schema version 4
+ */
+ public void testLoadAddonXml_4() throws Exception {
+ InputStream xmlStream = getTestResource("/com/android/sdklib/testdata/addon_sample_4.xml");
+
+ // guess the version from the XML document
+ int version = mSource._getXmlSchemaVersion(xmlStream);
+ assertEquals(4, version);
+
+ Boolean[] validatorFound = new Boolean[] { Boolean.FALSE };
+ String[] validationError = new String[] { null };
+ String url = "not-a-valid-url://" + SdkAddonConstants.URL_DEFAULT_FILENAME;
+
+ String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound);
+ assertEquals(Boolean.TRUE, validatorFound[0]);
+ assertEquals(null, validationError[0]);
+ assertEquals(SdkAddonConstants.getSchemaUri(4), uri);
+
+ // Validation was successful, load the document
+ MockMonitor monitor = new MockMonitor();
+ Document doc = mSource._getDocument(xmlStream, monitor);
+ assertNotNull(doc);
+
+ // Get the packages
+ assertTrue(mSource._parsePackages(doc, uri, monitor));
+
+ assertEquals("Found My First add-on by John Doe, Android API 1, revision 1\n" +
+ "Found My Second add-on by John Deer, Android API 2, revision 42\n" +
+ "Found This add-on has no libraries by Joe Bar, Android API 4, revision 3\n" +
+ "Found Random name, not an id!, revision 43 (Obsolete)\n" +
+ "Found Yet another extra, by Android, revision 2\n" +
+ "Found . -..- - .-. .-, revision 2 (Obsolete)\n",
+ monitor.getCapturedVerboseLog());
+ assertEquals("", monitor.getCapturedLog());
+ assertEquals("", monitor.getCapturedErrorLog());
+
+ // check the packages we found... we expected to find 6 packages with each at least
+ // one archive.
+ // Note the order doesn't necessary match the one from the
+ // assertEquald(getCapturedVerboseLog) because packages are sorted using the
+ // Packages' sorting order, e.g. all platforms are sorted by descending API level, etc.
+ Package[] pkgs = mSource.getPackages();
+
+ assertEquals(6, pkgs.length);
+ for (Package p : pkgs) {
+ assertTrue(p.getArchives().length >= 1);
+ }
+
+ // Check the layoutlib of the platform packages.
+ ArrayList<Pair<Integer, Integer>> layoutlibVers = new ArrayList<Pair<Integer,Integer>>();
+ for (Package p : pkgs) {
+ if (p instanceof AddonPackage) {
+ layoutlibVers.add(((AddonPackage) p).getLayoutlibVersion());
+ }
+ }
+ assertEquals(
+ "[Pair [first=3, second=42], " + // for #3 "This add-on has no libraries"
+ "Pair [first=0, second=0], " + // for #2 "My Second add-on"
+ "Pair [first=5, second=0]]", // for #1 "My First add-on"
+ Arrays.toString(layoutlibVers.toArray()));
+
+
+ // Check the extra packages: path, vendor, install folder, old-paths
+
+ final String osSdkPath = "SDK";
+ final SdkManager sdkManager = new MockEmptySdkManager(osSdkPath);
+
+ ArrayList<String> extraPaths = new ArrayList<String>();
+ ArrayList<String> extraVendors = new ArrayList<String>();
+ ArrayList<File> extraInstall = new ArrayList<File>();
+ ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>();
+ for (Package p : pkgs) {
+ if (p instanceof ExtraPackage) {
+ ExtraPackage ep = (ExtraPackage) p;
+ // combine path and old-paths in the form "path [old_path1, old_path2]"
+ extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths()));
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
+ extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
+
+ ArrayList<String> filePaths = new ArrayList<String>();
+ for (String filePath : ep.getProjectFiles()) {
+ filePaths.add(filePath);
+ }
+ extraFilePaths.add(filePaths);
+ }
+ }
+ // Extras are sorted by vendor-id/path and thus their order differs from the
+ // XML or the parsed package list.
+ assertEquals(
+ "[extra0000005f [], " + // for extra #3
+ "extra_api_dep [path1, old_path2, oldPath3], " + // for extra #2
+ "usb_driver []]", // for extra #1
+ Arrays.toString(extraPaths.toArray()));
+ assertEquals(
+ "[____/____, " +
+ "android_vendor/Android Vendor, " +
+ "cyclop/The big bus]",
+ Arrays.toString(extraVendors.toArray()));
+ assertEquals(
+ ("[SDK/extras/____/extra0000005f, " +
+ "SDK/extras/android_vendor/extra_api_dep, " +
+ "SDK/extras/cyclop/usb_driver]").replace('/', File.separatorChar),
+ Arrays.toString(extraInstall.toArray()));
+ assertEquals(
+ "[[], " +
+ "[v8/veggies_8.jar, root.jar, dir1/dir 2 with space/mylib.jar], " +
+ "[]]",
+ Arrays.toString(extraFilePaths.toArray()));
+ }
+
+ /**
* Returns an SdkLib file resource as a {@link ByteArrayInputStream},
* which has the advantage that we can use {@link InputStream#reset()} on it
* at any time to read it multiple times.
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
index a32d154..3d78949 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
@@ -233,7 +233,7 @@ public class SdkRepoSourceTest extends TestCase {
"Found Documentation for Android SDK, API 2, revision 42\n" +
"Found Android SDK Tools, revision 42\n" +
"Found This add-on has no libraries by Joe Bar, Android API 4, revision 3\n" +
- "Found Usb Driver package, revision 43\n",
+ "Found Usb Driver, revision 43\n",
monitor.getCapturedVerboseLog());
assertEquals("", monitor.getCapturedLog());
assertEquals("", monitor.getCapturedErrorLog());
@@ -256,16 +256,17 @@ public class SdkRepoSourceTest extends TestCase {
ArrayList<File> extraInstall = new ArrayList<File>();
for (Package p : pkgs) {
if (p instanceof ExtraPackage) {
- extraPaths.add(((ExtraPackage) p).getPath());
- extraVendors.add(((ExtraPackage) p).getVendor());
- extraInstall.add(((ExtraPackage) p).getInstallFolder(osSdkPath, sdkManager));
+ ExtraPackage ep = (ExtraPackage) p;
+ extraPaths.add(ep.getPath());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
+ extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
}
}
assertEquals(
"[usb_driver]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[]",
+ "[/]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
"[SDK/extras/usb_driver]".replace('/', File.separatorChar),
@@ -310,8 +311,8 @@ public class SdkRepoSourceTest extends TestCase {
"Found Documentation for Android SDK, API 2, revision 42\n" +
"Found Android SDK Tools, revision 42\n" +
"Found This add-on has no libraries by Joe Bar, Android API 4, revision 3\n" +
- "Found Usb Driver package, revision 43 (Obsolete)\n" +
- "Found Extra API Dep package, revision 2 (Obsolete)\n" +
+ "Found Usb Driver, revision 43 (Obsolete)\n" +
+ "Found Extra API Dep, revision 2 (Obsolete)\n" +
"Found Samples for SDK API 14, revision 24 (Obsolete)\n",
monitor.getCapturedVerboseLog());
assertEquals("", monitor.getCapturedLog());
@@ -335,16 +336,17 @@ public class SdkRepoSourceTest extends TestCase {
ArrayList<File> extraInstall = new ArrayList<File>();
for (Package p : pkgs) {
if (p instanceof ExtraPackage) {
- extraPaths.add(((ExtraPackage) p).getPath());
- extraVendors.add(((ExtraPackage) p).getVendor());
- extraInstall.add(((ExtraPackage) p).getInstallFolder(osSdkPath, sdkManager));
+ ExtraPackage ep = (ExtraPackage) p;
+ extraPaths.add(ep.getPath());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
+ extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
}
}
assertEquals(
"[extra_api_dep, usb_driver]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[, ]",
+ "[/, /]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
"[SDK/extras/extra_api_dep, SDK/extras/usb_driver]".replace('/', File.separatorChar),
@@ -387,8 +389,8 @@ public class SdkRepoSourceTest extends TestCase {
"Found Documentation for Android SDK, API 2, revision 42\n" +
"Found Android SDK Tools, revision 42\n" +
"Found Android SDK Platform-tools, revision 3\n" +
- "Found A USB Driver package, revision 43 (Obsolete)\n" +
- "Found Android Vendor Extra API Dep package, revision 2 (Obsolete)\n" +
+ "Found A USB Driver, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" +
"Found Samples for SDK API 14, revision 24 (Obsolete)\n",
monitor.getCapturedVerboseLog());
assertEquals("", monitor.getCapturedLog());
@@ -412,16 +414,17 @@ public class SdkRepoSourceTest extends TestCase {
ArrayList<File> extraInstall = new ArrayList<File>();
for (Package p : pkgs) {
if (p instanceof ExtraPackage) {
- extraPaths.add(((ExtraPackage) p).getPath());
- extraVendors.add(((ExtraPackage) p).getVendor());
- extraInstall.add(((ExtraPackage) p).getInstallFolder(osSdkPath, sdkManager));
+ ExtraPackage ep = (ExtraPackage) p;
+ extraPaths.add(ep.getPath());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
+ extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
}
}
assertEquals(
"[extra_api_dep, usb_driver]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[android_vendor, a]",
+ "[android_vendor/android_vendor, a/a]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
"[SDK/extras/android_vendor/extra_api_dep, SDK/extras/a/usb_driver]"
@@ -465,8 +468,8 @@ public class SdkRepoSourceTest extends TestCase {
"Found Documentation for Android SDK, API 2, revision 42\n" +
"Found Android SDK Tools, revision 42\n" +
"Found Android SDK Platform-tools, revision 3\n" +
- "Found A USB Driver package, revision 43 (Obsolete)\n" +
- "Found Android Vendor Extra API Dep package, revision 2 (Obsolete)\n" +
+ "Found A USB Driver, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" +
"Found Samples for SDK API 14, revision 24 (Obsolete)\n",
monitor.getCapturedVerboseLog());
assertEquals("", monitor.getCapturedLog());
@@ -508,12 +511,13 @@ public class SdkRepoSourceTest extends TestCase {
ArrayList<ArrayList<String>> extraFilePaths = new ArrayList<ArrayList<String>>();
for (Package p : pkgs) {
if (p instanceof ExtraPackage) {
- extraPaths.add(((ExtraPackage) p).getPath());
- extraVendors.add(((ExtraPackage) p).getVendor());
- extraInstall.add(((ExtraPackage) p).getInstallFolder(osSdkPath, sdkManager));
+ ExtraPackage ep = (ExtraPackage) p;
+ extraPaths.add(ep.getPath());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
+ extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
ArrayList<String> filePaths = new ArrayList<String>();
- for (String filePath : ((ExtraPackage) p).getProjectFiles()) {
+ for (String filePath : ep.getProjectFiles()) {
filePaths.add(filePath);
}
extraFilePaths.add(filePaths);
@@ -523,7 +527,7 @@ public class SdkRepoSourceTest extends TestCase {
"[extra_api_dep, usb_driver]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[android_vendor, a]",
+ "[android_vendor/android_vendor, a/a]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
"[SDK/extras/android_vendor/extra_api_dep, SDK/extras/a/usb_driver]"
@@ -575,8 +579,8 @@ public class SdkRepoSourceTest extends TestCase {
"Found Documentation for Android SDK, API 2, revision 42\n" +
"Found Android SDK Tools, revision 42\n" +
"Found Android SDK Platform-tools, revision 3\n" +
- "Found A USB Driver package, revision 43 (Obsolete)\n" +
- "Found Android Vendor Extra API Dep package, revision 2 (Obsolete)\n" +
+ "Found A USB Driver, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra API Dep, revision 2 (Obsolete)\n" +
"Found Samples for SDK API 14, revision 24 (Obsolete)\n" +
"Found ARM EABI System Image, Android API 42, revision 12\n" +
"Found Sources for Android SDK, API 42, revision 12\n",
@@ -631,7 +635,7 @@ public class SdkRepoSourceTest extends TestCase {
ExtraPackage ep = (ExtraPackage) p;
// combine path and old-paths in the form "path [old_path1, old_path2]"
extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths()));
- extraVendors.add(ep.getVendor());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
ArrayList<String> filePaths = new ArrayList<String>();
@@ -646,8 +650,8 @@ public class SdkRepoSourceTest extends TestCase {
"usb_driver []]",
Arrays.toString(extraPaths.toArray()));
assertEquals(
- "[android_vendor, " +
- "a]",
+ "[android_vendor/android_vendor, " +
+ "a/a]",
Arrays.toString(extraVendors.toArray()));
assertEquals(
("[SDK/extras/android_vendor/extra_api_dep, " +
@@ -782,7 +786,7 @@ public class SdkRepoSourceTest extends TestCase {
ExtraPackage ep = (ExtraPackage) p;
// combine path and old-paths in the form "path [old_path1, old_path2]"
extraPaths.add(ep.getPath() + " " + Arrays.toString(ep.getOldPaths()));
- extraVendors.add(ep.getVendor());
+ extraVendors.add(ep.getVendorId() + "/" + ep.getVendorDisplay());
extraInstall.add(ep.getInstallFolder(osSdkPath, sdkManager));
ArrayList<String> filePaths = new ArrayList<String>();
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java
index d1355d7..cf7dfd4 100755
--- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/repository/ValidateAddonXmlTest.java
@@ -120,7 +120,7 @@ public class ValidateAddonXmlTest extends TestCase {
handler.verify();
}
- /** Validate a valid sample using namespace version 2 using an InputStream */
+ /** Validate a valid sample using namespace version 3 using an InputStream */
public void testValidateLocalAddonFile3() throws Exception {
InputStream xmlStream = this.getClass().getResourceAsStream(
"/com/android/sdklib/testdata/addon_sample_3.xml");
@@ -132,6 +132,18 @@ public class ValidateAddonXmlTest extends TestCase {
handler.verify();
}
+ /** Validate a valid sample using namespace version 4 using an InputStream */
+ public void testValidateLocalAddonFile4() throws Exception {
+ InputStream xmlStream = this.getClass().getResourceAsStream(
+ "/com/android/sdklib/testdata/addon_sample_4.xml");
+ Source source = new StreamSource(xmlStream);
+
+ CaptureErrorHandler handler = new CaptureErrorHandler();
+ Validator validator = getAddonValidator(4, handler);
+ validator.validate(source);
+ handler.verify();
+ }
+
// IMPORTANT: each time you add a test here, you should add a corresponding
// test in SdkAddonSourceTest to validate the XML content is parsed correctly.
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_4.xml b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_4.xml
new file mode 100755
index 0000000..59ca9a1
--- /dev/null
+++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/testdata/addon_sample_4.xml
@@ -0,0 +1,215 @@
+<?xml version="1.0"?>
+<!--
+ * Copyright (C) 2011 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.
+-->
+<sdk:sdk-addon
+ xmlns:sdk="http://schemas.android.com/sdk/android/addon/4">
+
+ <!-- Define a couple of licenses. These will be referenced by uses-license later. -->
+
+ <sdk:license type="text" id="license1">
+ This is the license
+ for this platform.
+ </sdk:license>
+
+ <sdk:license id="license2">
+ Licenses are only of type 'text' right now, so this is implied.
+ </sdk:license>
+
+ <!-- Inner elements must be either platform, add-on, doc or tool.
+ There can be 0 or more of each, in any order. -->
+
+ <sdk:add-on>
+ <sdk:name>My First add-on</sdk:name>
+ <sdk:vendor>John Doe</sdk:vendor>
+ <!-- TODO The next CL will deal with addon properties.
+ <sdk:name-id>My_First_add-on</sdk:name-id>
+ <sdk:name-display>My First add-on</sdk:name-display>
+
+ <sdk:vendor-id>John_Doe</sdk:vendor-id>
+ <sdk:vendor-display>John Doe</sdk:vendor-display>
+ -->
+
+ <sdk:api-level>1</sdk:api-level>
+ <sdk:revision>1</sdk:revision>
+ <sdk:uses-license ref="license2" />
+ <sdk:description>Some optional description</sdk:description>
+ <sdk:desc-url>http://www.example.com/myfirstaddon</sdk:desc-url>
+ <sdk:archives>
+ <sdk:archive os="any">
+ <sdk:size>65536</sdk:size>
+ <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
+ <sdk:url>http://www.example.com/add-ons/first.zip</sdk:url>
+ </sdk:archive>
+ </sdk:archives>
+ <!-- The libs node is mandatory, however it can be empty. -->
+ <sdk:libs>
+ <sdk:lib>
+ <sdk:name>android.blah.somelib</sdk:name>
+ <sdk:description>The description for this library.</sdk:description>
+ </sdk:lib>
+ <sdk:lib>
+ <!-- sdk:description is optional, name is not -->
+ <sdk:name>com.android.mymaps</sdk:name>
+ </sdk:lib>
+ </sdk:libs>
+ <sdk:layoutlib>
+ <sdk:api>5</sdk:api>
+ <sdk:revision>0</sdk:revision>
+ </sdk:layoutlib>
+ </sdk:add-on>
+
+ <sdk:add-on>
+ <sdk:name>My Second add-on</sdk:name>
+ <sdk:vendor>John Deer</sdk:vendor>
+ <!-- TODO The next CL will deal with addon properties.
+ <sdk:name-id>My_Second_add-on</sdk:name-id>
+ <sdk:name-display>My Second add-on</sdk:name-display>
+
+ <sdk:vendor-id>John_Deer</sdk:vendor-id>
+ <sdk:vendor-display>John Deer</sdk:vendor-display>
+ -->
+
+ <sdk:api-level>2</sdk:api-level>
+ <sdk:revision>42</sdk:revision>
+ <sdk:archives>
+ <sdk:archive os="windows">
+ <sdk:size>65536</sdk:size>
+ <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
+ <sdk:url>distrib/second-42-win.zip</sdk:url>
+ </sdk:archive>
+ <sdk:archive os="linux">
+ <sdk:size>65536</sdk:size>
+ <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
+ <sdk:url>distrib/second-42-linux.tar.bz2</sdk:url>
+ </sdk:archive>
+ </sdk:archives>
+ <sdk:libs>
+ <sdk:lib>
+ <sdk:name>android.blah.somelib</sdk:name>
+ <sdk:description>The description for this library.</sdk:description>
+ </sdk:lib>
+ <sdk:lib>
+ <sdk:name>com.android.mymaps</sdk:name>
+ </sdk:lib>
+ </sdk:libs>
+ <sdk:uses-license ref="license2" />
+ <!-- No layoutlib element in this package. It's optional. -->
+ </sdk:add-on>
+
+ <sdk:add-on>
+ <sdk:name>This add-on has no libraries</sdk:name>
+ <sdk:vendor>Joe Bar</sdk:vendor>
+ <!-- TODO The next CL will deal with addon properties.
+ <sdk:name-id>no_libs</sdk:name-id>
+ <sdk:name-display>This add-on has no libraries</sdk:name-display>
+
+ <sdk:vendor-id>Joe_Bar</sdk:vendor-id>
+ <sdk:vendor-display>Joe Bar</sdk:vendor-display>
+ -->
+
+ <sdk:uses-license ref="license2" />
+ <sdk:api-level>4</sdk:api-level>
+ <sdk:revision>3</sdk:revision>
+ <sdk:archives>
+ <sdk:archive os="any" arch="any">
+ <sdk:size>65536</sdk:size>
+ <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
+ <sdk:url>distrib/imnotanarchiveimadoctorjim.zip</sdk:url>
+ </sdk:archive>
+ </sdk:archives>
+ <!-- The libs node is mandatory, however it can be empty. -->
+ <sdk:libs />
+ <sdk:layoutlib>
+ <sdk:api>3</sdk:api>
+ <sdk:revision>42</sdk:revision>
+ </sdk:layoutlib>
+ </sdk:add-on>
+
+ <sdk:extra>
+ <sdk:name-display>Random name, not an id!</sdk:name-display>
+
+ <sdk:vendor-id>cyclop</sdk:vendor-id>
+ <sdk:vendor-display>The big bus</sdk:vendor-display>
+
+ <sdk:path>usb_driver</sdk:path>
+ <sdk:uses-license ref="license2" />
+ <sdk:revision>43</sdk:revision>
+ <sdk:archives>
+ <sdk:archive os="any" arch="any">
+ <sdk:size>65536</sdk:size>
+ <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
+ <sdk:url>distrib/extraduff.zip</sdk:url>
+ </sdk:archive>
+ </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:obsolete/>
+ </sdk:extra>
+
+ <sdk:extra>
+ <sdk:name-display>Yet another extra, by Android</sdk:name-display>
+
+ <sdk:vendor-id>android_vendor</sdk:vendor-id>
+ <sdk:vendor-display>Android Vendor</sdk:vendor-display>
+
+ <sdk:path>extra_api_dep</sdk:path>
+ <sdk:uses-license ref="license2" />
+ <sdk:revision>2</sdk:revision>
+ <sdk:archives>
+ <sdk:archive os="any" arch="any">
+ <sdk:size>65536</sdk:size>
+ <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
+ <sdk:url>distrib/extra_mega_duff.zip</sdk:url>
+ </sdk:archive>
+ </sdk:archives>
+ <sdk:description>Some extra package that has a min-api-level of 42</sdk:description>
+ <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url>
+ <sdk:min-tools-rev>3</sdk:min-tools-rev>
+ <sdk:min-api-level>42</sdk:min-api-level>
+ <sdk:project-files>
+ <sdk:path>v8/veggies_8.jar</sdk:path>
+ <sdk:path>root.jar</sdk:path>
+ <sdk:path>dir1/dir 2 with space/mylib.jar</sdk:path>
+ </sdk:project-files>
+ <sdk:old-paths>path1;old_path2;oldPath3</sdk:old-paths>
+ </sdk:extra>
+
+ <sdk:extra>
+ <sdk:name-display>. -..- - .-. .-</sdk:name-display>
+
+ <sdk:vendor-id>____</sdk:vendor-id>
+ <sdk:vendor-display>____</sdk:vendor-display>
+
+ <sdk:path>____</sdk:path>
+ <sdk:uses-license ref="license2" />
+ <sdk:revision>2</sdk:revision>
+ <sdk:archives>
+ <sdk:archive os="any" arch="any">
+ <sdk:size>65536</sdk:size>
+ <sdk:checksum type="sha1">2822ae37115ebf13412bbef91339ee0d9454525e</sdk:checksum>
+ <sdk:url>distrib/extra_mega_duff.zip</sdk:url>
+ </sdk:archive>
+ </sdk:archives>
+ <sdk:description>Some extra package that has a min-api-level of 42</sdk:description>
+ <sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url>
+ <sdk:min-tools-rev>3</sdk:min-tools-rev>
+ <sdk:min-api-level>42</sdk:min-api-level>
+ <sdk:obsolete></sdk:obsolete>
+ <!-- No project-files element in this package. -->
+ </sdk:extra>
+
+</sdk:sdk-addon>
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java
index dce4110..2311df2 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/AdtUpdateDialog.java
@@ -309,7 +309,7 @@ public class AdtUpdateDialog extends SwtBaseDialog {
boolean accept(Package pkg) {
if (pkg instanceof ExtraPackage) {
ExtraPackage ep = (ExtraPackage) pkg;
- if (ep.getVendor().equals(mVendor)) {
+ if (ep.getVendorId().equals(mVendor)) {
// Check actual extra <path> field first
if (ep.getPath().equals(mPath)) {
return true;
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
index 49395ef..944dffb 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogic.java
@@ -221,8 +221,8 @@ class PackagesDiffLogic {
Package p = item.getMainPackage();
if (p instanceof ExtraPackage && item.getState() == PkgState.NEW) {
ExtraPackage ep = (ExtraPackage) p;
- if (ep.getVendor().equals("google") && //$NON-NLS-1$
- ep.getPath().equals("usb_driver")) { //$NON-NLS-1$
+ if (ep.getVendorId().equals("google") && //$NON-NLS-1$
+ ep.getPath().equals("usb_driver")) { //$NON-NLS-1$
item.setChecked(true);
}
}
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java
index 58d7daa..d3dc7b6 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java
@@ -519,7 +519,9 @@ public class PackagesPage extends UpdaterPage
value = button.getSelection();
}
- item.setSelection(value);
+ if (!item.isDisposed()) {
+ item.setSelection(value);
+ }
}
}
@@ -1564,12 +1566,25 @@ public class PackagesPage extends UpdaterPage
if (element instanceof IDescription) {
String s = ((IDescription) element).getLongDescription();
if (element instanceof Package) {
- SdkSource src = ((Package) element).getParentSource();
+ Package p = (Package) element;
+
+ if (!p.isLocal()) {
+ // For non-installed item, try to find a download size
+ for (Archive a : p.getArchives()) {
+ if (!a.isLocal() && a.isCompatible()) {
+ s += '\n' + a.getSizeDescription();
+ break;
+ }
+ }
+ }
+
+ // Display info about where this package comes/came from
+ SdkSource src = p.getParentSource();
if (src != null) {
try {
URL url = new URL(src.getUrl());
String host = url.getHost();
- if (((Package) element).isLocal()) {
+ if (p.isLocal()) {
s += String.format("\nInstalled from %1$s", host);
} else {
s += String.format("\nProvided by %1$s", host);
diff --git a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java
index eafe5ac..85f1ab5 100755
--- a/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java
+++ b/sdkmanager/libs/sdkuilib/tests/com/android/sdkuilib/internal/repository/sdkman2/PackagesDiffLogicTest.java
@@ -326,8 +326,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <INSTALLED, pkg:Android SDK Tools, revision 10>\n" +
"-- <INSTALLED, pkg:Android SDK Platform-tools, revision 3>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=2>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 5>\n" +
- "-- <INSTALLED, pkg:Carrier Custom Rom package, revision 1>\n",
+ "-- <INSTALLED, pkg:Android USB Driver, revision 5>\n" +
+ "-- <INSTALLED, pkg:Carrier Custom Rom, revision 1>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
@@ -335,8 +335,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <INSTALLED, pkg:Android SDK Tools, revision 10>\n" +
"-- <INSTALLED, pkg:Android SDK Platform-tools, revision 3>\n" +
"PkgCategorySource <source=repo2 (example.com), #items=2>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 5>\n" +
- "-- <INSTALLED, pkg:Carrier Custom Rom package, revision 1>\n",
+ "-- <INSTALLED, pkg:Android USB Driver, revision 5>\n" +
+ "-- <INSTALLED, pkg:Carrier Custom Rom, revision 1>\n",
getTree(m, false /*displaySortByApi*/));
}
@@ -371,8 +371,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <INSTALLED, pkg:Android SDK Tools, revision 10>\n" +
"-- <INSTALLED, pkg:Android SDK Platform-tools, revision 3>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=2>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 4, updated by:Android USB Driver package, revision 5>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n",
+ "-- <INSTALLED, pkg:Android USB Driver, revision 4, updated by:Android USB Driver, revision 5>\n" +
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n",
getTree(m, true /*displaySortByApi*/));
// Next update adds platforms and addon, sorted in a category based on their API level
@@ -430,8 +430,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <INSTALLED, pkg:addon A by vendor 1, Android API 1, revision 5, updated by:addon A by vendor 1, Android API 1, revision 6>\n" +
"-- <INSTALLED, pkg:addon D by vendor 1, Android API 1, revision 10, updated by:addon D by vendor 1, Android API 1, revision 13>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=2>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 4, updated by:Android USB Driver package, revision 5>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n",
+ "-- <INSTALLED, pkg:Android USB Driver, revision 4, updated by:Android USB Driver, revision 5>\n" +
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n",
getTree(m, true /*displaySortByApi*/));
// Reloading the same thing should have no impact except for the update methods
@@ -486,8 +486,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <INSTALLED, pkg:addon A by vendor 1, Android API 1, revision 5, updated by:addon A by vendor 1, Android API 1, revision 6>\n" +
"-- <INSTALLED, pkg:addon D by vendor 1, Android API 1, revision 10, updated by:addon D by vendor 1, Android API 1, revision 13>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=2>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 4, updated by:Android USB Driver package, revision 5>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n",
+ "-- <INSTALLED, pkg:Android USB Driver, revision 4, updated by:Android USB Driver, revision 5>\n" +
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n",
getTree(m, true /*displaySortByApi*/));
}
@@ -714,8 +714,8 @@ public class PackagesDiffLogicTest extends TestCase {
"PkgCategorySource <source=repo1 (1.example.com), #items=4>\n" +
"-- <INSTALLED, pkg:Android SDK Tools, revision 10>\n" +
"-- <INSTALLED, pkg:Android SDK Platform-tools, revision 3>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 4, updated by:Android USB Driver package, revision 5>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n",
+ "-- <INSTALLED, pkg:Android USB Driver, revision 4, updated by:Android USB Driver, revision 5>\n" +
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n",
getTree(m, false /*displaySortByApi*/));
// Next update adds platforms and addon, sorted in a category based on their API level
@@ -766,8 +766,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <INSTALLED, pkg:SDK Platform Android android-3, API 3, revision 6>\n" +
"-- <NEW, pkg:SDK Platform Android android-2, API 2, revision 4>\n" +
"-- <INSTALLED, pkg:SDK Platform Android android-1, API 1, revision 2>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 4, updated by:Android USB Driver package, revision 5>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n" +
+ "-- <INSTALLED, pkg:Android USB Driver, revision 4, updated by:Android USB Driver, revision 5>\n" +
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n" +
"PkgCategorySource <source=repo2 (2.example.com), #items=4>\n" +
"-- <NEW, pkg:addon B by vendor 2, Android API 2, revision 9>\n" +
"-- <NEW, pkg:addon C by vendor 2, Android API 2, revision 9>\n" +
@@ -820,8 +820,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <INSTALLED, pkg:SDK Platform Android android-3, API 3, revision 6>\n" +
"-- <NEW, pkg:SDK Platform Android android-2, API 2, revision 4>\n" +
"-- <INSTALLED, pkg:SDK Platform Android android-1, API 1, revision 2>\n" +
- "-- <INSTALLED, pkg:Android USB Driver package, revision 4, updated by:Android USB Driver package, revision 5>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n" +
+ "-- <INSTALLED, pkg:Android USB Driver, revision 4, updated by:Android USB Driver, revision 5>\n" +
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n" +
"PkgCategorySource <source=repo2 (2.example.com), #items=4>\n" +
"-- <NEW, pkg:addon B by vendor 2, Android API 2, revision 9>\n" +
"-- <NEW, pkg:addon C by vendor 2, Android API 2, revision 9>\n" +
@@ -975,8 +975,8 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <NEW, pkg:SDK Platform Android android-1, API 1, revision 2>\n" +
"-- <NEW, pkg:addon A by vendor 1, Android API 1, revision 5>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=2>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n" +
- "-- <NEW, pkg:Google USB Driver package, revision 5>\n",
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n" +
+ "-- <NEW, pkg:Google USB Driver, revision 5>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
"PkgCategorySource <source=repo1 (1.example.com), #items=7>\n" +
@@ -986,11 +986,11 @@ public class PackagesDiffLogicTest extends TestCase {
"-- <NEW, pkg:SDK Platform Android android-1, API 1, revision 2>\n" +
"-- < * NEW, pkg:ARM EABI System Image, Android API 2, revision 1>\n" +
"-- < * NEW, pkg:Intel x86 Atom System Image, Android API 2, revision 1>\n" +
- "-- <NEW, pkg:Google USB Driver package, revision 5>\n" +
+ "-- <NEW, pkg:Google USB Driver, revision 5>\n" +
"PkgCategorySource <source=repo2 (2.example.com), #items=3>\n" +
"-- < * NEW, pkg:addon B by vendor 2, Android API 2, revision 7>\n" +
"-- <NEW, pkg:addon A by vendor 1, Android API 1, revision 5>\n" +
- "-- <NEW, pkg:Carrier Custom Rom package, revision 1>\n",
+ "-- <NEW, pkg:Carrier Custom Rom, revision 1>\n",
getTree(m, false /*displaySortByApi*/));
// We don't install the USB driver by default on Mac or Linux, only on Windows
@@ -1005,11 +1005,11 @@ public class PackagesDiffLogicTest extends TestCase {
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=1>\n" +
- "-- <NEW, pkg:Google USB Driver package, revision 5>\n",
+ "-- <NEW, pkg:Google USB Driver, revision 5>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
"PkgCategorySource <source=repo1 (1.example.com), #items=1>\n" +
- "-- <NEW, pkg:Google USB Driver package, revision 5>\n",
+ "-- <NEW, pkg:Google USB Driver, revision 5>\n",
getTree(m, false /*displaySortByApi*/));
m.clear();
@@ -1023,11 +1023,11 @@ public class PackagesDiffLogicTest extends TestCase {
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=1>\n" +
- "-- <NEW, pkg:Google USB Driver package, revision 5>\n",
+ "-- <NEW, pkg:Google USB Driver, revision 5>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
"PkgCategorySource <source=repo1 (1.example.com), #items=1>\n" +
- "-- <NEW, pkg:Google USB Driver package, revision 5>\n",
+ "-- <NEW, pkg:Google USB Driver, revision 5>\n",
getTree(m, false /*displaySortByApi*/));
m.clear();
@@ -1041,11 +1041,11 @@ public class PackagesDiffLogicTest extends TestCase {
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=1>\n" +
- "-- < * NEW, pkg:Google USB Driver package, revision 5>\n",
+ "-- < * NEW, pkg:Google USB Driver, revision 5>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
"PkgCategorySource <source=repo1 (1.example.com), #items=1>\n" +
- "-- < * NEW, pkg:Google USB Driver package, revision 5>\n",
+ "-- < * NEW, pkg:Google USB Driver, revision 5>\n",
getTree(m, false /*displaySortByApi*/));
}
@@ -1254,13 +1254,13 @@ public class PackagesDiffLogicTest extends TestCase {
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=2>\n" +
- "-- <NEW, pkg:Vendor1 New Path2 package, revision 2>\n" +
- "-- <INSTALLED, pkg:Vendor1 Old Path1 package, revision 1>\n",
+ "-- <NEW, pkg:Vendor1 New Path2, revision 2>\n" +
+ "-- <INSTALLED, pkg:Vendor1 Old Path1, revision 1>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
"PkgCategorySource <source=repo1 (example.com), #items=2>\n" +
- "-- <NEW, pkg:Vendor1 New Path2 package, revision 2>\n" +
- "-- <INSTALLED, pkg:Vendor1 Old Path1 package, revision 1>\n",
+ "-- <NEW, pkg:Vendor1 New Path2, revision 2>\n" +
+ "-- <INSTALLED, pkg:Vendor1 Old Path1, revision 1>\n",
getTree(m, false /*displaySortByApi*/));
// Now, start again, but this time the new package uses the old-path attribute
@@ -1280,11 +1280,11 @@ public class PackagesDiffLogicTest extends TestCase {
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=1>\n" +
- "-- <INSTALLED, pkg:Vendor1 Old Path1 package, revision 1, updated by:Vendor1 New Path2 package, revision 2>\n",
+ "-- <INSTALLED, pkg:Vendor1 Old Path1, revision 1, updated by:Vendor1 New Path2, revision 2>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
"PkgCategorySource <source=repo1 (example.com), #items=1>\n" +
- "-- <INSTALLED, pkg:Vendor1 Old Path1 package, revision 1, updated by:Vendor1 New Path2 package, revision 2>\n",
+ "-- <INSTALLED, pkg:Vendor1 Old Path1, revision 1, updated by:Vendor1 New Path2, revision 2>\n",
getTree(m, false /*displaySortByApi*/));
}