aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2009-07-24 13:36:07 -0700
committerXavier Ducrohet <xav@android.com>2009-07-24 13:39:04 -0700
commitfa335b0e39fa1029acf9044f98edee593ba0b757 (patch)
tree2c4b3dcc40a3dc771b4f6ba5dc2af0a51509bcec
parent95eaa6428d3a6713d9242b9e9fa7a52ef58875e3 (diff)
downloadsdk-fa335b0e39fa1029acf9044f98edee593ba0b757.zip
sdk-fa335b0e39fa1029acf9044f98edee593ba0b757.tar.gz
sdk-fa335b0e39fa1029acf9044f98edee593ba0b757.tar.bz2
Fix the update check for doc packages.
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java47
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java2
2 files changed, 48 insertions, 1 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
index d146842..abd42fb 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java
@@ -140,4 +140,51 @@ public class DocPackage extends Package {
// only one doc package so any doc package is the same item.
return pkg instanceof DocPackage;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * The comparison between doc packages is a bit more complex so we override the default
+ * implementation.
+ * <p/>
+ * Docs are upgrade if they have a higher api, or a similar api but a higher revision.
+ * <p/>
+ * What makes this more complex is handling codename.
+ */
+ @Override
+ public UpdateInfo canBeUpdatedBy(Package replacementPackage) {
+ if (replacementPackage == null) {
+ return UpdateInfo.INCOMPATIBLE;
+ }
+
+ // check they are the same item.
+ if (sameItemAs(replacementPackage) == false) {
+ return UpdateInfo.INCOMPATIBLE;
+ }
+
+ DocPackage replacementDoc = (DocPackage)replacementPackage;
+
+ AndroidVersion replacementVersion = replacementDoc.getVersion();
+
+ // the new doc is an update if the api level is higher
+ if (replacementVersion.getApiLevel() > mVersion.getApiLevel()) {
+ return UpdateInfo.UPDATE;
+ }
+
+ // if it's the exactly same (including codename), we check the revision
+ if (replacementVersion.equals(mVersion) &&
+ replacementPackage.getRevision() > this.getRevision()) {
+ return UpdateInfo.UPDATE;
+ }
+
+ // else we check if they have the same api level and the new one is a preview, in which
+ // case it's also an update (since preview have the api level of the _previous_ version.
+ if (replacementVersion.getApiLevel() == mVersion.getApiLevel() &&
+ replacementVersion.isPreview()) {
+ 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/Package.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
index 369305a..1fcd6b1 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java
@@ -330,7 +330,7 @@ public abstract class Package implements IDescription {
*
* @see #sameItemAs(Package)
*/
- public final UpdateInfo canBeUpdatedBy(Package replacementPackage) {
+ public UpdateInfo canBeUpdatedBy(Package replacementPackage) {
if (replacementPackage == null) {
return UpdateInfo.INCOMPATIBLE;
}