com.android.sdklib.internal.repository.packages
Class BrokenPackage

java.lang.Object
  extended by com.android.sdklib.internal.repository.packages.Package
      extended by com.android.sdklib.internal.repository.packages.MajorRevisionPackage
          extended by com.android.sdklib.internal.repository.packages.BrokenPackage
All Implemented Interfaces:
IDescription, IExactApiLevelDependency, IMinApiLevelDependency, java.lang.Comparable<Package>

public class BrokenPackage
extends MajorRevisionPackage
implements IExactApiLevelDependency, IMinApiLevelDependency

Represents an SDK repository package that is incomplete. It has a distinct icon and a specific error that is supposed to help the user on how to fix it.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.android.sdklib.internal.repository.packages.Package
Package.License, Package.UpdateInfo
 
Field Summary
 
Fields inherited from interface com.android.sdklib.internal.repository.packages.IExactApiLevelDependency
API_LEVEL_INVALID
 
Fields inherited from interface com.android.sdklib.internal.repository.packages.IMinApiLevelDependency
MIN_API_LEVEL_NOT_SPECIFIED
 
Method Summary
 int getExactApiLevel()
          Returns the exact API level required by this package, if > 0, or IExactApiLevelDependency.API_LEVEL_INVALID if the value was missing.
 java.io.File getInstallFolder(java.lang.String osSdkRoot, SdkManager sdkManager)
          We should not be attempting to install a broken package.
 java.lang.String getListDescription()
          Returns a description of this package that is suitable for a list display.
 java.lang.String getLongDescription()
          Returns a long description for an IDescription.
 int getMinApiLevel()
          Returns the minimal API level required by this package, if > 0, or IMinApiLevelDependency.MIN_API_LEVEL_NOT_SPECIFIED if there is no such requirement.
 java.lang.String getShortDescription()
          Returns a short description for an IDescription.
 java.lang.String installId()
          Returns a string identifier to install this package from the command line.
 void postInstallHook(Archive archive, ITaskMonitor monitor, java.io.File installFolder)
          Computes a hash of the installed content (in case of successful install.) Hook called right after an archive has been installed.
 boolean preInstallHook(Archive archive, ITaskMonitor monitor, java.lang.String osSdkRoot, java.io.File installFolder)
          Hook called right before an archive is installed.
 boolean sameItemAs(Package pkg)
          Returns whether the give package represents the same item as the current package.
 void saveProperties(java.util.Properties props)
          Save the properties of the current packages in the given Properties object.
 
Methods inherited from class com.android.sdklib.internal.repository.packages.MajorRevisionPackage
canBeUpdatedBy, getRevision
 
Methods inherited from class com.android.sdklib.internal.repository.packages.Package
compareTo, comparisonKey, equals, getArchives, getDescription, getDescUrl, getLicense, getParentSource, getReleaseNote, getReleaseNoteUrl, hasArchive, hasCompatibleArchive, hashCode, initializeArchives, isLocal, isObsolete, postUnzipFileHook, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

saveProperties

public void saveProperties(java.util.Properties props)
Save the properties of the current packages in the given Properties object. These properties will later be given to a constructor that takes a Properties object.

Base implementation override: We don't actually save properties for a broken package.

Overrides:
saveProperties in class MajorRevisionPackage

getMinApiLevel

public int getMinApiLevel()
Returns the minimal API level required by this package, if > 0, or IMinApiLevelDependency.MIN_API_LEVEL_NOT_SPECIFIED if there is no such requirement.

Specified by:
getMinApiLevel in interface IMinApiLevelDependency

getExactApiLevel

public int getExactApiLevel()
Returns the exact API level required by this package, if > 0, or IExactApiLevelDependency.API_LEVEL_INVALID if the value was missing.

Specified by:
getExactApiLevel in interface IExactApiLevelDependency

installId

public java.lang.String installId()
Returns a string identifier to install this package from the command line. For broken packages, we return an empty string. These are not installable.

Returns a short, reasonably unique string identifier that can be used to identify this package when installing from the command-line interface. 'android list sdk' will show these IDs and then in turn they can be provided to 'android update sdk --no-ui --filter' to select some specific packages.

