aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager/libs
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2011-12-05 14:16:39 -0800
committerRaphael <raphael@google.com>2011-12-05 22:44:30 -0800
commit71e61cdf45ea1b12e8dd32d8b5c9edde9607818e (patch)
treef7fb136efada0c4a3e091fe35241c4426f4ac4ce /sdkmanager/libs
parent3f69598ca49f1672c6a1fd311fb4e3bac245512a (diff)
downloadsdk-71e61cdf45ea1b12e8dd32d8b5c9edde9607818e.zip
sdk-71e61cdf45ea1b12e8dd32d8b5c9edde9607818e.tar.gz
sdk-71e61cdf45ea1b12e8dd32d8b5c9edde9607818e.tar.bz2
SDK Manager: 'list sdk' show system images and source pkg.
This fixes the 'android list sdk' to output the system images and source packages in the list. Since there are no hard dependencies on them, they were not listed. The behavior is changed to: - 'android list sdk': display all potential and mandatory updates and their dependencies. - 'android list sdk --obsolete': display everything compatible on the remote sources. This allows users to install sources and system images from the command line: $ android list sdk -e -o $ android update sdk -u -o -t source,system-image # all $ android update sdk -u -o -t source-14,sysimg-14 # API14 Also, although system images are not mandatory (e.g. they are not hard dependencies of platforms), the heuristic is that if a platform doesn't have any system image of its own we'll suggest any matching sys-image we can find for either new platform or the currently highest installed one. SDK Bug: 21880 Change-Id: I4c47c6e60d885ebeaf181288db743b382fdb1618
Diffstat (limited to 'sdkmanager/libs')
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterLogic.java95
-rwxr-xr-xsdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java43
2 files changed, 123 insertions, 15 deletions
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterLogic.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterLogic.java
index 54dce6d..c24ec55 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterLogic.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/SdkUpdaterLogic.java
@@ -31,13 +31,14 @@ import com.android.sdklib.internal.repository.ITask;
import com.android.sdklib.internal.repository.ITaskMonitor;
import com.android.sdklib.internal.repository.MinToolsPackage;
import com.android.sdklib.internal.repository.Package;
+import com.android.sdklib.internal.repository.Package.UpdateInfo;
import com.android.sdklib.internal.repository.PlatformPackage;
import com.android.sdklib.internal.repository.PlatformToolPackage;
import com.android.sdklib.internal.repository.SamplePackage;
import com.android.sdklib.internal.repository.SdkSource;
import com.android.sdklib.internal.repository.SdkSources;
+import com.android.sdklib.internal.repository.SystemImagePackage;
import com.android.sdklib.internal.repository.ToolPackage;
-import com.android.sdklib.internal.repository.Package.UpdateInfo;
import java.util.ArrayList;
import java.util.Arrays;
@@ -63,6 +64,69 @@ class SdkUpdaterLogic {
}
/**
+ * Retrieves an unfiltered list of all remote archives.
+ * The archives are guaranteed to be compatible with the current platform.
+ */
+ public List<ArchiveInfo> getAllRemoteArchives(
+ SdkSources sources,
+ Package[] localPkgs,
+ boolean includeObsoletes) {
+
+ List<Package> remotePkgs = new ArrayList<Package>();
+ SdkSource[] remoteSources = sources.getAllSources();
+ fetchRemotePackages(remotePkgs, remoteSources);
+
+ ArrayList<Archive> archives = new ArrayList<Archive>();
+ for (Package remotePkg : remotePkgs) {
+ // Only look for non-obsolete updates unless requested to include them
+ if (includeObsoletes || !remotePkg.isObsolete()) {
+ // Found a suitable update. Only accept the remote package
+ // if it provides at least one compatible archive
+
+ addArchives:
+ for (Archive a : remotePkg.getArchives()) {
+ if (a.isCompatible()) {
+
+ // If we're trying to add a package for revision N,
+ // make sure we don't also have a package for revision N-1.
+ for (int i = archives.size() - 1; i >= 0; i--) {
+ Package pkgFound = archives.get(i).getParentPackage();
+ if (pkgFound.canBeUpdatedBy(remotePkg) == UpdateInfo.UPDATE) {
+ // This package can update one we selected earlier.
+ // Remove the one that can be updated by this new one.
+ archives.remove(i);
+ } else if (remotePkg.canBeUpdatedBy(pkgFound) == UpdateInfo.UPDATE) {
+ // There is a package in the list that is already better
+ // than the one we want to add, so don't add it.
+ break addArchives;
+ }
+ }
+
+ archives.add(a);
+ break;
+ }
+ }
+ }
+ }
+
+ ArrayList<ArchiveInfo> result = new ArrayList<ArchiveInfo>();
+
+ ArchiveInfo[] localArchives = createLocalArchives(localPkgs);
+
+ for (Archive a : archives) {
+ insertArchive(a,
+ result,
+ archives,
+ remotePkgs,
+ remoteSources,
+ localArchives,
+ false /*automated*/);
+ }
+
+ return result;
+ }
+
+ /**
* Compute which packages to install by taking the user selection
* and adding required packages as needed.
*
@@ -241,6 +305,35 @@ class SdkUpdaterLogic {
}
}
}
+
+ if (p instanceof PlatformPackage && (score >= currentPlatformScore)) {
+ // We just added a new platform *or* we are visiting the highest currently
+ // installed platform. In either case we want to make sure it either has
+ // its own system image or that we provide one by default.
+ PlatformPackage pp = (PlatformPackage) p;
+ if (pp.getIncludedAbi() == null) {
+ for (Package p2 : remotePkgs) {
+ if (!(p2 instanceof SystemImagePackage) ||
+ (p2.isObsolete() && !includeObsoletes)) {
+ continue;
+ }
+ SystemImagePackage sip = (SystemImagePackage) p2;
+ if (sip.getVersion().equals(pp.getVersion())) {
+ for (Archive a : sip.getArchives()) {
+ if (a.isCompatible()) {
+ insertArchive(a,
+ archives,
+ null /*selectedArchives*/,
+ remotePkgs,
+ remoteSources,
+ localArchives,
+ true /*automated*/);
+ }
+ }
+ }
+ }
+ }
+ }
}
if (suggestedDoc != null) {
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
index 6643dca..40ba59c 100755
--- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
+++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/UpdaterData.java
@@ -26,6 +26,7 @@ import com.android.sdklib.internal.avd.AvdManager;
import com.android.sdklib.internal.repository.AdbWrapper;
import com.android.sdklib.internal.repository.AddonPackage;
import com.android.sdklib.internal.repository.AddonsListFetcher;
+import com.android.sdklib.internal.repository.AddonsListFetcher.Site;
import com.android.sdklib.internal.repository.Archive;
import com.android.sdklib.internal.repository.ArchiveInstaller;
import com.android.sdklib.internal.repository.ITask;
@@ -41,7 +42,6 @@ import com.android.sdklib.internal.repository.SdkSource;
import com.android.sdklib.internal.repository.SdkSourceCategory;
import com.android.sdklib.internal.repository.SdkSources;
import com.android.sdklib.internal.repository.ToolPackage;
-import com.android.sdklib.internal.repository.AddonsListFetcher.Site;
import com.android.sdklib.repository.SdkAddonConstants;
import com.android.sdklib.repository.SdkAddonsListConstants;
import com.android.sdklib.repository.SdkRepoConstants;
@@ -717,18 +717,28 @@ public class UpdaterData implements IUpdaterData {
refreshSources(true);
loadRemoteAddonsList(new NullTaskMonitor(getSdkLog()));
+ List<ArchiveInfo> archives;
SdkUpdaterLogic ul = new SdkUpdaterLogic(this);
- List<ArchiveInfo> archives = ul.computeUpdates(
- null /*selectedArchives*/,
- getSources(),
- getLocalSdkParser().getPackages(),
- includeObsoletes);
- ul.addNewPlatforms(
- archives,
- getSources(),
- getLocalSdkParser().getPackages(),
- includeObsoletes);
+ if (includeObsoletes) {
+ archives = ul.getAllRemoteArchives(
+ getSources(),
+ getLocalSdkParser().getPackages(),
+ includeObsoletes);
+
+ } else {
+ archives = ul.computeUpdates(
+ null /*selectedArchives*/,
+ getSources(),
+ getLocalSdkParser().getPackages(),
+ includeObsoletes);
+
+ ul.addNewPlatforms(
+ archives,
+ getSources(),
+ getLocalSdkParser().getPackages(),
+ includeObsoletes);
+ }
Collections.sort(archives);
return archives;
@@ -1025,14 +1035,19 @@ public class UpdaterData implements IUpdaterData {
url = url.replaceAll("https://", "http://"); //$NON-NLS-1$ //$NON-NLS-2$
}
+ // Hook to bypass loading 3rd party addons lists.
+ boolean fetch3rdParties = System.getenv("SDK_SKIP_3RD_PARTIES") == null;
+
AddonsListFetcher fetcher = new AddonsListFetcher();
Site[] sites = fetcher.fetch(monitor, url);
if (sites != null) {
mSources.removeAll(SdkSourceCategory.ADDONS_3RD_PARTY);
- for (Site s : sites) {
- mSources.add(SdkSourceCategory.ADDONS_3RD_PARTY,
- new SdkAddonSource(s.getUrl(), s.getUiName()));
+ if (fetch3rdParties) {
+ for (Site s : sites) {
+ mSources.add(SdkSourceCategory.ADDONS_3RD_PARTY,
+ new SdkAddonSource(s.getUrl(), s.getUiName()));
+ }
}
mStateFetchRemoteAddonsList = 1;