diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-24 16:09:16 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-07-24 16:09:16 -0700 |
commit | 53ac3703af34fc2e7d80176488289e3beecbae42 (patch) | |
tree | 978019ac3ef92a4323d73a971ebedea903bee0e9 | |
parent | 5d50871ac781ab1457f3765feb22a01c75878e3c (diff) | |
parent | 559c623750b39221888e41e7c22d979b9dfccad3 (diff) | |
download | sdk-53ac3703af34fc2e7d80176488289e3beecbae42.zip sdk-53ac3703af34fc2e7d80176488289e3beecbae42.tar.gz sdk-53ac3703af34fc2e7d80176488289e3beecbae42.tar.bz2 |
am 1b742290: Merge change 8537 into donut
Merge commit '1b742290b6e2410744315280a2f6933585c7aac3'
* commit '1b742290b6e2410744315280a2f6933585c7aac3':
Fix the update check for doc packages.
-rwxr-xr-x | sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/DocPackage.java | 47 | ||||
-rwxr-xr-x | sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Package.java | 2 |
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;
}
|