com.android.ide.common.sdk
Class SdkVersionInfo

java.lang.Object
  extended by com.android.ide.common.sdk.SdkVersionInfo

public class SdkVersionInfo
extends java.lang.Object

Information about available SDK Versions


Field Summary
static int HIGHEST_KNOWN_API
          The highest known API level.
static int HIGHEST_KNOWN_STABLE_API
          Like HIGHEST_KNOWN_API but does not include preview platforms
 
Constructor Summary
SdkVersionInfo()
           
 
Method Summary
static java.lang.String camelCaseToUnderlines(java.lang.String string)
          Converts a CamelCase word into an underlined_word
static java.lang.String getAndroidName(int api)
          Returns the Android version and code name of the given API level, or null if not known.
static int getApiByBuildCode(java.lang.String buildCode, boolean recognizeUnknowns)
          Returns the API level of the given build code (e.g.
static int getApiByPreviewName(java.lang.String previewName, boolean recognizeUnknowns)
          Returns the API level of the given preview code name (e.g.
static java.lang.String getBuildCode(int api)
          Returns the applicable build code (for android.os.Build.VERSION_CODES) for the corresponding API level, or null if it's unknown.
static java.lang.String getCodeName(int api)
           
static com.android.sdklib.AndroidVersion getVersion(java.lang.String apiOrPreviewName, com.android.sdklib.IAndroidTarget[] targets)
          Returns the AndroidVersion for a given version string, which is typically an API level number, but can also be a codename for a preview platform.
static java.lang.String underlinesToCamelCase(java.lang.String string)
          Converts an underlined_word into a CamelCase word
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIGHEST_KNOWN_API

public static final int HIGHEST_KNOWN_API
The highest known API level. Note that the tools may also look at the installed platforms to see if they can find more recently released platforms, e.g. when the tools have not yet been updated for a new release. This number is used as a baseline and any more recent platforms found can be used to increase the highest known number.

See Also:
Constant Field Values

HIGHEST_KNOWN_STABLE_API

public static final int HIGHEST_KNOWN_STABLE_API
Like HIGHEST_KNOWN_API but does not include preview platforms

See Also:
Constant Field Values
Constructor Detail

SdkVersionInfo

public SdkVersionInfo()
Method Detail

getAndroidName

@Nullable
public static java.lang.String getAndroidName(int api)
Returns the Android version and code name of the given API level, or null if not known. The highest number (inclusive) that is supported is HIGHEST_KNOWN_API.

Parameters:
api - the api level
Returns:
a suitable version display name

getCodeName

public static java.lang.String getCodeName(int api)

getBuildCode

@Nullable
public static java.lang.String getBuildCode(int api)
Returns the applicable build code (for android.os.Build.VERSION_CODES) for the corresponding API level, or null if it's unknown. The highest number (inclusive) that is supported is HIGHEST_KNOWN_API.

Parameters:
api - the API level to look up a version code for
Returns:
the corresponding build code field name, or null

getApiByBuildCode

public static int getApiByBuildCode(java.lang.String buildCode,
                                    boolean recognizeUnknowns)
Returns the API level of the given build code (e.g. JELLY_BEAN_MR1 => 17), or -1 if not recognized

Parameters:
buildCode - the build code name (not case sensitive)
recognizeUnknowns - if true, treat an unrecognized code name as a newly released platform the tools are not yet aware of, and set its API level to some higher number than all the currently known API versions
Returns:
the API level, or -1 if not recognized (unless recognizeUnknowns is true, in which HIGHEST_KNOWN_API plus one is returned

getApiByPreviewName

public static int getApiByPreviewName(java.lang.String previewName,
                                      boolean recognizeUnknowns)
Returns the API level of the given preview code name (e.g. JellyBeanMR2 => 17), or -1 if not recognized

Parameters:
previewName - the preview name (not case sensitive)
recognizeUnknowns - if true, treat an unrecognized code name as a newly released platform the tools are not yet aware of, and set its API level to some higher number than all the currently known API versions
Returns:
the API level, or -1 if not recognized (unless recognizeUnknowns is true, in which HIGHEST_KNOWN_API plus one is returned

camelCaseToUnderlines

public static java.lang.String camelCaseToUnderlines(java.lang.String string)
Converts a CamelCase word into an underlined_word

Parameters:
string - the CamelCase version of the word
Returns:
the underlined version of the word

underlinesToCamelCase

public static java.lang.String underlinesToCamelCase(java.lang.String string)
Converts an underlined_word into a CamelCase word

Parameters:
string - the underlined word to convert
Returns:
the CamelCase version of the word

getVersion

@Nullable
public static com.android.sdklib.AndroidVersion getVersion(@Nullable
                                                                    java.lang.String apiOrPreviewName,
                                                                    @Nullable
                                                                    com.android.sdklib.IAndroidTarget[] targets)
Returns the AndroidVersion for a given version string, which is typically an API level number, but can also be a codename for a preview platform. Note: This should not be used to look up version names for build codes; for that, use getApiByBuildCode(String, boolean). The primary difference between this method is that getApiByBuildCode(String, boolean) will return the final API number for a platform (e.g. for "KITKAT" it will return 19) whereas this method will return the API number for the codename as a preview platform (e.g. 18).

Parameters:
apiOrPreviewName - the version string
targets - an optional array of installed targets, if available. If the version string corresponds to a code name, this is used to search for a corresponding API level.
Returns:
an AndroidVersion, or null if the version could not be determined (e.g. an empty or invalid API number or an unknown code name)