com.android.sdklib.internal.repository.updater
Class SdkUpdaterLogic

java.lang.Object
  extended by com.android.sdklib.internal.repository.updater.SdkUpdaterLogic

public class SdkUpdaterLogic
extends java.lang.Object

The logic to compute which packages to install, based on the choices made by the user. This adds required packages as needed.

When the user doesn't provide a selection, looks at local package to find those that can be updated and compute dependencies too.


Constructor Summary
SdkUpdaterLogic(IUpdaterData updaterData)
           
 
Method Summary
 void addNewPlatforms(java.util.Collection<ArchiveInfo> archives, SdkSources sources, Package[] localPkgs, boolean includeAll)
          Finds new packages that the user does not have in his/her local SDK and adds them to the list of archives to install.
 java.util.List<ArchiveInfo> computeUpdates(java.util.Collection<Archive> selectedArchives, SdkSources sources, Package[] localPkgs, boolean includeAll)
          Compute which packages to install by taking the user selection and adding required packages as needed.
 ArchiveInfo[] createLocalArchives(Package[] localPkgs)
          Create a array of ArchiveInfo based on all local (already installed) packages.
protected  void fetchRemotePackages(java.util.Collection<Package> remotePkgs, SdkSource[] remoteSources)
          Fetch all remote packages only if really needed.
 ArchiveInfo findExactApiLevelDependency(IExactApiLevelDependency pkg, java.util.Collection<ArchiveInfo> outArchives, java.util.Collection<Archive> selectedArchives, java.util.Collection<Package> remotePkgs, SdkSource[] remoteSources, ArchiveInfo[] localArchives)
          Resolves platform dependencies for add-ons.
protected  ArchiveInfo findMinApiLevelDependency(IMinApiLevelDependency pkg, java.util.Collection<ArchiveInfo> outArchives, java.util.Collection<Archive> selectedArchives, java.util.Collection<Package> remotePkgs, SdkSource[] remoteSources, ArchiveInfo[] localArchives)
          Resolves platform dependencies for extras.
 ArchiveInfo findPlatformDependency(IPlatformDependency pkg, java.util.Collection<ArchiveInfo> outArchives, java.util.Collection<Archive> selectedArchives, java.util.Collection<Package> remotePkgs, SdkSource[] remoteSources, ArchiveInfo[] localArchives)
          Resolves dependencies on platform for an addon.
 ArchiveInfo findPlatformToolsDependency(IMinPlatformToolsDependency pkg, java.util.Collection<ArchiveInfo> outArchives, java.util.Collection<Archive> selectedArchives, java.util.Collection<Package> remotePkgs, SdkSource[] remoteSources, ArchiveInfo[] localArchives)
          Resolves dependencies on platform-tools.
 ArchiveInfo findToolsDependency(IMinToolsDependency pkg, java.util.Collection<ArchiveInfo> outArchives, java.util.Collection<Archive> selectedArchives, java.util.Collection<Package> remotePkgs, SdkSource[] remoteSources, ArchiveInfo[] localArchives)
          Resolves dependencies on tools.
 java.util.List<ArchiveInfo> getAllRemoteArchives(SdkSources sources, Package[] localPkgs, boolean includeAll)
          Retrieves an unfiltered list of all remote archives.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SdkUpdaterLogic

public SdkUpdaterLogic(IUpdaterData updaterData)
Method Detail

getAllRemoteArchives

public java.util.List<ArchiveInfo> getAllRemoteArchives(SdkSources sources,
                                                        Package[] localPkgs,
                                                        boolean includeAll)
Retrieves an unfiltered list of all remote archives. The archives are guaranteed to be compatible with the current platform.


computeUpdates

public java.util.List<ArchiveInfo> computeUpdates(java.util.Collection<Archive> selectedArchives,
                                                  SdkSources sources,
                                                  Package[] localPkgs,
                                                  boolean includeAll)
Compute which packages to install by taking the user selection and adding required packages as needed. When the user doesn't provide a selection, looks at local packages to find those that can be updated and compute dependencies too.


addNewPlatforms

public void addNewPlatforms(java.util.Collection<ArchiveInfo> archives,
                            SdkSources sources,
                            Package[] localPkgs,
                            boolean includeAll)
Finds new packages that the user does not have in his/her local SDK and adds them to the list of archives to install.

