diff options
author | Raphael Moll <ralf@android.com> | 2012-04-19 16:27:03 -0700 |
---|---|---|
committer | Raphael Moll <ralf@android.com> | 2012-05-03 12:12:22 -0700 |
commit | 87107c5cb1fb5fdafdaa94460fb6797af60fcde9 (patch) | |
tree | 01f99d040165bb3144321902d61e42399689dbc9 /sdkmanager/libs/sdklib | |
parent | ea0e2af1c398ad3b189a163fa574ca3d255e5895 (diff) | |
download | sdk-87107c5cb1fb5fdafdaa94460fb6797af60fcde9.zip sdk-87107c5cb1fb5fdafdaa94460fb6797af60fcde9.tar.gz sdk-87107c5cb1fb5fdafdaa94460fb6797af60fcde9.tar.bz2 |
Rework SDK Manager support for major.minor.micro revisions.
2 things in this CL:
- There's a bit of refactoring:
- PreviewVersion becomes FullVersion (which is
a full major.minor.micro.preview)
- And I introduce a MajorRevision (which is just
a major number)
- Package.getRevision() returns one of these
revision objects instead of an integer which
leads to a multide of small boring changes.
- Changed the PackageDiffLogic and its test to
adequately use the new revision; "tools preview"
packages are placed in their own category and
releases can update previews but not the reverse.
Change-Id: Ia80fd9a3791919e827ce0d183c0f297f0d27f2e6
Diffstat (limited to 'sdkmanager/libs/sdklib')
21 files changed, 354 insertions, 148 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java index 8284054..a786728 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkManager.java @@ -463,7 +463,7 @@ public class SdkManager { int revision = 1; LayoutlibVersion layoutlibVersion = null; try { - revision = Integer.parseInt(platformProp.get(PkgProps.PKG_REVISION)); + revision = Integer.parseInt(platformProp.get(PkgProps.PKG_MAJOR_REV)); } catch (NumberFormatException e) { // do nothing, we'll keep the default value of 1. } diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/DocPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/DocPackage.java index 635dff9..9d6c02c 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/DocPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/DocPackage.java @@ -170,12 +170,12 @@ public class DocPackage extends Package implements IAndroidVersionProvider { if (mVersion.isPreview()) {
return String.format("Documentation for Android '%1$s' Preview SDK, revision %2$s%3$s",
mVersion.getCodename(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
} else {
return String.format("Documentation for Android SDK, API %1$d, revision %2$s%3$s",
mVersion.getApiLevel(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
}
@@ -194,8 +194,8 @@ public class DocPackage extends Package implements IAndroidVersionProvider { }
if (s.indexOf("revision") == -1) {
- s += String.format("\nRevision %1$d%2$s",
- getRevision(),
+ s += String.format("\nRevision %1$s%2$s",
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
@@ -257,7 +257,7 @@ public class DocPackage extends Package implements IAndroidVersionProvider { // Check if they're the same exact (api and codename)
if (replacementVersion.equals(mVersion)) {
// exact same version, so check the revision level
- if (replacementPackage.getRevision() > this.getRevision()) {
+ if (replacementPackage.getRevision().compareTo(this.getRevision()) > 0) {
return UpdateInfo.UPDATE;
}
} else {
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ExtraPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ExtraPackage.java index cc27853..3b921ae 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ExtraPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ExtraPackage.java @@ -490,9 +490,9 @@ public class ExtraPackage extends MinToolsPackage */
@Override
public String getShortDescription() {
- String s = String.format("%1$s, revision %2$d%3$s",
+ String s = String.format("%1$s, revision %2$s%3$s",
getDisplayName(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : ""); //$NON-NLS-2$
return s;
@@ -506,9 +506,9 @@ public class ExtraPackage extends MinToolsPackage */
@Override
public String getLongDescription() {
- String s = String.format("%1$s, revision %2$d%3$s\nBy %4$s",
+ String s = String.format("%1$s, revision %2$s%3$s\nBy %4$s",
getDisplayName(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "", //$NON-NLS-2$
getVendorDisplay());
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PreviewVersion.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/FullRevision.java index a75eb4b..f902001 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PreviewVersion.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/FullRevision.java @@ -22,8 +22,10 @@ package com.android.sdklib.internal.repository.packages; * (major.minor.micro) and an optional preview revision
* (the lack of a preview number indicates it's not a preview
* but a final package.)
+ *
+ * @see MajorRevision
*/
-public class PreviewVersion implements Comparable<PreviewVersion> {
+public class FullRevision implements Comparable<FullRevision> {
public static final int IMPLICIT_MINOR_REV = 0;
public static final int IMPLICIT_MICRO_REV = 0;
@@ -34,15 +36,15 @@ public class PreviewVersion implements Comparable<PreviewVersion> { private final int mMicro;
private final int mPreview;
- public PreviewVersion(int major) {
+ public FullRevision(int major) {
this(major, 0, 0);
}
- public PreviewVersion(int major, int minor, int micro) {
+ public FullRevision(int major, int minor, int micro) {
this(major, minor, micro, NOT_A_PREVIEW);
}
- public PreviewVersion(int major, int minor, int micro, int preview) {
+ public FullRevision(int major, int minor, int micro, int preview) {
mMajor = major;
mMinor = minor;
mMicro = micro;
@@ -130,10 +132,10 @@ public class PreviewVersion implements Comparable<PreviewVersion> { if (rhs == null) {
return false;
}
- if (!(rhs instanceof PreviewVersion)) {
+ if (!(rhs instanceof FullRevision)) {
return false;
}
- PreviewVersion other = (PreviewVersion) rhs;
+ FullRevision other = (FullRevision) rhs;
if (mMajor != other.mMajor) {
return false;
}
@@ -150,7 +152,7 @@ public class PreviewVersion implements Comparable<PreviewVersion> { }
/**
- * Trivial comparision of a version, e.g 17.1.2 < 18.0.0.
+ * Trivial comparison of a version, e.g 17.1.2 < 18.0.0.
*
* Note that preview/release candidate are released before their final version,
* so "18.0.0 rc1" comes below "18.0.0". The best way to think of it as if the
@@ -159,7 +161,7 @@ public class PreviewVersion implements Comparable<PreviewVersion> { * and more than "18.1.2.4"
*/
@Override
- public int compareTo(PreviewVersion rhs) {
+ public int compareTo(FullRevision rhs) {
int delta = mMajor - rhs.mMajor;
if (delta != 0) {
return delta;
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PreviewVersionPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/FullRevisionPackage.java index eac548e..9024af5 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PreviewVersionPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/FullRevisionPackage.java @@ -16,10 +16,10 @@ package com.android.sdklib.internal.repository.packages;
-import com.android.annotations.NonNull;
import com.android.sdklib.internal.repository.XmlParserUtils;
import com.android.sdklib.internal.repository.archives.Archive.Arch;
import com.android.sdklib.internal.repository.archives.Archive.Os;
+import com.android.sdklib.internal.repository.packages.Package.UpdateInfo;
import com.android.sdklib.internal.repository.sources.SdkSource;
import com.android.sdklib.repository.PkgProps;
import com.android.sdklib.repository.SdkRepoConstants;
@@ -30,13 +30,13 @@ import java.util.Map; import java.util.Properties;
/**
- * Represents a package in an SDK repository that has a {@link PreviewVersion},
+ * Represents a package in an SDK repository that has a {@link FullRevision},
* which is a multi-part revision number (major.minor.micro) and an optional preview revision.
*/
-public abstract class PreviewVersionPackage extends Package
- implements IPreviewVersionProvider {
+public abstract class FullRevisionPackage extends Package
+ implements IFullRevisionProvider {
- private final PreviewVersion mPreviewVersion;
+ private final FullRevision mPreviewVersion;
/**
* Creates a new package from the attributes and elements of the given XML node.
@@ -48,25 +48,25 @@ public abstract class PreviewVersionPackage extends Package * parameters that vary according to the originating XML schema.
* @param licenses The licenses loaded from the XML originating document.
*/
- PreviewVersionPackage(SdkSource source,
+ FullRevisionPackage(SdkSource source,
Node packageNode,
String nsUri,
Map<String,String> licenses) {
super(source, packageNode, nsUri, licenses);
- // The major revision is getRevision(), already handled by Package.
-
+ // The major revision is in Package.getRevision()
+ int majorRevision = super.getRevision().getMajor();
int minorRevision = XmlParserUtils.getXmlInt(packageNode,
SdkRepoConstants.NODE_MINOR_REV,
- PreviewVersion.IMPLICIT_MINOR_REV);
+ FullRevision.IMPLICIT_MINOR_REV);
int microRevision = XmlParserUtils.getXmlInt(packageNode,
SdkRepoConstants.NODE_MICRO_REV,
- PreviewVersion.IMPLICIT_MICRO_REV);
+ FullRevision.IMPLICIT_MICRO_REV);
int preview = XmlParserUtils.getXmlInt(packageNode,
SdkRepoConstants.NODE_PREVIEW,
- PreviewVersion.NOT_A_PREVIEW);
+ FullRevision.NOT_A_PREVIEW);
- mPreviewVersion = new PreviewVersion(getRevision(), minorRevision, microRevision, preview);
+ mPreviewVersion = new FullRevision(majorRevision, minorRevision, microRevision, preview);
}
/**
@@ -78,7 +78,7 @@ public abstract class PreviewVersionPackage extends Package * <p/>
* By design, this creates a package with one and only one archive.
*/
- public PreviewVersionPackage(
+ public FullRevisionPackage(
SdkSource source,
Properties props,
int revision,
@@ -91,26 +91,26 @@ public abstract class PreviewVersionPackage extends Package super(source, props, revision, license, description, descUrl,
archiveOs, archiveArch, archiveOsPath);
- // The major revision is getRevision(), already handled by Package.
-
+ // The major revision is in Package.getRevision()
+ int majorRevision = super.getRevision().getMajor();
int minorRevision = Integer.parseInt(
getProperty(props,
PkgProps.PKG_MINOR_REV,
- Integer.toString(PreviewVersion.IMPLICIT_MINOR_REV)));
+ Integer.toString(FullRevision.IMPLICIT_MINOR_REV)));
int microRevision = Integer.parseInt(
getProperty(props,
PkgProps.PKG_MICRO_REV,
- Integer.toString(PreviewVersion.IMPLICIT_MINOR_REV)));
+ Integer.toString(FullRevision.IMPLICIT_MINOR_REV)));
int preview = Integer.parseInt(
getProperty(props,
PkgProps.PKG_PREVIEW_REV,
- Integer.toString(PreviewVersion.NOT_A_PREVIEW)));
+ Integer.toString(FullRevision.NOT_A_PREVIEW)));
- mPreviewVersion = new PreviewVersion(getRevision(), minorRevision, microRevision, preview);
+ mPreviewVersion = new FullRevision(majorRevision, minorRevision, microRevision, preview);
}
- @Override @NonNull
- public PreviewVersion getPreviewVersion() {
+ @Override
+ public FullRevision getRevision() {
return mPreviewVersion;
}
@@ -118,11 +118,9 @@ public abstract class PreviewVersionPackage extends Package public void saveProperties(Properties props) {
super.saveProperties(props);
- // The major revision is getRevision(), already handled by Package.
- assert mPreviewVersion.getMajor() == getRevision();
-
- props.setProperty(PkgProps.PKG_MINOR_REV, Integer.toString(mPreviewVersion.getMinor()));
- props.setProperty(PkgProps.PKG_MICRO_REV, Integer.toString(mPreviewVersion.getMicro()));
+ props.setProperty(PkgProps.PKG_MAJOR_REV, Integer.toString(mPreviewVersion.getMajor()));
+ props.setProperty(PkgProps.PKG_MINOR_REV, Integer.toString(mPreviewVersion.getMinor()));
+ props.setProperty(PkgProps.PKG_MICRO_REV, Integer.toString(mPreviewVersion.getMicro()));
props.setProperty(PkgProps.PKG_PREVIEW_REV, Integer.toString(mPreviewVersion.getPreview()));
}
@@ -142,10 +140,10 @@ public abstract class PreviewVersionPackage extends Package if (!super.equals(obj)) {
return false;
}
- if (!(obj instanceof PreviewVersionPackage)) {
+ if (!(obj instanceof FullRevisionPackage)) {
return false;
}
- PreviewVersionPackage other = (PreviewVersionPackage) obj;
+ FullRevisionPackage other = (FullRevisionPackage) obj;
if (mPreviewVersion == null) {
if (other.mPreviewVersion != null) {
return false;
@@ -155,4 +153,38 @@ public abstract class PreviewVersionPackage extends Package }
return true;
}
+
+ /**
+ * Computes whether the given package is a suitable update for the current package.
+ * <p/>
+ * A specific case here is that a release package can update a preview, whereas
+ * a preview can only update another preview.
+ * <p/>
+ * {@inheritDoc}
+ */
+ @Override
+ public UpdateInfo canBeUpdatedBy(Package replacementPackage) {
+ if (replacementPackage == null) {
+ return UpdateInfo.INCOMPATIBLE;
+ }
+
+ // check they are the same item, ignoring the preview bit.
+ if (!sameItemAs(replacementPackage, true /*ignorePreviews*/)) {
+ return UpdateInfo.INCOMPATIBLE;
+ }
+
+ // a preview cannot update a non-preview
+ if (!getRevision().isPreview() && replacementPackage.getRevision().isPreview()) {
+ return UpdateInfo.INCOMPATIBLE;
+ }
+
+ // check revision number
+ if (replacementPackage.getRevision().compareTo(this.getRevision()) > 0) {
+ return UpdateInfo.UPDATE;
+ }
+
+ // not an upgrade but not incompatible either.
+ return UpdateInfo.NOT_UPDATE;
+ }
+
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/IFullRevisionProvider.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/IFullRevisionProvider.java new file mode 100755 index 0000000..497b2f8 --- /dev/null +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/IFullRevisionProvider.java @@ -0,0 +1,43 @@ +/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sdklib.internal.repository.packages;
+
+
+
+/**
+ * Interface for packages that provide a {@link FullRevision},
+ * which is a multi-part revision number (major.minor.micro) and an optional preview revision.
+ * <p/>
+ * This interface is a tag. It indicates that {@link Package#getRevision()} returns a
+ * {@link FullRevision} instead of a limited {@link MajorRevision}. <br/>
+ * The preview version number is available via {@link Package#getRevision()}.
+ */
+public interface IFullRevisionProvider {
+
+ /**
+ * Returns whether the give package represents the same item as the current package.
+ * <p/>
+ * Two packages are considered the same if they represent the same thing, except for the
+ * revision number.
+ * @param pkg the package to compare
+ * @param ignorePreviews true if 2 packages should be considered the same even if one
+ * is a preview and the other one is not.
+ * @return true if the item are the same.
+ */
+ public abstract boolean sameItemAs(Package pkg, boolean ignorePreviews);
+
+}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/IPreviewVersionProvider.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/MajorRevision.java index 5a9f8a0..2678b1f 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/IPreviewVersionProvider.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/MajorRevision.java @@ -1,5 +1,5 @@ /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,17 +16,22 @@ package com.android.sdklib.internal.repository.packages;
-import com.android.annotations.NonNull;
-
/**
- * Interface for packages that provide a {@link PreviewVersion},
- * which is a multi-part revision number (major.minor.micro) and an optional preview revision.
+ * Package revision number composed of a <em>single</em> major revision.
+ * <p/>
+ * Contrary to a {@link FullRevision}, a {@link MajorRevision} does not
+ * provide minor, micro and preview revision numbers -- these are all
+ * set to zero.
*/
-public interface IPreviewVersionProvider {
+public class MajorRevision extends FullRevision {
+
+ public MajorRevision(int major) {
+ super(major, 0, 0);
+ }
- /**
- * Returns a {@link PreviewVersion} for this package. Never null.
- */
- public abstract @NonNull PreviewVersion getPreviewVersion();
+ @Override
+ public String toString() {
+ return super.toShortString();
+ }
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/Package.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/Package.java index 6760747..9c2d30b 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/Package.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/Package.java @@ -58,7 +58,7 @@ import java.util.Properties; */
public abstract class Package implements IDescription, Comparable<Package> {
- private final int mRevision;
+ private final MajorRevision mRevision;
private final String mObsolete;
private final String mLicense;
private final String mDescription;
@@ -104,7 +104,8 @@ public abstract class Package implements IDescription, Comparable<Package> { */
Package(SdkSource source, Node packageNode, String nsUri, Map<String,String> licenses) {
mSource = source;
- mRevision = XmlParserUtils.getXmlInt (packageNode, SdkRepoConstants.NODE_REVISION, 0);
+ mRevision = new MajorRevision(
+ XmlParserUtils.getXmlInt (packageNode, SdkRepoConstants.NODE_REVISION, 0));
mDescription = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_DESCRIPTION);
mDescUrl = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_DESC_URL);
mReleaseNote = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_RELEASE_NOTE);
@@ -144,8 +145,8 @@ public abstract class Package implements IDescription, Comparable<Package> { descUrl = "";
}
- mRevision = Integer.parseInt(
- getProperty(props, PkgProps.PKG_REVISION, Integer.toString(revision)));
+ mRevision = new MajorRevision(Integer.parseInt(
+ getProperty(props, PkgProps.PKG_MAJOR_REV, Integer.toString(revision))));
mLicense = getProperty(props, PkgProps.PKG_LICENSE, license);
mDescription = getProperty(props, PkgProps.PKG_DESC, description);
mDescUrl = getProperty(props, PkgProps.PKG_DESC_URL, descUrl);
@@ -222,7 +223,7 @@ public abstract class Package implements IDescription, Comparable<Package> { * These properties will later be give the constructor that takes a {@link Properties} object.
*/
public void saveProperties(Properties props) {
- props.setProperty(PkgProps.PKG_REVISION, Integer.toString(mRevision));
+ props.setProperty(PkgProps.PKG_MAJOR_REV, Integer.toString(mRevision.getMajor()));
if (mLicense != null && mLicense.length() > 0) {
props.setProperty(PkgProps.PKG_LICENSE, mLicense);
}
@@ -328,7 +329,7 @@ public abstract class Package implements IDescription, Comparable<Package> { * Returns the revision, an int > 0, for all packages (platform, add-on, tool, doc).
* Can be 0 if this is a local package of unknown revision.
*/
- public int getRevision() {
+ public FullRevision getRevision() {
return mRevision;
}
@@ -484,8 +485,8 @@ public abstract class Package implements IDescription, Comparable<Package> { sb.append("\n");
}
- sb.append(String.format("Revision %1$d%2$s",
- getRevision(),
+ sb.append(String.format("Revision %1$s%2$s",
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : ""));
s = getDescUrl();
@@ -615,8 +616,8 @@ public abstract class Package implements IDescription, Comparable<Package> { * <p/>
* Two packages are considered the same if they represent the same thing, except for the
* revision number.
- * @param pkg the package to compare
- * @return true if the item
+ * @param pkg the package to compare.
+ * @return true if the item as equivalent.
*/
public abstract boolean sameItemAs(Package pkg);
@@ -638,12 +639,12 @@ public abstract class Package implements IDescription, Comparable<Package> { }
// check they are the same item.
- if (sameItemAs(replacementPackage) == false) {
+ if (!sameItemAs(replacementPackage)) {
return UpdateInfo.INCOMPATIBLE;
}
// check revision number
- if (replacementPackage.getRevision() > this.getRevision()) {
+ if (replacementPackage.getRevision().compareTo(this.getRevision()) > 0) {
return UpdateInfo.UPDATE;
}
@@ -652,7 +653,7 @@ public abstract class Package implements IDescription, Comparable<Package> { }
/**
- * Returns an ordering like this: <br/>
+ * Returns an ordering <b>suitable for display</b> like this: <br/>
* - Tools <br/>
* - Platform-Tools <br/>
* - Docs. <br/>
@@ -668,6 +669,10 @@ public abstract class Package implements IDescription, Comparable<Package> { * Important: this must NOT be used to compare if two packages are the same thing.
* This is achieved by {@link #sameItemAs(Package)} or {@link #canBeUpdatedBy(Package)}.
* <p/>
+ * The order done here is suitable for display, and this may not be the appropriate
+ * order when comparing whether packages are equal or of greater revision -- if you need
+ * to compare revisions, then use {@link #getRevision()}{@code .compareTo(rev)} directly.
+ * <p/>
* This {@link #compareTo(Package)} method is purely an implementation detail to
* perform the right ordering of the packages in the list of available or installed packages.
* <p/>
@@ -679,7 +684,8 @@ public abstract class Package implements IDescription, Comparable<Package> { String s1 = this.comparisonKey();
String s2 = other.comparisonKey();
- return s1.compareTo(s2);
+ int r = s1.compareTo(s2);
+ return r;
}
/**
@@ -728,7 +734,8 @@ public abstract class Package implements IDescription, Comparable<Package> { // We insert the package version here because it is more important
- // than the revision number. We want package version to be sorted
+ // than the revision number.
+ // In the list display, we want package version to be sorted
// top-down, so we'll use 10k-api as the sorting key. The day we
// reach 10k APIs, we'll need to revisit this.
sb.append("|v:"); //$NON-NLS-1$
@@ -743,10 +750,18 @@ public abstract class Package implements IDescription, Comparable<Package> { // Append revision number
sb.append("|r:"); //$NON-NLS-1$
- if (this instanceof IPreviewVersionProvider) {
- sb.append(String.format("%1$s", ((IPreviewVersionProvider) this).getPreviewVersion()));
+ FullRevision rev = getRevision();
+ sb.append(rev.getMajor()).append('.')
+ .append(rev.getMinor()).append('.')
+ .append(rev.getMicro()).append('.');
+ // Hack: When comparing packages for installation purposes, we want to treat
+ // "final releases" packages as more important than rc/preview packages.
+ // However like for the API level above, when sorting for list display purposes
+ // we want the final release package listed before its rc/preview packages.
+ if (rev.isPreview()) {
+ sb.append(rev.getPreview());
} else {
- sb.append(String.format("%1$04d", getRevision())); //$NON-NLS-1$
+ sb.append('0'); // 0=Final (!preview), to make "18.0" < "18.1" (18 Final < 18 RC1)
}
sb.append('|');
@@ -759,7 +774,7 @@ public abstract class Package implements IDescription, Comparable<Package> { int result = 1;
result = prime * result + Arrays.hashCode(mArchives);
result = prime * result + ((mObsolete == null) ? 0 : mObsolete.hashCode());
- result = prime * result + mRevision;
+ result = prime * result + mRevision.hashCode();
result = prime * result + ((mSource == null) ? 0 : mSource.hashCode());
return result;
}
@@ -786,7 +801,7 @@ public abstract class Package implements IDescription, Comparable<Package> { } else if (!mObsolete.equals(other.mObsolete)) {
return false;
}
- if (mRevision != other.mRevision) {
+ if (!mRevision.equals(other.mRevision)) {
return false;
}
if (mSource == null) {
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformPackage.java index 2f75610..6efb620 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformPackage.java @@ -222,13 +222,13 @@ public class PlatformPackage extends MinToolsPackage if (mVersion.isPreview()) {
s = String.format("SDK Platform Android %1$s Preview, revision %2$s%3$s",
getVersionName(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : ""); //$NON-NLS-2$
} else {
s = String.format("SDK Platform Android %1$s, API %2$d, revision %3$s%4$s",
getVersionName(),
mVersion.getApiLevel(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : ""); //$NON-NLS-2$
}
@@ -249,8 +249,8 @@ public class PlatformPackage extends MinToolsPackage }
if (s.indexOf("revision") == -1) {
- s += String.format("\nRevision %1$d%2$s",
- getRevision(),
+ s += String.format("\nRevision %1$s%2$s",
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformToolPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformToolPackage.java index 2566ce3..fdacfcc 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformToolPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/PlatformToolPackage.java @@ -39,10 +39,12 @@ import java.util.Set; /** * Represents a platform-tool XML node in an SDK repository. */ -public class PlatformToolPackage extends PreviewVersionPackage { +public class PlatformToolPackage extends FullRevisionPackage { /** The value returned by {@link PlatformToolPackage#installId()}. */ public static final String INSTALL_ID = "platform-tools"; //$NON-NLS-1$ + /** The value returned by {@link PlatformToolPackage#installId()}. */ + public static final String INSTALL_ID_PREVIEW = "platform-tools-preview"; //$NON-NLS-1$ /** * Creates a new platform-tool package from the attributes and elements of the given XML node. @@ -153,13 +155,18 @@ public class PlatformToolPackage extends PreviewVersionPackage { /** * Returns a string identifier to install this package from the command line. - * For platform-tools, we use "platform-tools" since this package type is unique. + * For platform-tools, we use "platform-tools" or "platform-tools-preview" since + * this package type is unique. * <p/> * {@inheritDoc} */ @Override public String installId() { - return INSTALL_ID; + if (getRevision().isPreview()) { + return INSTALL_ID_PREVIEW; + } else { + return INSTALL_ID; + } } /** @@ -179,7 +186,7 @@ public class PlatformToolPackage extends PreviewVersionPackage { @Override public String getShortDescription() { return String.format("Android SDK Platform-tools, revision %1$s%2$s", - getPreviewVersion().toShortString(), + getRevision().toShortString(), isObsolete() ? " (Obsolete)" : ""); } @@ -193,7 +200,7 @@ public class PlatformToolPackage extends PreviewVersionPackage { if (s.indexOf("revision") == -1) { s += String.format("\nRevision %1$s%2$s", - getPreviewVersion().toShortString(), + getRevision().toShortString(), isObsolete() ? " (Obsolete)" : ""); } @@ -215,10 +222,28 @@ public class PlatformToolPackage extends PreviewVersionPackage { return new File(osSdkRoot, SdkConstants.FD_PLATFORM_TOOLS); } + /** + * Check whether 2 platform-tool packages are the same <em>and</em> have the + * same preview bit. + */ @Override public boolean sameItemAs(Package pkg) { + return sameItemAs(pkg, false /*ignorePreviews*/); + } + + @Override + public boolean sameItemAs(Package pkg, boolean ignorePreviews) { // only one platform-tool package so any platform-tool package is the same item. - return pkg instanceof PlatformToolPackage; + if (pkg instanceof PlatformToolPackage) { + if (ignorePreviews) { + return true; + } else { + // however previews can only match previews by default, unless we ignore that check. + return ((PlatformToolPackage) pkg).getRevision().isPreview() == + getRevision().isPreview(); + } + } + return false; } /** diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SamplePackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SamplePackage.java index e95c12e..59d6adc 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SamplePackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SamplePackage.java @@ -222,10 +222,10 @@ public class SamplePackage extends MinToolsPackage */
@Override
public String getShortDescription() {
- String s = String.format("Samples for SDK API %1$s%2$s, revision %3$d%4$s",
+ String s = String.format("Samples for SDK API %1$s%2$s, revision %3$s%4$s",
mVersion.getApiString(),
mVersion.isPreview() ? " Preview" : "",
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
return s;
}
@@ -244,8 +244,8 @@ public class SamplePackage extends MinToolsPackage }
if (s.indexOf("revision") == -1) {
- s += String.format("\nRevision %1$d%2$s",
- getRevision(),
+ s += String.format("\nRevision %1$s%2$s",
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SourcePackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SourcePackage.java index cf280f8..fc4d8af 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SourcePackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SourcePackage.java @@ -227,12 +227,12 @@ public class SourcePackage extends Package implements IAndroidVersionProvider { if (mVersion.isPreview()) {
return String.format("Sources for Android '%1$s' Preview SDK, revision %2$s%3$s",
mVersion.getCodename(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
} else {
return String.format("Sources for Android SDK, API %1$d, revision %2$s%3$s",
mVersion.getApiLevel(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
}
@@ -251,8 +251,8 @@ public class SourcePackage extends Package implements IAndroidVersionProvider { }
if (s.indexOf("revision") == -1) {
- s += String.format("\nRevision %1$d%2$s",
- getRevision(),
+ s += String.format("\nRevision %1$s%2$s",
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SystemImagePackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SystemImagePackage.java index e1e441c..963b80e 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SystemImagePackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/SystemImagePackage.java @@ -254,7 +254,7 @@ public class SystemImagePackage extends Package return String.format("%1$s System Image, Android API %2$s, revision %3$s%4$s",
getAbiDisplayName(),
mVersion.getApiString(),
- getRevision(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
@@ -272,8 +272,8 @@ public class SystemImagePackage extends Package }
if (s.indexOf("revision") == -1) {
- s += String.format("\nRevision %1$d%2$s",
- getRevision(),
+ s += String.format("\nRevision %1$s%2$s",
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java index 763ed43..c34a3d0 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/packages/ToolPackage.java @@ -44,10 +44,12 @@ import java.util.regex.Pattern; /**
* Represents a tool XML node in an SDK repository.
*/
-public class ToolPackage extends PreviewVersionPackage implements IMinPlatformToolsDependency {
+public class ToolPackage extends FullRevisionPackage implements IMinPlatformToolsDependency {
/** The value returned by {@link ToolPackage#installId()}. */
public static final String INSTALL_ID = "tools"; //$NON-NLS-1$
+ /** The value returned by {@link ToolPackage#installId()}. */
+ private static final String INSTALL_ID_PREVIEW = "tools-preview"; //$NON-NLS-1$
/**
* The minimal revision of the platform-tools package required by this package
@@ -163,13 +165,17 @@ public class ToolPackage extends PreviewVersionPackage implements IMinPlatformTo /**
* Returns a string identifier to install this package from the command line.
- * For tools, we use "tools" since this package is unique.
+ * For tools, we use "tools" or "tools-preview" since this package is unique.
* <p/>
* {@inheritDoc}
*/
@Override
public String installId() {
- return INSTALL_ID;
+ if (getRevision().isPreview()) {
+ return INSTALL_ID_PREVIEW;
+ } else {
+ return INSTALL_ID;
+ }
}
/**
@@ -189,7 +195,7 @@ public class ToolPackage extends PreviewVersionPackage implements IMinPlatformTo @Override
public String getShortDescription() {
return String.format("Android SDK Tools, revision %1$s%2$s",
- getPreviewVersion().toShortString(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
@@ -203,7 +209,7 @@ public class ToolPackage extends PreviewVersionPackage implements IMinPlatformTo if (s.indexOf("revision") == -1) {
s += String.format("\nRevision %1$s%2$s",
- getPreviewVersion().toShortString(),
+ getRevision().toShortString(),
isObsolete() ? " (Obsolete)" : "");
}
@@ -225,10 +231,29 @@ public class ToolPackage extends PreviewVersionPackage implements IMinPlatformTo return new File(osSdkRoot, SdkConstants.FD_TOOLS);
}
+ /**
+ * Check whether 2 tool packages are the same <em>and</em> have the
+ * same preview bit.
+ */
@Override
public boolean sameItemAs(Package pkg) {
+ // Only one tool package so any tool package is the same item
+ return sameItemAs(pkg, false /*ignorePreviews*/);
+ }
+
+ @Override
+ public boolean sameItemAs(Package pkg, boolean ignorePreviews) {
// only one tool package so any tool package is the same item.
- return pkg instanceof ToolPackage;
+ if (pkg instanceof ToolPackage) {
+ if (ignorePreviews) {
+ return true;
+ } else {
+ // however previews can only match previews by default, unless we ignore that check.
+ return ((ToolPackage) pkg).getRevision().isPreview() ==
+ getRevision().isPreview();
+ }
+ }
+ return false;
}
@Override
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 a570153..5b39e89 100755 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/PkgProps.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/PkgProps.java @@ -29,8 +29,7 @@ package com.android.sdklib.repository; public class PkgProps {
// Base Package
-
- public static final String PKG_REVISION = "Pkg.Revision"; //$NON-NLS-1$
+ public static final String PKG_MAJOR_REV = "Pkg.Revision"; //$NON-NLS-1$
public static final String PKG_LICENSE = "Pkg.License"; //$NON-NLS-1$
public static final String PKG_DESC = "Pkg.Desc"; //$NON-NLS-1$
public static final String PKG_DESC_URL = "Pkg.DescUrl"; //$NON-NLS-1$
@@ -39,17 +38,17 @@ public class PkgProps { public static final String PKG_SOURCE_URL = "Pkg.SourceUrl"; //$NON-NLS-1$
public static final String PKG_OBSOLETE = "Pkg.Obsolete"; //$NON-NLS-1$
+ // FullRevision
+
+ public static final String PKG_MINOR_REV = "Pkg.MinorRev"; //$NON-NLS-1$
+ public static final String PKG_MICRO_REV = "Pkg.MicroRev"; //$NON-NLS-1$
+ public static final String PKG_PREVIEW_REV = "Pkg.PreviewRev"; //$NON-NLS-1$
+
// AndroidVersion
public static final String VERSION_API_LEVEL = "AndroidVersion.ApiLevel";//$NON-NLS-1$
public static final String VERSION_CODENAME = "AndroidVersion.CodeName";//$NON-NLS-1$
- // PreviewVersion
-
- public static final String PKG_MINOR_REV = "PreviewVersion.MinorRev";//$NON-NLS-1$
- public static final String PKG_MICRO_REV = "PreviewVersion.MicroRev";//$NON-NLS-1$
- public static final String PKG_PREVIEW_REV = "PreviewVersion.Preview"; //$NON-NLS-1$
-
// AddonPackage
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionPackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionPackageTest.java new file mode 100755 index 0000000..63e1d05 --- /dev/null +++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionPackageTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.sdklib.internal.repository.packages; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; + +import junit.framework.TestCase; + +public class FullRevisionPackageTest extends TestCase { + + public void testCompareTo() throws Exception { + // Test order of full revision packages. + // + // Note that Package.compareTo() is designed to return the desired + // ordering for a list display and as such a final/release package + // needs to be listed before its rc/preview package. + // + // This differs from the order used by FullRevision.compareTo(). + + ArrayList<Package> list = new ArrayList<Package>(); + + list.add(new MockToolPackage(null, new FullRevision(1, 0, 0, 0), 8)); + list.add(new MockToolPackage(null, new FullRevision(1, 0, 0, 1), 8)); + list.add(new MockToolPackage(null, new FullRevision(1, 0, 1, 0), 8)); + list.add(new MockToolPackage(null, new FullRevision(1, 0, 1, 1), 8)); + list.add(new MockToolPackage(null, new FullRevision(1, 1, 0, 0), 8)); + list.add(new MockToolPackage(null, new FullRevision(1, 1, 0, 1), 8)); + list.add(new MockToolPackage(null, new FullRevision(2, 1, 1, 0), 8)); + list.add(new MockToolPackage(null, new FullRevision(2, 1, 1, 1), 8)); + + Collections.sort(list); + + assertEquals( + "[Android SDK Tools, revision 1, " + + "Android SDK Tools, revision 1 rc1, " + + "Android SDK Tools, revision 1.0.1, " + + "Android SDK Tools, revision 1.0.1 rc1, " + + "Android SDK Tools, revision 1.1, " + + "Android SDK Tools, revision 1.1 rc1, " + + "Android SDK Tools, revision 2.1.1, " + + "Android SDK Tools, revision 2.1.1 rc1]", + Arrays.toString(list.toArray())); + } +} diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PreviewVersionTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionTest.java index daa4704..97e76bb 100755 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PreviewVersionTest.java +++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/FullRevisionTest.java @@ -18,7 +18,7 @@ package com.android.sdklib.internal.repository.packages; import junit.framework.TestCase; -public class PreviewVersionTest extends TestCase { +public class FullRevisionTest extends TestCase { @Override protected void setUp() throws Exception { @@ -30,26 +30,26 @@ public class PreviewVersionTest extends TestCase { super.tearDown(); } - public final void testPreviewVersion() { - PreviewVersion p = new PreviewVersion(5); + public final void testFullRevision() { + FullRevision p = new FullRevision(5); assertEquals(5, p.getMajor()); - assertEquals(PreviewVersion.IMPLICIT_MINOR_REV, p.getMinor()); - assertEquals(PreviewVersion.IMPLICIT_MICRO_REV, p.getMicro()); - assertEquals(PreviewVersion.NOT_A_PREVIEW, p.getPreview()); + assertEquals(FullRevision.IMPLICIT_MINOR_REV, p.getMinor()); + assertEquals(FullRevision.IMPLICIT_MICRO_REV, p.getMicro()); + assertEquals(FullRevision.NOT_A_PREVIEW, p.getPreview()); assertFalse (p.isPreview()); assertEquals("5", p.toShortString()); assertEquals("5.0.0", p.toString()); - p = new PreviewVersion(5, 0, 0, 6); + p = new FullRevision(5, 0, 0, 6); assertEquals(5, p.getMajor()); - assertEquals(PreviewVersion.IMPLICIT_MINOR_REV, p.getMinor()); - assertEquals(PreviewVersion.IMPLICIT_MICRO_REV, p.getMicro()); + assertEquals(FullRevision.IMPLICIT_MINOR_REV, p.getMinor()); + assertEquals(FullRevision.IMPLICIT_MICRO_REV, p.getMicro()); assertEquals(6, p.getPreview()); assertTrue (p.isPreview()); assertEquals("5 rc6", p.toShortString()); assertEquals("5.0.0 rc6", p.toString()); - p = new PreviewVersion(6, 7, 0); + p = new FullRevision(6, 7, 0); assertEquals(6, p.getMajor()); assertEquals(7, p.getMinor()); assertEquals(0, p.getMicro()); @@ -58,7 +58,7 @@ public class PreviewVersionTest extends TestCase { assertEquals("6.7", p.toShortString()); assertEquals("6.7.0", p.toString()); - p = new PreviewVersion(10, 11, 12, PreviewVersion.NOT_A_PREVIEW); + p = new FullRevision(10, 11, 12, FullRevision.NOT_A_PREVIEW); assertEquals(10, p.getMajor()); assertEquals(11, p.getMinor()); assertEquals(12, p.getMicro()); @@ -67,7 +67,7 @@ public class PreviewVersionTest extends TestCase { assertEquals("10.11.12", p.toShortString()); assertEquals("10.11.12", p.toString()); - p = new PreviewVersion(10, 11, 12, 13); + p = new FullRevision(10, 11, 12, 13); assertEquals(10, p.getMajor()); assertEquals(11, p.getMinor()); assertEquals(12, p.getMicro()); @@ -78,13 +78,13 @@ public class PreviewVersionTest extends TestCase { } public final void testCompareTo() { - PreviewVersion s4 = new PreviewVersion(4); - PreviewVersion i4 = new PreviewVersion(4); - PreviewVersion g5 = new PreviewVersion(5, 1, 0, 6); - PreviewVersion y5 = new PreviewVersion(5); - PreviewVersion c5 = new PreviewVersion(5, 1, 0, 6); - PreviewVersion o5 = new PreviewVersion(5, 0, 0, 7); - PreviewVersion p5 = new PreviewVersion(5, 1, 0, 0); + FullRevision s4 = new FullRevision(4); + FullRevision i4 = new FullRevision(4); + FullRevision g5 = new FullRevision(5, 1, 0, 6); + FullRevision y5 = new FullRevision(5); + FullRevision c5 = new FullRevision(5, 1, 0, 6); + FullRevision o5 = new FullRevision(5, 0, 0, 7); + FullRevision p5 = new FullRevision(5, 1, 0, 0); assertEquals(s4, i4); // 4.0.0-0 == 4.0.0-0 assertEquals(g5, c5); // 5.1.0-6 == 5.1.0-6 diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockEmptyPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockEmptyPackage.java index f1e4344..5c7bfe3 100755 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockEmptyPackage.java +++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockEmptyPackage.java @@ -134,7 +134,7 @@ public class MockEmptyPackage extends Package { public String getShortDescription() { StringBuilder sb = new StringBuilder(this.getClass().getSimpleName()); sb.append(" '").append(mTestHandle).append('\''); - if (getRevision() > 0) { + if (getRevision().getMajor() > 0) { sb.append(" rev=").append(getRevision()); } return sb.toString(); diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformToolPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformToolPackage.java index 0b46876..7ed5114 100755 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformToolPackage.java +++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockPlatformToolPackage.java @@ -67,11 +67,11 @@ public class MockPlatformToolPackage extends PlatformToolPackage { * <p/>
* By design, this creates a package with one and only one archive.
*/
- public MockPlatformToolPackage(SdkSource source, PreviewVersion previewVersion) {
+ public MockPlatformToolPackage(SdkSource source, FullRevision revision) {
super(
source, // source,
- createProps(previewVersion), // props,
- previewVersion.getMajor(),
+ createProps(revision), // props,
+ revision.getMajor(),
null, // license,
"desc", // description,
"url", // descUrl,
@@ -81,14 +81,14 @@ public class MockPlatformToolPackage extends PlatformToolPackage { );
}
- private static Properties createProps(PreviewVersion previewVersion) {
+ private static Properties createProps(FullRevision revision) {
Properties props = new Properties();
props.setProperty(PkgProps.PKG_MINOR_REV,
- Integer.toString(previewVersion.getMinor()));
+ Integer.toString(revision.getMinor()));
props.setProperty(PkgProps.PKG_MICRO_REV,
- Integer.toString(previewVersion.getMicro()));
+ Integer.toString(revision.getMicro()));
props.setProperty(PkgProps.PKG_PREVIEW_REV,
- Integer.toString(previewVersion.getPreview()));
+ Integer.toString(revision.getPreview()));
return props;
}
}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockToolPackage.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockToolPackage.java index e4bd9c6..cdccbb8 100755 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockToolPackage.java +++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/MockToolPackage.java @@ -69,12 +69,12 @@ public class MockToolPackage extends ToolPackage { */
public MockToolPackage(
SdkSource source,
- PreviewVersion previewVersion,
+ FullRevision revision,
int minPlatformToolsRev) {
super(
source, // source,
- createProps(previewVersion, minPlatformToolsRev), // props,
- previewVersion.getMajor(),
+ createProps(revision, minPlatformToolsRev), // props,
+ revision.getMajor(),
null, // license,
"desc", // description,
"url", // descUrl,
@@ -84,17 +84,17 @@ public class MockToolPackage extends ToolPackage { );
}
- private static Properties createProps(PreviewVersion previewVersion, int minPlatformToolsRev) {
+ private static Properties createProps(FullRevision revision, int minPlatformToolsRev) {
Properties props = new Properties();
props.setProperty(PkgProps.MIN_PLATFORM_TOOLS_REV,
Integer.toString((minPlatformToolsRev)));
- if (previewVersion != null) {
+ if (revision != null) {
props.setProperty(PkgProps.PKG_MINOR_REV,
- Integer.toString(previewVersion.getMinor()));
+ Integer.toString(revision.getMinor()));
props.setProperty(PkgProps.PKG_MICRO_REV,
- Integer.toString(previewVersion.getMicro()));
+ Integer.toString(revision.getMicro()));
props.setProperty(PkgProps.PKG_PREVIEW_REV,
- Integer.toString(previewVersion.getPreview()));
+ Integer.toString(revision.getPreview()));
}
return props;
}
diff --git a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PackageTest.java b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PackageTest.java index ce41a4d..cfe70c1 100755 --- a/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PackageTest.java +++ b/sdkmanager/libs/sdklib/tests/src/com/android/sdklib/internal/repository/packages/PackageTest.java @@ -136,7 +136,7 @@ public class PackageTest extends TestCase { Properties props = new Properties(); // Package properties - props.setProperty(PkgProps.PKG_REVISION, "42"); + props.setProperty(PkgProps.PKG_MAJOR_REV, "42"); props.setProperty(PkgProps.PKG_LICENSE, "The License"); props.setProperty(PkgProps.PKG_DESC, "Some description."); props.setProperty(PkgProps.PKG_DESC_URL, "http://description/url"); @@ -155,7 +155,7 @@ public class PackageTest extends TestCase { */ protected void testCreatedPackage(Package p) { // Package properties - assertEquals(42, p.getRevision()); + assertEquals("42", p.getRevision().toShortString()); assertEquals("The License", p.getLicense()); assertEquals("Some description.", p.getDescription()); assertEquals("http://description/url", p.getDescUrl()); |