From: Raphael Moll Date: Sat, 19 Feb 2011 01:02:29 +0000 (-0800) Subject: SDK Manager: fix extra package update detection. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=fcb38f8f3ee58bbac65340c4878f8ab66431ddb6;p=android-x86%2Fsdk.git SDK Manager: fix extra package update detection. Change-Id: Ie512a8cc75075987d1eb88dafd079e52083e2a3c --- 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 49236dc1e..3472544aa 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 @@ -394,19 +394,33 @@ public class ExtraPackage extends MinToolsPackage ExtraPackage ep = (ExtraPackage) pkg; // To be backward compatible, we need to support the old vendor-path form - if (ep.mPath != null && (ep.mVendor == null || ep.mVendor.length() == 0) && - mPath != null && mVendor != null) { - if (ep.mPath.equals(mVendor + "-" + mPath)) { //$NON-NLS-1$ + // in either the current or the remote package. + // + // The vendor test below needs to account for an old installed package + // (e.g. with an install path of vendor-name) that has then beeen updated + // in-place and thus when reloaded contains the vendor name in both the + // path and the vendor attributes. + if (ep.mPath != null && mPath != null && mVendor != null) { + if (ep.mPath.equals(mVendor + "-" + mPath) && //$NON-NLS-1$ + (ep.mVendor == null || ep.mVendor.length() == 0 + || ep.mVendor.equals(mVendor))) { + return true; + } + } + if (mPath != null && ep.mPath != null && ep.mVendor != null) { + if (mPath.equals(ep.mVendor + "-" + ep.mPath) && //$NON-NLS-1$ + (mVendor == null || mVendor.length() == 0 || mVendor.equals(ep.mVendor))) { return true; } } + if (!mPath.equals(ep.mPath)) { return false; } if ((mVendor == null && ep.mVendor == null) || - (mVendor != null && !mVendor.equals(ep.mVendor))) { - return false; + (mVendor != null && mVendor.equals(ep.mVendor))) { + return true; } } diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java index 8722e025d..54bc06884 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/RepoSourcesAdapter.java @@ -316,13 +316,13 @@ public class RepoSourcesAdapter { // get the installed packages Package[] installedPackages = mUpdaterData.getInstalledPackages(); + // we'll populate this package list with either upgrades or new packages. ArrayList filteredList = new ArrayList(); // for each remote packages, we look for an existing version. // If no existing version -> add to the list // if existing version but with older revision -> add it to the list for (Package remotePkg : remotePackages) { - boolean newPkg = true; // Obsolete packages are not offered as updates. if (remotePkg.isObsolete()) { @@ -332,20 +332,27 @@ public class RepoSourcesAdapter { // For all potential packages, we also make sure that there's an archive for // the current platform, or we simply skip them. if (remotePkg.hasCompatibleArchive()) { - for (Package installedPkg : installedPackages) { + boolean keepPkg = true; + + nextPkg: for (Package installedPkg : installedPackages) { UpdateInfo info = installedPkg.canBeUpdatedBy(remotePkg); - if (info == UpdateInfo.UPDATE) { - filteredList.add(remotePkg); - newPkg = false; - break; // there shouldn't be 2 revisions of the same package - } else if (info != UpdateInfo.INCOMPATIBLE) { - newPkg = false; - break; // there shouldn't be 2 revisions of the same package + switch(info) { + case UPDATE: + // The remote package is an update to an existing one. + // We're done looking. + keepPkg = true; + break nextPkg; + case NOT_UPDATE: + // The remote package is the same as one that is already installed. + keepPkg = false; + break; + case INCOMPATIBLE: + // We can't compare and decide on incompatible things. + break; } } - // if we have not found the same package, then we add it (it's a new package) - if (newPkg) { + if (keepPkg) { filteredList.add(remotePkg); } }