public final class AndroidSdkHandler
extends java.lang.Object
RepoManager. Ensures that the proper android sdk-specific
schemas and source providers are registered, and provides android sdk-specific package logic
(pending as adoption continues).| Modifier and Type | Field and Description |
|---|---|
static int |
LATEST_LEGACY_VERSION
The latest version of legacy remote packages we should expect to receive from a server.
|
static java.lang.String |
SDK_TEST_BASE_URL_ENV_VAR
The name of the environment variable used to override the url of the primary repository, for
testing.
|
static java.lang.String |
SDK_TEST_BASE_URL_PROPERTY
The name of the system property used to override the url of the primary repository, for
testing.
|
| Constructor and Description |
|---|
AndroidSdkHandler(java.io.File localPath,
java.io.File androidFolder,
com.android.repository.io.FileOp fop)
Don't use this, use
getInstance(File), unless you're in a unit test and need to
specify a custom FileOp and/or androidFolder. |
AndroidSdkHandler(java.io.File localPath,
java.io.File androidFolder,
com.android.repository.io.FileOp fop,
com.android.repository.api.RepoManager repoManager)
Don't use this either, unless you're in a unit test and need to specify a custom
RepoManager. |
| Modifier and Type | Method and Description |
|---|---|
static void |
addCustomSourceProvider(com.android.repository.api.RepositorySourceProvider provider,
com.android.repository.api.ProgressIndicator progress)
Add another
RepositorySourceProvider. |
static com.android.repository.api.SchemaModule<AddonFactory> |
getAddonModule() |
static java.util.List<com.android.repository.api.SchemaModule<?>> |
getAllModules() |
java.io.File |
getAndroidFolder() |
AndroidTargetManager |
getAndroidTargetManager(com.android.repository.api.ProgressIndicator progress)
Gets (and creates if necessary) an
AndroidTargetManager based on our local sdk
packages. |
BuildToolInfo |
getBuildToolInfo(com.android.repository.Revision revision,
com.android.repository.api.ProgressIndicator progress)
Creates a the
BuildToolInfo for the specificed build tools revision, if available. |
static com.android.repository.api.SchemaModule<SdkCommonFactory> |
getCommonModule() |
com.android.repository.io.FileOp |
getFileOp()
Gets our
FileOp. |
static AndroidSdkHandler |
getInstance(java.io.File localPath)
Get a
AndroidSdkHandler instance. |
BuildToolInfo |
getLatestBuildTool(com.android.repository.api.ProgressIndicator progress,
boolean allowPreview)
Returns a
BuildToolInfo corresponding to the newest installed build tool RepoPackage, or null if none are installed (or if the allowPreview parameter
is false and there was non-preview version available) |
BuildToolInfo |
getLatestBuildTool(com.android.repository.api.ProgressIndicator progress,
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview)
Returns a
BuildToolInfo corresponding to the newest installed build tool RepoPackage, or null if none are installed (or if the allowPreview parameter
is false and there was non-preview version available) |
com.android.repository.api.LocalPackage |
getLatestLocalPackageForPrefix(java.lang.String prefix,
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
java.util.function.Function<java.lang.String,? extends java.lang.Comparable> mapper,
com.android.repository.api.ProgressIndicator progress) |
<T> com.android.repository.api.LocalPackage |
getLatestLocalPackageForPrefix(java.lang.String prefix,
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
java.util.function.Function<java.lang.String,T> mapper,
java.util.Comparator<T> comparator,
com.android.repository.api.ProgressIndicator progress)
This grabs the
Collection of LocalPackages from RepoManager with the
same prefix using RepositoryPackages.getLocalPackagesForPrefix(String)
and forwards it to getLatestPackageFromPrefixCollection(java.util.Collection<P>, java.util.function.Predicate<com.android.repository.Revision>, boolean, java.util.function.Function<java.lang.String, T>, java.util.Comparator<T>) |
com.android.repository.api.LocalPackage |
getLatestLocalPackageForPrefix(java.lang.String prefix,
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
com.android.repository.api.ProgressIndicator progress)
Suppose that
prefix is p, and we have these local packages: p;1.1,
p;1.2, p;2.1 What this should return is the package p;2.1. |
static <P extends com.android.repository.api.RepoPackage,T> |
getLatestPackageFromPrefixCollection(java.util.Collection<P> packages,
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
java.util.function.Function<java.lang.String,T> mapper,
java.util.Comparator<T> comparator) |
com.android.repository.api.RemotePackage |
getLatestRemotePackageForPrefix(java.lang.String prefix,
boolean allowPreview,
java.util.function.Function<java.lang.String,? extends java.lang.Comparable> mapper,
com.android.repository.api.ProgressIndicator progress) |
<T> com.android.repository.api.RemotePackage |
getLatestRemotePackageForPrefix(java.lang.String prefix,
boolean allowPreview,
java.util.function.Function<java.lang.String,T> mapper,
java.util.Comparator<T> comparator,
com.android.repository.api.ProgressIndicator progress) |
com.android.repository.api.RemotePackage |
getLatestRemotePackageForPrefix(java.lang.String prefix,
boolean allowPreview,
com.android.repository.api.ProgressIndicator progress) |
com.android.repository.api.LocalPackage |
getLocalPackage(java.lang.String path,
com.android.repository.api.ProgressIndicator progress)
Convenience to get a package from the local repo.
|
java.io.File |
getLocation()
Gets the path of the local SDK, if set.
|
com.android.repository.api.LocalPackage |
getPackageInRange(java.lang.String prefix,
com.google.common.collect.Range<com.android.repository.Revision> range,
com.android.repository.api.ProgressIndicator progressIndicator)
Returns the highest available version of the given package that is contained by the given
range, or null if no such version was found.
|
static com.android.repository.api.SchemaModule<RepoFactory> |
getRepositoryModule() |
com.android.repository.api.RepoManager |
getSdkManager(com.android.repository.api.ProgressIndicator progress)
Fetches
RepoManager set up to interact with android SDK repositories. |
static com.android.repository.api.SchemaModule<SysImgFactory> |
getSysImgModule() |
SystemImageManager |
getSystemImageManager(com.android.repository.api.ProgressIndicator progress)
Gets (and creates if necessary) a
SystemImageManager based on our local sdk packages. |
com.android.repository.impl.sources.LocalSourceProvider |
getUserSourceProvider(com.android.repository.api.ProgressIndicator progress)
Gets the customizable
RepositorySourceProvider. |
static void |
resetInstance(java.io.File localPath)
Force removal of a cached
AndroidSdkHandler instance. |
public static final java.lang.String SDK_TEST_BASE_URL_ENV_VAR
public static final java.lang.String SDK_TEST_BASE_URL_PROPERTY
public static final int LATEST_LEGACY_VERSION
public AndroidSdkHandler(@Nullable
java.io.File localPath,
@Nullable
java.io.File androidFolder,
@NonNull
com.android.repository.io.FileOp fop)
getInstance(File), unless you're in a unit test and need to
specify a custom FileOp and/or androidFolder.public AndroidSdkHandler(@Nullable
java.io.File localPath,
@Nullable
java.io.File androidFolder,
@NonNull
com.android.repository.io.FileOp fop,
@NonNull
com.android.repository.api.RepoManager repoManager)
RepoManager.AndroidSdkHandler(File, File, FileOp)@NonNull public static AndroidSdkHandler getInstance(@Nullable java.io.File localPath)
AndroidSdkHandler instance.localPath - The path to the local SDK. If null this handler will only be used
for remote operations.public static void resetInstance(@NonNull
java.io.File localPath)
AndroidSdkHandler instance. This will force a reparsing of
the SDK next time a component is looked up.localPath - The path to the local SDK.@NonNull
public com.android.repository.api.RepoManager getSdkManager(@NonNull
com.android.repository.api.ProgressIndicator progress)
RepoManager set up to interact with android SDK repositories. It should not
cached by callers of this method, since any changes to the fundamental properties of the
manager (fallback loaders, local path) will cause a new instance to be created.@NonNull public SystemImageManager getSystemImageManager(@NonNull com.android.repository.api.ProgressIndicator progress)
SystemImageManager based on our local sdk packages.@NonNull public AndroidTargetManager getAndroidTargetManager(@NonNull com.android.repository.api.ProgressIndicator progress)
AndroidTargetManager based on our local sdk
packages.@Nullable public java.io.File getLocation()
@Nullable public java.io.File getAndroidFolder()
@Nullable
public com.android.repository.api.LocalPackage getLocalPackage(@NonNull
java.lang.String path,
@NonNull
com.android.repository.api.ProgressIndicator progress)
@Nullable
public static <P extends com.android.repository.api.RepoPackage,T> P getLatestPackageFromPrefixCollection(@NonNull
java.util.Collection<P> packages,
@Nullable
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
@NonNull
java.util.function.Function<java.lang.String,T> mapper,
@NonNull
java.util.Comparator<T> comparator)
P - LocalPackage or RemotePackageT - Comparable that we map the suffix to.packages - a Collection of packages which share a common prefix, from
which we wish to extract the "Latest" package, as sorted with mapper and comparator on the suffixes.filter - the revision predicate that has to be satisfied by the returned packageallowPreview - whether we allow returning a preview package.mapper - maps from path suffix to a Comparable, so that we can sort the packages
by suffix.comparator - how to sort suffixes after mapping them.Collection, as sorted with mapper and
comparator on the last path component.@Nullable
public com.android.repository.api.LocalPackage getLatestLocalPackageForPrefix(@NonNull
java.lang.String prefix,
@Nullable
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
@NonNull
com.android.repository.api.ProgressIndicator progress)
prefix is p, and we have these local packages: p;1.1,
p;1.2, p;2.1 What this should return is the package p;2.1. We operate
on the path suffix since we have no guarantee that the package revision is the same as used
in the path. We also have no guarantee that the format of the path even matches, so we ignore
the packages that don't fit the format.@Nullable
public com.android.repository.api.LocalPackage getLatestLocalPackageForPrefix(@NonNull
java.lang.String prefix,
@Nullable
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
@NonNull
java.util.function.Function<java.lang.String,? extends java.lang.Comparable> mapper,
@NonNull
com.android.repository.api.ProgressIndicator progress)
@Nullable
public <T> com.android.repository.api.LocalPackage getLatestLocalPackageForPrefix(@NonNull
java.lang.String prefix,
@Nullable
java.util.function.Predicate<com.android.repository.Revision> filter,
boolean allowPreview,
@NonNull
java.util.function.Function<java.lang.String,T> mapper,
@NonNull
java.util.Comparator<T> comparator,
@NonNull
com.android.repository.api.ProgressIndicator progress)
Collection of LocalPackages from RepoManager with the
same prefix using RepositoryPackages.getLocalPackagesForPrefix(String)
and forwards it to getLatestPackageFromPrefixCollection(java.util.Collection<P>, java.util.function.Predicate<com.android.repository.Revision>, boolean, java.util.function.Function<java.lang.String, T>, java.util.Comparator<T>)@Nullable
public com.android.repository.api.RemotePackage getLatestRemotePackageForPrefix(@NonNull
java.lang.String prefix,
boolean allowPreview,
@NonNull
com.android.repository.api.ProgressIndicator progress)
, but for {@link
RemotePackage}s instead.@Nullable
public com.android.repository.api.RemotePackage getLatestRemotePackageForPrefix(@NonNull
java.lang.String prefix,
boolean allowPreview,
@NonNull
java.util.function.Function<java.lang.String,? extends java.lang.Comparable> mapper,
@NonNull
com.android.repository.api.ProgressIndicator progress)
, but for
{@link RemotePackage}s instead.@Nullable
public <T> com.android.repository.api.RemotePackage getLatestRemotePackageForPrefix(@NonNull
java.lang.String prefix,
boolean allowPreview,
@NonNull
java.util.function.Function<java.lang.String,T> mapper,
@NonNull
java.util.Comparator<T> comparator,
@NonNull
com.android.repository.api.ProgressIndicator progress)
, but for {@link RemotePackage}s instead.@NonNull public static com.android.repository.api.SchemaModule<SdkCommonFactory> getCommonModule()
SchemaModule containing the common sdk-specific metadata. See
sdk-common-XX.xsd.@NonNull public static com.android.repository.api.SchemaModule<AddonFactory> getAddonModule()
SchemaModule containing the metadata for addon-type Repositorys.
See sdk-addon-XX.xsd.@NonNull public static com.android.repository.api.SchemaModule<RepoFactory> getRepositoryModule()
SchemaModule containing the metadata for the primary android SDK Repository (containin platforms etc.). See sdk-repository-XX.xsd.@NonNull public static com.android.repository.api.SchemaModule<SysImgFactory> getSysImgModule()
SchemaModule containing the metadata for system image-type Repositorys. See sdk-sys-img-XX.xsd.@NonNull public static java.util.List<com.android.repository.api.SchemaModule<?>> getAllModules()
SchemaModules@Nullable
public com.android.repository.impl.sources.LocalSourceProvider getUserSourceProvider(@NonNull
com.android.repository.api.ProgressIndicator progress)
RepositorySourceProvider. Can be null if there's a problem
with the user's environment.public static void addCustomSourceProvider(@NonNull
com.android.repository.api.RepositorySourceProvider provider,
@NonNull
com.android.repository.api.ProgressIndicator progress)
RepositorySourceProvider. All existing AndroidSdkHandlers and
RepoManagers are invalidated, and all future instances will include the new
provider.@Nullable
public com.android.repository.api.LocalPackage getPackageInRange(@NonNull
java.lang.String prefix,
@NonNull
com.google.common.collect.Range<com.android.repository.Revision> range,
@NonNull
com.android.repository.api.ProgressIndicator progressIndicator)
@Nullable public BuildToolInfo getLatestBuildTool(@NonNull com.android.repository.api.ProgressIndicator progress, boolean allowPreview)
BuildToolInfo corresponding to the newest installed build tool RepoPackage, or null if none are installed (or if the allowPreview parameter
is false and there was non-preview version available)progress - a progress indicatorallowPreview - ignore preview build tools version unless this parameter is true@Nullable public BuildToolInfo getLatestBuildTool(@NonNull com.android.repository.api.ProgressIndicator progress, @Nullable java.util.function.Predicate<com.android.repository.Revision> filter, boolean allowPreview)
BuildToolInfo corresponding to the newest installed build tool RepoPackage, or null if none are installed (or if the allowPreview parameter
is false and there was non-preview version available)progress - a progress indicatorfilter - the revision predicate to satisfyallowPreview - ignore preview build tools version unless this parameter is true@Nullable public BuildToolInfo getBuildToolInfo(@NonNull com.android.repository.Revision revision, @NonNull com.android.repository.api.ProgressIndicator progress)
BuildToolInfo for the specificed build tools revision, if available.revision - The build tools revision requestedprogress - ProgressIndicator for logging.BuildToolInfo corresponding to the specified build tools package, or
null if that revision is not installed.@NonNull public com.android.repository.io.FileOp getFileOp()
FileOp. Useful so both the sdk handler and file op don't both have to be
injected everywhere.