The default is to only find "new" platforms, that is anything more recent than the highest platform currently installed. A side effect is that for an empty SDK install this will list *all* platforms available (since there's no "highest" installed platform.)

This also adds "silent" dependencies. For example the user probably needs to have at least one version of the build-tools package although there is nothing that directly depends on it. So if the user doesn't have any installed or selected version, selected the most recent one as a candidate for install.

Parameters:
archives - The in-out list of archives to install. Typically the list is not empty at first as it should contain any archives that is already scheduled for install. This method will add to the list.
sources - The list of all sources, to fetch them as necessary.
localPkgs - The list of all currently installed packages.
includeAll - When true, this will list all platforms. (included these lower than the highest installed one) as well as all obsolete packages of these platforms.

createLocalArchives

public ArchiveInfo[] createLocalArchives(Package[] localPkgs)
Create a array of ArchiveInfo based on all local (already installed) packages. The array is always non-null but may be empty.

The local ArchiveInfo are guaranteed to have one non-null archive that you can retrieve using ArchiveReplacement.getNewArchive().


findToolsDependency

public ArchiveInfo findToolsDependency(IMinToolsDependency pkg,
                                       java.util.Collection<ArchiveInfo> outArchives,
                                       java.util.Collection<Archive> selectedArchives,
                                       java.util.Collection<Package> remotePkgs,
                                       SdkSource[] remoteSources,
                                       ArchiveInfo[] localArchives)
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.


findPlatformToolsDependency

public ArchiveInfo findPlatformToolsDependency(IMinPlatformToolsDependency pkg,
                                               java.util.Collection<ArchiveInfo> outArchives,
                                               java.util.Collection<Archive> selectedArchives,
                                               java.util.Collection<Package> remotePkgs,
                                               SdkSource[] remoteSources,
                                               ArchiveInfo[] localArchives)
Resolves dependencies on platform-tools. A tool package can have a min-platform-tools-rev, in which case it depends on having a platform-tool package of the requested revision. Finds the platform-tool dependency. If found, add it to the list of things to install. Returns the archive info dependency, if any.


findPlatformDependency

public ArchiveInfo findPlatformDependency(IPlatformDependency pkg,
                                          java.util.Collection<ArchiveInfo> outArchives,
                                          java.util.Collection<Archive> selectedArchives,
                                          java.util.Collection<Package> remotePkgs,
                                          SdkSource[] remoteSources,
                                          ArchiveInfo[] localArchives)
Resolves dependencies on platform for an addon. An addon depends on having a platform with the same API level. Finds the platform dependency. If found, add it to the list of things to install. Returns the archive info dependency, if any.


findMinApiLevelDependency

protected ArchiveInfo findMinApiLevelDependency(IMinApiLevelDependency pkg,
                                                java.util.Collection<ArchiveInfo> outArchives,
                                                java.util.Collection<Archive> selectedArchives,
                                                java.util.Collection<Package> remotePkgs,
                                                SdkSource[] remoteSources,
                                                ArchiveInfo[] localArchives)
Resolves platform dependencies for extras. An extra depends on having a platform with a minimun API level. We try to return the highest API level available above the specified minimum. Note that installed packages have priority so if one installed platform satisfies the dependency, we'll use it even if there's a higher API platform available but not installed yet. Finds the platform dependency. If found, add it to the list of things to install. Returns the archive info dependency, if any.


findExactApiLevelDependency

public ArchiveInfo findExactApiLevelDependency(IExactApiLevelDependency pkg,
                                               java.util.Collection<ArchiveInfo> outArchives,
                                               java.util.Collection<Archive> selectedArchives,
                                               java.util.Collection<Package> remotePkgs,
                                               SdkSource[] remoteSources,
                                               ArchiveInfo[] localArchives)
Resolves platform dependencies for add-ons. An add-ons depends on having a platform with an exact specific API level. Finds the platform dependency. If found, add it to the list of things to install. Returns the archive info dependency, if any.


fetchRemotePackages

protected void fetchRemotePackages(java.util.Collection<Package> remotePkgs,
                                   SdkSource[] remoteSources)
Fetch all remote packages only if really needed.

This method takes a list of sources. Each source is only fetched once -- that is each source keeps the list of packages that we fetched from the remote XML file. If the list is null, it means this source has never been fetched so we'll do it once here. Otherwise we rely on the cached list of packages from this source.

This method also takes a remote package list as input, which it will fill out. If a source has already been fetched, we'll add its packages to the remote package list if they are not already present. Otherwise, the source will be fetched and the packages added to the list.

Parameters:
remotePkgs - An in-out list of packages available from remote sources. This list must not be null. It can be empty or already contain some packages.
remoteSources - A list of available remote sources to fetch from.