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

java.lang.Object
  extended by com.android.sdklib.internal.repository.packages.Package
      extended by com.android.sdklib.internal.repository.packages.FullRevisionPackage
          extended by com.android.sdklib.internal.repository.packages.PlatformToolPackage
All Implemented Interfaces:
IDescription, IFullRevisionProvider, java.lang.Comparable<Package>

public class PlatformToolPackage
extends FullRevisionPackage

Represents a platform-tool XML node in an SDK repository.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.android.sdklib.internal.repository.packages.Package
Package.License, Package.UpdateInfo
 
Field Summary
static java.lang.String INSTALL_ID
          The value returned by installId().
static java.lang.String INSTALL_ID_PREVIEW
          The value returned by installId().
 
Constructor Summary
  PlatformToolPackage(SdkSource source, org.w3c.dom.Node packageNode, java.lang.String nsUri, java.util.Map<java.lang.String,java.lang.String> licenses)
          Creates a new platform-tool package from the attributes and elements of the given XML node.
protected PlatformToolPackage(SdkSource source, java.util.Properties props, int revision, java.lang.String license, java.lang.String description, java.lang.String descUrl, Archive.Os archiveOs, Archive.Arch archiveArch, java.lang.String archiveOsPath)
           
 
Method Summary
static Package create(SdkSource source, java.util.Properties props, int revision, java.lang.String license, java.lang.String description, java.lang.String descUrl, Archive.Os archiveOs, Archive.Arch archiveArch, java.lang.String archiveOsPath)
          Manually create a new package with one archive and the given attributes or properties.
 java.io.File getInstallFolder(java.lang.String osSdkRoot, SdkManager sdkManager)
          Computes a potential installation folder if an archive of this package were to be installed right away in the given SDK root.
 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.
 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.
 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)
          Check whether 2 platform-tool packages are the same and have the same preview bit.
 boolean sameItemAs(Package pkg, FullRevision.PreviewComparison comparePreview)
          Returns whether the given package represents the same item as the current package.
 
Methods inherited from class com.android.sdklib.internal.repository.packages.FullRevisionPackage
canBeUpdatedBy, equals, getRevision, hashCode, saveProperties
 
Methods inherited from class com.android.sdklib.internal.repository.packages.Package
compareTo, comparisonKey, getArchives, getDescription, getDescUrl, getLicense, getParentSource, getReleaseNote, getReleaseNoteUrl, hasArchive, hasCompatibleArchive, initializeArchives, isLocal, isObsolete, postInstallHook, postUnzipFileHook, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INSTALL_ID

public static final java.lang.String INSTALL_ID
The value returned by installId().

See Also:
Constant Field Values

INSTALL_ID_PREVIEW

public static final java.lang.String INSTALL_ID_PREVIEW
The value returned by installId().

See Also:
Constant Field Values
Constructor Detail

PlatformToolPackage

public PlatformToolPackage(SdkSource source,
                           org.w3c.dom.Node packageNode,
                           java.lang.String nsUri,
                           java.util.Map<java.lang.String,java.lang.String> licenses)
Creates a new platform-tool package from the attributes and elements of the given XML node. This constructor should throw an exception if the package cannot be created.

Parameters:
source - The SdkSource where this is loaded from.
packageNode - The XML element being parsed.
nsUri - The namespace URI of the originating XML document, to be able to deal with parameters that vary according to the originating XML schema.
licenses - The licenses loaded from the XML originating document.

PlatformToolPackage

protected PlatformToolPackage(SdkSource source,
                              java.util.Properties props,
                              int revision,
                              java.lang.String license,
                              java.lang.String description,
                              java.lang.String descUrl,
                              Archive.Os archiveOs,
                              Archive.Arch archiveArch,
                              java.lang.String archiveOsPath)
Method Detail

create

public static Package create(SdkSource source,
                             java.util.Properties props,
                             int revision,
                             java.lang.String license,
                             java.lang.String description,
                             java.lang.String descUrl,
                             Archive.Os archiveOs,
                             Archive.Arch archiveArch,
                             java.lang.String archiveOsPath)
Manually create a new package with one archive and the given attributes or properties. This is used to create packages from local directories in which case there must be one archive which URL is the actual target location.

By design, this creates a package with one and only one archive.


installId

public java.lang.String installId()
Returns a string identifier to install this package from the command line. For platform-tools, we use "platform-tools" or "platform-tools-preview" since this package type is unique.

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.

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

getInstallFolder

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

A "platform-tool" package should always be located in SDK/platform-tools. There can be only one installed at once.

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)
Check whether 2 platform-tool packages are the same and have the same preview bit.

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

sameItemAs

public boolean sameItemAs(Package pkg,
                          FullRevision.PreviewComparison comparePreview)
Description copied from interface: IFullRevisionProvider
Returns whether the given 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.

Parameters:
pkg - The package to compare
comparePreview - How to compare previews.
Returns:
true if the items are the same.

preInstallHook

public boolean preInstallHook(Archive archive,
                              ITaskMonitor monitor,
                              java.lang.String osSdkRoot,
                              java.io.File installFolder)
Hook called right before an archive is installed. This is used here to stop ADB before trying to replace the platform-tool package.

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.