AndroidSdkHandler
/RepoManager
.@Deprecated
public class LocalSdk
extends java.lang.Object
Packages are accessed by their type and a main query attribute, depending on the
package type. There are different versions of getPkgInfo(com.android.sdklib.repository.legacy.descriptors.IPkgDesc)
which depend on the
query attribute.
Type | Query parameter | Getter |
---|---|---|
Tools | Unique instance | getPkgInfo(PkgType.PKG_TOOLS) ⇒ LocalPkgInfo |
Platform-Tools | Unique instance | getPkgInfo(PkgType.PKG_PLATFORM_TOOLS) ⇒ LocalPkgInfo |
Docs | Unique instance | getPkgInfo(PkgType.PKG_DOCS) ⇒ LocalPkgInfo |
Build-Tools | Revision |
getLatestBuildTool() ⇒ BuildToolInfo , or getBuildTool(Revision) ⇒ BuildToolInfo , or getPkgInfo(PkgType.PKG_BUILD_TOOLS, Revision) ⇒ LocalPkgInfo , or getPkgsInfos(PkgType.PKG_BUILD_TOOLS) ⇒ LocalPkgInfo [] |
Extras | String vendor/path | getExtra(String) ⇒ LocalExtraPkgInfo , or getPkgInfo(PkgType.PKG_EXTRAS, String) ⇒ LocalPkgInfo , or getPkgsInfos(PkgType.PKG_EXTRAS) ⇒ LocalPkgInfo [] |
Sources | AndroidVersion |
getPkgInfo(PkgType.PKG_SOURCES, AndroidVersion) ⇒ LocalPkgInfo , or getPkgsInfos(PkgType.PKG_SOURCES) ⇒ LocalPkgInfo [] |
Samples | AndroidVersion |
getPkgInfo(PkgType.PKG_SAMPLES, AndroidVersion) ⇒ LocalPkgInfo , or getPkgsInfos(PkgType.PKG_SAMPLES) ⇒ LocalPkgInfo [] |
Platforms | AndroidVersion |
getPkgInfo(PkgType.PKG_PLATFORMS, AndroidVersion) ⇒ LocalPkgInfo , or getPkgInfo(PkgType.PKG_ADDONS, String) ⇒ LocalPkgInfo , or getPkgsInfos(PkgType.PKG_PLATFORMS) ⇒ LocalPkgInfo [], or getTargetFromHashString(String) ⇒ IAndroidTarget |
Add-ons | AndroidVersion x String vendor/path |
getPkgInfo(PkgType.PKG_ADDONS, String) ⇒ LocalPkgInfo , or getPkgsInfos(PkgType.PKG_ADDONS) ⇒ LocalPkgInfo [], or getTargetFromHashString(String) ⇒ IAndroidTarget |
System images | AndroidVersion x String ABI |
getPkgsInfos(PkgType.PKG_SYS_IMAGES) ⇒ LocalPkgInfo [] |
Threading: All accessor methods are synchronized on the same internal lock so
it's safe to call them from any thread, even concurrently.
A method like getPkgsInfos
returns a copy of its data array, which objects are
not altered after creation, so its value is not influenced by the internal state after
it returns.
Implementation Background:
LocalSdk
parses sdk on disk,
and a separate class wraps the downloaded manifest (this is now handled within Studio only)
Constructor and Description |
---|
LocalSdk()
Deprecated.
Creates an initial LocalSdk instance with an unknown location.
|
LocalSdk(java.io.File sdkRoot)
Deprecated.
Creates an initial LocalSdk instance for a known SDK location.
|
LocalSdk(com.android.repository.io.FileOp fileOp)
Deprecated.
Creates an initial LocalSdk instance with an unknown location.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
androidCmdName()
Deprecated.
Returns the appropriate name for the 'android' command, which is 'android.bat' for
Windows and 'android' for all other platforms.
|
void |
clearLocalPkg(java.util.EnumSet<PkgType> filters)
Deprecated.
Clear the tracked visited folders and the cached
LocalPkgInfo for the
given filter types. |
BuildToolInfo |
getBuildTool(com.android.repository.Revision revision)
Deprecated.
Returns the
BuildToolInfo for the given revision. |
LocalExtraPkgInfo |
getExtra(java.lang.String vendor,
java.lang.String path)
Deprecated.
Retrieves information on an extra package identified by its
String vendor/path. |
com.android.repository.io.FileOp |
getFileOp()
Deprecated.
|
BuildToolInfo |
getLatestBuildTool()
Deprecated.
Returns the highest build-tool revision known, or null if there are are no build-tools.
|
java.io.File |
getLocation()
Deprecated.
Location of the SDK.
|
java.lang.String |
getPath()
Deprecated.
|
LocalPkgInfo |
getPkgInfo(IPkgDesc descriptor)
Deprecated.
Retrieves information on a package identified by an
IPkgDesc . |
LocalPkgInfo |
getPkgInfo(PkgType filter)
Deprecated.
For unique local packages.
|
LocalPkgInfo |
getPkgInfo(PkgType filter,
com.android.sdklib.AndroidVersion version)
Deprecated.
Retrieves information on a package identified by an
AndroidVersion . |
LocalPkgInfo |
getPkgInfo(PkgType filter,
com.android.repository.Revision revision)
Deprecated.
Retrieves information on a package identified by its
Revision . |
LocalPkgInfo |
getPkgInfo(PkgType filter,
java.lang.String path)
Deprecated.
Retrieves information on a package identified by its
String path. |
LocalPkgInfo |
getPkgInfo(PkgType filter,
java.lang.String vendor,
java.lang.String path)
Deprecated.
Retrieves information on a package identified by both vendor and path strings.
|
LocalPkgInfo[] |
getPkgsInfos(java.util.EnumSet<PkgType> filters)
Deprecated.
Retrieve all the info about the requested package types.
|
LocalPkgInfo[] |
getPkgsInfos(PkgType filter)
Deprecated.
Retrieve all the info about the requested package type.
|
void |
setLocation(java.io.File sdkRoot)
Deprecated.
Sets or changes the SDK root location.
|
public LocalSdk()
public LocalSdk(@NonNull java.io.File sdkRoot)
sdkRoot
- The location of the SDK root folder.public LocalSdk(@NonNull com.android.repository.io.FileOp fileOp)
FileOp
being used.fileOp
- The alternate FileOp
to use for all file-based interactions.@NonNull public com.android.repository.io.FileOp getFileOp()
public void setLocation(@NonNull java.io.File sdkRoot)
sdkRoot
- The location of the SDK root folder.@Nullable public java.io.File getLocation()
@Deprecated @Nullable public java.lang.String getPath()
public void clearLocalPkg(@NonNull java.util.EnumSet<PkgType> filters)
LocalPkgInfo
for the
given filter types.filters
- A set of PkgType constants or PkgType.PKG_ALL
to clear everything.@Nullable public LocalPkgInfo getPkgInfo(@NonNull IPkgDesc descriptor)
IPkgDesc
.descriptor
- IPkgDesc
describing a package.@Nullable public LocalPkgInfo getPkgInfo(@NonNull PkgType filter, @NonNull com.android.sdklib.AndroidVersion version)
AndroidVersion
.
Note: don't use this for PkgType.PKG_SYS_IMAGE
since there can be more than
one ABI and this method only returns a single package per filter type.filter
- PkgType.PKG_PLATFORM
, PkgType.PKG_SAMPLE
or PkgType.PKG_SOURCE
.version
- The AndroidVersion
specific for this package type.@Nullable public LocalPkgInfo getPkgInfo(@NonNull PkgType filter, @NonNull com.android.repository.Revision revision)
Revision
.
Note that PkgType.PKG_TOOLS
and PkgType.PKG_PLATFORM_TOOLS
are unique in a local SDK so you'll want to use getPkgInfo(PkgType)
to retrieve them instead.
filter
- PkgType.PKG_BUILD_TOOLS
.revision
- The Revision
uniquely identifying this package.@Nullable public LocalPkgInfo getPkgInfo(@NonNull PkgType filter, @NonNull java.lang.String path)
String
path.
For add-ons and platforms, the path is the target hash string
(see AndroidTargetHash
for helpers methods to generate this string.)
filter
- PkgType.PKG_ADDON
, PkgType.PKG_PLATFORM
.path
- The vendor/path uniquely identifying this package.@Nullable public LocalPkgInfo getPkgInfo(@NonNull PkgType filter, @NonNull java.lang.String vendor, @NonNull java.lang.String path)
For add-ons the path is target hash string
(see AndroidTargetHash
for helpers methods to generate this string.)
filter
- PkgType.PKG_EXTRA
, PkgType.PKG_ADDON
.vendor
- The vendor id of the extra package.path
- The path uniquely identifying this package for its vendor.@Nullable public LocalExtraPkgInfo getExtra(@NonNull java.lang.String vendor, @NonNull java.lang.String path)
String
vendor/path.vendor
- The vendor id of the extra package.path
- The path uniquely identifying this package for its vendor.@Nullable public LocalPkgInfo getPkgInfo(@NonNull PkgType filter)
filter
- PkgType.PKG_TOOLS
or PkgType.PKG_PLATFORM_TOOLS
or PkgType.PKG_DOC
.@NonNull public LocalPkgInfo[] getPkgsInfos(@NonNull PkgType filter)
Note: you can use this with PkgType.PKG_TOOLS
, PkgType.PKG_PLATFORM_TOOLS
and
PkgType.PKG_DOC
but since there can only be one package of these types, it is
more efficient to use getPkgInfo(PkgType)
to query them.
filter
- One of PkgType
constants.@NonNull public LocalPkgInfo[] getPkgsInfos(@NonNull java.util.EnumSet<PkgType> filters)
To force the LocalSdk parser to load everything, simply call this method with the
PkgType.PKG_ALL
argument to load all the known package types.
Note: you can use this with PkgType.PKG_TOOLS
, PkgType.PKG_PLATFORM_TOOLS
and PkgType.PKG_DOC
but since there can only be one package of these types, it is
more efficient to use getPkgInfo(PkgType)
to query them.
filters
- One or more of PkgType.PKG_ADDON
, PkgType.PKG_PLATFORM
, PkgType.PKG_BUILD_TOOLS
, PkgType.PKG_EXTRA
, PkgType.PKG_SOURCE
, PkgType.PKG_SYS_IMAGE
@Nullable public BuildToolInfo getBuildTool(@Nullable com.android.repository.Revision revision)
BuildToolInfo
for the given revision.revision
- The requested revision.BuildToolInfo
. Can be null if revision
is null or is
not part of the known set returned by getPkgsInfos(PkgType.PKG_BUILD_TOOLS)
.@Nullable public BuildToolInfo getLatestBuildTool()
If no specific build-tool package is installed but the platform-tools is lower than 17, then this creates and returns a "legacy" built-tool package using platform-tools. (We only split build-tools out of platform-tools starting with revision 17, before they were both the same thing.)
public static java.lang.String androidCmdName()