SDK Manager: extra packages must respect min-tools-rev too.

SDK BUG 2040986

Change-Id: I2fb42327ff6d474fd8ad58fcd0725af3972ea026
This commit is contained in:
Raphael
2009-10-09 18:45:15 -07:00
parent 31d0121f68
commit cce3d0d9ba
6 changed files with 129 additions and 81 deletions

View File

@@ -536,7 +536,7 @@ final class UpdateChooserDialog extends Dialog {
// If there's no selection, just find the first missing dependency of any accepted
// package.
for (ArchiveInfo ai2 : mArchives) {
if (ai2.isAccepted()) {
if (ai2.isAccepted()) {
ArchiveInfo adep = ai2.getDependsOn();
if (adep != null && !adep.isAccepted()) {
error = String.format("Package '%1$s' depends on '%2$s'",

View File

@@ -19,6 +19,7 @@ package com.android.sdkuilib.internal.repository;
import com.android.sdklib.AndroidVersion;
import com.android.sdklib.internal.repository.AddonPackage;
import com.android.sdklib.internal.repository.Archive;
import com.android.sdklib.internal.repository.MinToolsPackage;
import com.android.sdklib.internal.repository.Package;
import com.android.sdklib.internal.repository.PlatformPackage;
import com.android.sdklib.internal.repository.RepoSource;
@@ -142,34 +143,36 @@ class UpdaterLogic {
if (pkg instanceof AddonPackage) {
AddonPackage addon = (AddonPackage) pkg;
return findAddonDependency(
return findPlatformDependency(
addon, outArchives, selectedArchives, remotePkgs, localPkgs);
} else if (pkg instanceof PlatformPackage) {
PlatformPackage platform = (PlatformPackage) pkg;
} else if (pkg instanceof MinToolsPackage) {
MinToolsPackage platformOrExtra = (MinToolsPackage) pkg;
return findPlatformDependency(
platform, outArchives, selectedArchives, remotePkgs, localPkgs);
return findToolsDependency(
platformOrExtra, outArchives, selectedArchives, remotePkgs, localPkgs);
}
return null;
}
/**
* A platform can have a min-tools-rev, in which case it depends on having a tools package
* of the requested revision.
* Resolves dependencies on tools.
*
* A platform or an extra package can both have a min-tools-rev, in which case it
* depends on having a tools package of the requested revision.
* Finds the tools dependency. If found, add it to the list of things to install.
* Returns the archive info dependency, if any.
*/
protected ArchiveInfo findPlatformDependency(PlatformPackage platform,
protected ArchiveInfo findToolsDependency(MinToolsPackage platformOrExtra,
ArrayList<ArchiveInfo> outArchives,
Collection<Archive> selectedArchives,
ArrayList<Package> remotePkgs,
Package[] localPkgs) {
// This is the requirement to match.
int rev = platform.getMinToolsRevision();
int rev = platformOrExtra.getMinToolsRevision();
if (rev == PlatformPackage.MIN_TOOLS_REV_NOT_SPECIFIED) {
if (rev == MinToolsPackage.MIN_TOOLS_REV_NOT_SPECIFIED) {
// Well actually there's no requirement.
return null;
}
@@ -234,11 +237,13 @@ class UpdaterLogic {
}
/**
* Resolves dependencies on platform.
*
* An addon depends on having a platform with the same API version.
* Finds the platform dependency. If found, add it to the list of things to install.
* Returns the archive info dependency, if any.
*/
protected ArchiveInfo findAddonDependency(AddonPackage addon,
protected ArchiveInfo findPlatformDependency(AddonPackage addon,
ArrayList<ArchiveInfo> outArchives,
Collection<Archive> selectedArchives,
ArrayList<Package> remotePkgs,

View File

@@ -59,13 +59,13 @@ public class UpdaterLogicTest extends TestCase {
// a2 depends on p2, which is not in the locals
Package[] locals = { p1, a1 };
assertNull(mul.findAddonDependency(a2, out, selected, remote, locals));
assertNull(mul.findPlatformDependency(a2, out, selected, remote, locals));
assertEquals(0, out.size());
// p2 is now selected, and should be scheduled for install in out
Archive p2_archive = p2.getArchives()[0];
selected.add(p2_archive);
ArchiveInfo ai2 = mul.findAddonDependency(a2, out, selected, remote, locals);
ArchiveInfo ai2 = mul.findPlatformDependency(a2, out, selected, remote, locals);
assertNotNull(ai2);
assertSame(p2_archive, ai2.getNewArchive());
assertEquals(1, out.size());
@@ -86,13 +86,13 @@ public class UpdaterLogicTest extends TestCase {
// p2 depends on t2, which is not locally installed
Package[] locals = { t1 };
assertNull(mul.findPlatformDependency(p2, out, selected, remote, locals));
assertNull(mul.findToolsDependency(p2, out, selected, remote, locals));
assertEquals(0, out.size());
// t2 is now selected and can be used as a dependency
Archive t2_archive = t2.getArchives()[0];
selected.add(t2_archive);
ArchiveInfo ai2 = mul.findPlatformDependency(p2, out, selected, remote, locals);
ArchiveInfo ai2 = mul.findToolsDependency(p2, out, selected, remote, locals);
assertNotNull(ai2);
assertSame(t2_archive, ai2.getNewArchive());
assertEquals(1, out.size());