AndroidBuildDownloader

public class AndroidBuildDownloader
extends Object implements IFileDownloader

java.lang.Object
   ↳ com.google.android.tradefed.build.AndroidBuildDownloader


A IFileDownloader that retrieves files from the Android Build API.

Summary

Fields

protected static final ConcurrentMap<String, RemoteZip> REMOTE_ZIP_CACHE

A cache of remote zip files indexed by remote path.

Public constructors

AndroidBuildDownloader()

Public methods

static File createTempFile(String remoteFilePath, File rootDir)

Creates a unique file on temporary disk to house downloaded file with given path.

void downloadFile(String remoteFilePath, File destFile, long startOffset, long size)

Alternate form of downloadFile(String,File), that allows caller to download a section of the file and save to a specific destination file.

void downloadFile(String remoteFilePath, File destFile)

Alternate form of downloadFile(String), that allows caller to specify the destination file the remote contents should be placed in.

File downloadFile(String remoteFilePath)

Downloads a remote file to a temporary file on local disk.

void downloadZippedFiles(File destDir, String remoteFilePath, List<String> includeFilters, List<String> excludeFilters)

Download the files matching given filters in a remote zip file.

void enablePartialDownloadCache(boolean enablePartialDownloadCache)
void setMetadataCheck(boolean enableMetadataCheck)
void setResolveSymlinks(boolean resolveSymlinks)
void setUseMd5(boolean useMd5)

Protected methods

AndroidBuildFetcher getBuildFetcher()

Returns an AndroidBuildFetcher, creating one if it does not already exist.

void setBuildEnvironment(String buildEnvironment)

Fields

REMOTE_ZIP_CACHE

protected static final ConcurrentMap<String, RemoteZip> REMOTE_ZIP_CACHE

A cache of remote zip files indexed by remote path.

Public constructors

AndroidBuildDownloader

public AndroidBuildDownloader ()

Public methods

createTempFile

public static File createTempFile (String remoteFilePath, 
                File rootDir)

Creates a unique file on temporary disk to house downloaded file with given path.

Constructs the file name based on base file name from path

Parameters
remoteFilePath String: the remote path to construct the name from

rootDir File

Returns
File

Throws
BuildRetrievalError

downloadFile

public void downloadFile (String remoteFilePath, 
                File destFile, 
                long startOffset, 
                long size)

Alternate form of downloadFile(String,File), that allows caller to download a section of the file and save to a specific destination file.

Parameters
remoteFilePath String: the remote path to the file to download, relative to an implementation-specific root.

destFile File: the file to place the downloaded contents into. Should not exist.

startOffset long: the start offset in the remote file.

size long: the number of bytes to download from the remote file. Set it to a negative value to download the whole file.

Throws
BuildRetrievalError

downloadFile

public void downloadFile (String remoteFilePath, 
                File destFile)

Alternate form of downloadFile(String), that allows caller to specify the destination file the remote contents should be placed in.

Parameters
remoteFilePath String: the remote path to the file to download, relative to an implementation-specific root.

destFile File: the file to place the downloaded contents into. Should not exist.

Throws
BuildRetrievalError

downloadFile

public File downloadFile (String remoteFilePath)

Downloads a remote file to a temporary file on local disk.

Parameters
remoteFilePath String: the remote path to the file to download, relative to a implementation specific root.

Returns
File the temporary local downloaded File.

Throws
BuildRetrievalError

downloadZippedFiles

public void downloadZippedFiles (File destDir, 
                String remoteFilePath, 
                List<String> includeFilters, 
                List<String> excludeFilters)

Download the files matching given filters in a remote zip file.

A file inside the remote zip file is only downloaded to its path matches any of the include filters but not the exclude filters.

Parameters
destDir File: the file to place the downloaded contents into.

remoteFilePath String: the remote path to the file to download, relative to an implementation specific root.

includeFilters List: a list of filters to download matching files.

excludeFilters List: a list of filters to skip downloading matching files.

Throws
BuildRetrievalError
IOException

enablePartialDownloadCache

public void enablePartialDownloadCache (boolean enablePartialDownloadCache)

Parameters
enablePartialDownloadCache boolean

setMetadataCheck

public void setMetadataCheck (boolean enableMetadataCheck)

Parameters
enableMetadataCheck boolean

setResolveSymlinks

public void setResolveSymlinks (boolean resolveSymlinks)

Parameters
resolveSymlinks boolean

setUseMd5

public void setUseMd5 (boolean useMd5)

Parameters
useMd5 boolean

Protected methods

getBuildFetcher

protected AndroidBuildFetcher getBuildFetcher ()

Returns an AndroidBuildFetcher, creating one if it does not already exist.

Returns
AndroidBuildFetcher

Throws
GeneralSecurityException
IOException

setBuildEnvironment

protected void setBuildEnvironment (String buildEnvironment)

Parameters
buildEnvironment String