com.android.sdklib.repositoryv2
Class AndroidSdkHandler

java.lang.Object
  extended by com.android.sdklib.repositoryv2.AndroidSdkHandler

public final class AndroidSdkHandler
extends java.lang.Object

Android SDK interface to 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).


Field Summary
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 URL_GOOGLE_SDK_SITE
          The URL of the official Google sdk-repository site.
 
Constructor Summary
AndroidSdkHandler(com.android.repository.io.FileOp fop, boolean useSdkV2)
          Don't use this, use getInstance(), unless you're in a unit test and need to specify a custom FileOp.
 
Method Summary
static com.android.repository.impl.installer.PackageInstaller findBestInstaller(com.android.repository.api.RepoPackage p)
          Finds the best PackageInstaller for the given RepoPackage.
 com.android.repository.api.SchemaModule getAddonModule(com.android.repository.api.ProgressIndicator progress)
           
 AndroidTargetManager getAndroidTargetManager(com.android.repository.api.ProgressIndicator progress)
          Gets (and creates if necessary) an AndroidTargetManager based on our local sdk packages.
 com.android.repository.api.SchemaModule getCommonModule(com.android.repository.api.ProgressIndicator progress)
           
 com.android.repository.io.FileOp getFileOp()
          Gets our FileOp.
static AndroidSdkHandler getInstance()
          Get a AndroidSdkHandler instance.
 BuildToolInfo getLatestBuildTool(com.android.repository.api.ProgressIndicator progress)
          Gets a BuildToolInfo corresponding to the newest installed build tool RepoPackage, or null if none are installed.
 com.android.repository.api.SchemaModule getRepositoryModule(com.android.repository.api.ProgressIndicator progress)
           
 com.android.repository.api.RepoManager getSdkManager(com.android.repository.api.ProgressIndicator progress)
          Fetches RepoManager set up to interact with android SDK repositories.
 com.android.repository.api.SchemaModule getSysImgModule(com.android.repository.api.ProgressIndicator progress)
           
 SystemImageManager getSystemImageManager(com.android.repository.api.ProgressIndicator progress)
          Gets (and creates if necessary) a SystemImageManager based on our local sdk packages.
 com.android.repository.api.RepositorySourceProvider getUserSourceProvider(com.android.repository.api.ProgressIndicator progress)
           
 void setLocation(java.io.File location)
          Sets the path the the local SDK.
 void setRemoteFallback(com.android.repository.api.FallbackRemoteRepoLoader fallbackSdk)
          Sets the FallbackRemoteRepoLoader to be used to parse any old-style remote repositories we might receive.
 boolean useSdkV2()
          Temporary method indicating whether we should use RepoManager or the older LocalSdk etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_GOOGLE_SDK_SITE

public static final java.lang.String URL_GOOGLE_SDK_SITE
The URL of the official Google sdk-repository site. The URL ends with a /, allowing easy concatenation.

See Also:
Constant Field Values

SDK_TEST_BASE_URL_ENV_VAR

public static final 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.

See Also:
Constant Field Values

LATEST_LEGACY_VERSION

public static final int LATEST_LEGACY_VERSION
The latest version of legacy remote packages we should expect to receive from a server. If you think you need to change this value you should create a new-style package instead.

See Also:
Constant Field Values
Constructor Detail

AndroidSdkHandler

public AndroidSdkHandler(@NonNull
                         com.android.repository.io.FileOp fop,
                         boolean useSdkV2)
Don't use this, use getInstance(), unless you're in a unit test and need to specify a custom FileOp. For new code, useSdkV2 should probably be true.

Method Detail

getInstance

@NonNull
public static AndroidSdkHandler getInstance()
Get a AndroidSdkHandler instance.


getSdkManager

@NonNull
public com.android.repository.api.RepoManager getSdkManager(@NonNull
                                                                    com.android.repository.api.ProgressIndicator progress)
Fetches 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.


getSystemImageManager

@NonNull
public SystemImageManager getSystemImageManager(@NonNull
                                                        com.android.repository.api.ProgressIndicator progress)
Gets (and creates if necessary) a SystemImageManager based on our local sdk packages.


getAndroidTargetManager

@NonNull
public AndroidTargetManager getAndroidTargetManager(@NonNull
                                                            com.android.repository.api.ProgressIndicator progress)
Gets (and creates if necessary) an AndroidTargetManager based on our local sdk packages.


setLocation

public void setLocation(@Nullable
                        java.io.File location)
Sets the path the the local SDK.

Invalidates the repo manager; it will be recreated when next retrieved.


setRemoteFallback

public void setRemoteFallback(@Nullable
                              com.android.repository.api.FallbackRemoteRepoLoader fallbackSdk)
Sets the FallbackRemoteRepoLoader to be used to parse any old-style remote repositories we might receive.

Invalidates the repo manager; it will be recreated when next retrieved.


getCommonModule

@NonNull
public com.android.repository.api.SchemaModule getCommonModule(@NonNull
                                                                       com.android.repository.api.ProgressIndicator progress)
Returns:
The SchemaModule containing the common sdk-specific metadata. See sdk-common-XX.xsd.

getAddonModule

@NonNull
public com.android.repository.api.SchemaModule getAddonModule(@NonNull
                                                                      com.android.repository.api.ProgressIndicator progress)
Returns:
The SchemaModule containing the metadata for addon-type Repositorys. See sdk-addon-XX.xsd.

getRepositoryModule

@NonNull
public com.android.repository.api.SchemaModule getRepositoryModule(@NonNull
                                                                           com.android.repository.api.ProgressIndicator progress)
Returns:
The SchemaModule containing the metadata for the primary android SDK Repository (containin platforms etc.). See sdk-repository-XX.xsd.

getSysImgModule

@NonNull
public com.android.repository.api.SchemaModule getSysImgModule(@NonNull
                                                                       com.android.repository.api.ProgressIndicator progress)
Returns:
The SchemaModule containing the metadata for system image-type Repositorys. See sdk-sys-img-XX.xsd.

getUserSourceProvider

@NonNull
public com.android.repository.api.RepositorySourceProvider getUserSourceProvider(@NonNull
                                                                                         com.android.repository.api.ProgressIndicator progress)

findBestInstaller

public static com.android.repository.impl.installer.PackageInstaller findBestInstaller(com.android.repository.api.RepoPackage p)
Finds the best PackageInstaller for the given RepoPackage.


useSdkV2

public boolean useSdkV2()
Temporary method indicating whether we should use RepoManager or the older LocalSdk etc.

Returns:
true if we should use RepoManager.

getLatestBuildTool

@Nullable
public BuildToolInfo getLatestBuildTool(com.android.repository.api.ProgressIndicator progress)
Gets a BuildToolInfo corresponding to the newest installed build tool RepoPackage, or null if none are installed.


getFileOp

@NonNull
public com.android.repository.io.FileOp getFileOp()
Gets our FileOp. Useful so both the sdk handler and file op don't both have to be injected everywhere.