The identifiers must have the following properties:
- They must contain only simple alphanumeric characters.
- Commas, whitespace and any special character that could be obviously problematic to a shell interface should be avoided (so dash/underscore are OK, but things like colon, pipe or dollar should be avoided.)
- The name must be consistent across calls and reasonably unique for the package type. Collisions can occur but should be rare.
- Different package types should have a clearly different name pattern.
- The revision number should not be included, as this would prevent updates from being automated (which is the whole point.)
- It must remain reasonably human readable.
- If no such id can exist (for example for a local package that cannot be installed) then an empty string should be returned. Don't return null.

Important: This is not a strong unique identifier for the package. If you need a strong unique identifier, you should use Package.comparisonKey() and the Comparable interface.

Specified by:
installId in class Package

getListDescription

public java.lang.String getListDescription()
Returns a description of this package that is suitable for a list display.

Returns a description of this package that is suitable for a list display. Should not be empty. Must never be null.

Note that this is the "base" name for the package with no specific revision nor API mentioned. In contrast, Package.getShortDescription() should be used if you want more details such as the package revision number or the API, if applicable.

Specified by:
getListDescription in class Package

getShortDescription

public java.lang.String getShortDescription()
Returns a short description for an IDescription.

Specified by:
getShortDescription in interface IDescription
Specified by:
getShortDescription in class Package

getLongDescription

public java.lang.String getLongDescription()
Returns a long description for an IDescription. The long description uses what was given to the constructor. If it's missing, it will use whatever the XML contains for the <description> field, or the short description if the former is empty.

Specified by:
getLongDescription in interface IDescription
Overrides:
getLongDescription in class Package

getInstallFolder

public java.io.File getInstallFolder(java.lang.String osSdkRoot,
                                     SdkManager sdkManager)
We should not be attempting to install a broken package. Computes a potential installation folder if an archive of this package were to be installed right away in the given SDK root.

Some types of packages install in a fix location, for example docs and tools. In this case the returned folder may already exist with a different archive installed at the desired location.
For other packages types, such as add-on or platform, the folder name is only partially relevant to determine the content and thus a real check will be done to provide an existing or new folder depending on the current content of the SDK.

Note that the installer *will* create all directories returned here just before installation so this method must not attempt to create them.

Specified by:
getInstallFolder in class Package
Parameters:
osSdkRoot - The OS path of the SDK root folder.
sdkManager - An existing SDK manager to list current platforms and addons.
Returns:
A new File corresponding to the directory to use to install this package.

sameItemAs

public boolean sameItemAs(Package pkg)
Description copied from class: Package
Returns whether the give package represents the same item as the current package.

Two packages are considered the same if they represent the same thing, except for the revision number.

Specified by:
sameItemAs in class Package
Parameters:
pkg - the package to compare.
Returns:
true if the item as equivalent.

preInstallHook

public boolean preInstallHook(Archive archive,
                              ITaskMonitor monitor,
                              java.lang.String osSdkRoot,
                              java.io.File installFolder)
Description copied from class: Package
Hook called right before an archive is installed. The archive has already been downloaded successfully and will be installed in the directory specified by installFolder when this call returns.

The hook lets the package decide if installation of this specific archive should be continue. The installer will still install the remaining packages if possible.

The base implementation always return true.

Note that the installer *will* create all directories specified by Package.getInstallFolder(java.lang.String, com.android.sdklib.SdkManager) just before installation, so they must not be created here. This is also called before the previous install dir is removed so the previous content is still there during upgrade.

Overrides:
preInstallHook in class Package
Parameters:
archive - The archive that will be installed
monitor - The ITaskMonitor to display errors.
osSdkRoot - The OS path of the SDK root folder.
installFolder - The folder where the archive will be installed. Note that this is not the folder where the archive was temporary unzipped. The installFolder, if it exists, contains the old archive that will soon be replaced by the new one.
Returns:
True if installing this archive shall continue, false if it should be skipped.

postInstallHook

public void postInstallHook(Archive archive,
                            ITaskMonitor monitor,
                            java.io.File installFolder)
Computes a hash of the installed content (in case of successful install.) Hook called right after an archive has been installed.

Overrides:
postInstallHook in class Package
Parameters:
archive - The archive that has been installed.
monitor - The ITaskMonitor to display errors.
installFolder - The folder where the archive was successfully installed. Null if the installation failed, in case the archive needs to do some cleanup after preInstallHook.