本文整理汇总了Java中com.android.sdklib.AndroidVersion类的典型用法代码示例。如果您正苦于以下问题:Java AndroidVersion类的具体用法?Java AndroidVersion怎么用?Java AndroidVersion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AndroidVersion类属于com.android.sdklib包,在下文中一共展示了AndroidVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPkgInfo
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/**
* Retrieves information on a package identified by an {@link AndroidVersion}.
*
* Note: don't use this for {@link PkgType#PKG_SYS_IMAGE} since there can be more than
* one ABI and this method only returns a single package per filter type.
*
* @param filter {@link PkgType#PKG_PLATFORM}, {@link PkgType#PKG_SAMPLE}
* or {@link PkgType#PKG_SOURCE}.
* @param version The {@link AndroidVersion} specific for this package type.
* @return An existing package information or null if not found.
*/
@Nullable
public LocalPkgInfo getPkgInfo(@NonNull PkgType filter, @NonNull AndroidVersion version) {
assert filter == PkgType.PKG_PLATFORM ||
filter == PkgType.PKG_SAMPLE ||
filter == PkgType.PKG_SOURCE;
for (LocalPkgInfo pkg : getPkgsInfos(filter)) {
IPkgDesc d = pkg.getDesc();
if (d.hasAndroidVersion() && d.getAndroidVersion().equals(version)) {
return pkg;
}
}
return null;
}
示例2: scanDoc
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/**
* Try to find a docs package at the given location.
* Returns null if not found.
*/
private LocalDocPkgInfo scanDoc(File docFolder) {
// Can we find some properties?
Properties props = parseProperties(new File(docFolder, SdkConstants.FN_SOURCE_PROP));
MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION);
if (rev == null) {
return null;
}
try {
AndroidVersion vers = new AndroidVersion(props);
LocalDocPkgInfo info = new LocalDocPkgInfo(this, docFolder, props, vers, rev);
// To start with, a doc folder should have an "index.html" to be acceptable.
// We don't actually check the content of the file.
if (!mFileOp.isFile(new File(docFolder, "index.html"))) {
info.appendLoadError("Missing index.html");
}
return info;
} catch (AndroidVersionException e) {
return null; // skip invalid or missing android version.
}
}
示例3: scanSources
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
private void scanSources(File collectionDir, Collection<LocalPkgInfo> outCollection) {
// The build-tool root folder contains a list of per-revision folders.
for (File platformDir : mFileOp.listFiles(collectionDir)) {
if (!shouldVisitDir(PkgType.PKG_SOURCE, platformDir)) {
continue;
}
Properties props = parseProperties(new File(platformDir, SdkConstants.FN_SOURCE_PROP));
MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION);
if (rev == null) {
continue; // skip, no revision
}
try {
AndroidVersion vers = new AndroidVersion(props);
LocalSourcePkgInfo pkgInfo =
new LocalSourcePkgInfo(this, platformDir, props, vers, rev);
outCollection.add(pkgInfo);
} catch (AndroidVersionException e) {
continue; // skip invalid or missing android version.
}
}
}
示例4: newDoc
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/**
* Creates a new doc package descriptor.
*
* @param revision The revision of the doc package.
* @return A {@link PkgDesc} describing this doc package.
*/
@NonNull
public static Builder newDoc(@NonNull AndroidVersion version,
@NonNull MajorRevision revision) {
Builder p = new Builder(PkgType.PKG_DOC);
p.mAndroidVersion = version;
p.mMajorRevision = revision;
p.mCustomIsUpdateFor = new IIsUpdateFor() {
@Override
public boolean isUpdateFor(PkgDesc thisPkgDesc, IPkgDesc existingDesc) {
if (existingDesc == null ||
!thisPkgDesc.getType().equals(existingDesc.getType())) {
return false;
}
// This package is unique in the SDK. It's an update if the API is newer
// or the revision is newer for the same API.
int diff = thisPkgDesc.getAndroidVersion().compareTo(
existingDesc.getAndroidVersion());
return diff > 0 ||
(diff == 0 && thisPkgDesc.getMajorRevision().compareTo(
existingDesc.getMajorRevision()) > 0);
}
};
return p;
}
示例5: newPlatform
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/**
* Creates a new platform package descriptor.
*
* @param version The android version of the platform package.
* @param revision The revision of the extra package.
* @param minToolsRev An optional {@code min-tools-rev}.
* Use {@link FullRevision#NOT_SPECIFIED} to indicate
* there is no requirement.
* @return A {@link PkgDesc} describing this platform package.
*/
@NonNull
public static Builder newPlatform(@NonNull AndroidVersion version,
@NonNull MajorRevision revision,
@NonNull FullRevision minToolsRev) {
Builder p = new Builder(PkgType.PKG_PLATFORM);
p.mAndroidVersion = version;
p.mMajorRevision = revision;
p.mMinToolsRev = minToolsRev;
p.mCustomPath = new IGetPath() {
@Override
public String getPath(PkgDesc thisPkgDesc) {
/** The "path" of a Platform is its Target Hash. */
return AndroidTargetHash.getPlatformHashString(thisPkgDesc.getAndroidVersion());
}
};
return p;
}
示例6: SamplePackage
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
private SamplePackage(String archiveOsPath, Properties props) throws AndroidVersionException {
super(null, //source
props, //properties
0, //revision will be taken from props
null, //license
null, //description
null, //descUrl
archiveOsPath //archiveOsPath
);
mVersion = new AndroidVersion(props);
mMinApiLevel = getPropertyInt(props, PkgProps.SAMPLE_MIN_API_LEVEL,
MIN_API_LEVEL_NOT_SPECIFIED);
mPkgDesc = PkgDesc.Builder
.newSample(mVersion,
(MajorRevision) getRevision(),
getMinToolsRevision())
.setDescriptions(this)
.create();
}
示例7: SourcePackage
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/**
* Creates a new source package from the attributes and elements of the given XML node.
* This constructor should throw an exception if the package cannot be created.
*
* @param source The {@link SdkSource} where this is loaded from.
* @param packageNode The XML element being parsed.
* @param nsUri The namespace URI of the originating XML document, to be able to deal with
* parameters that vary according to the originating XML schema.
* @param licenses The licenses loaded from the XML originating document.
*/
public SourcePackage(
SdkSource source,
Node packageNode,
String nsUri,
Map<String,String> licenses) {
super(source, packageNode, nsUri, licenses);
int apiLevel =
PackageParserUtils.getXmlInt(packageNode, SdkRepoConstants.NODE_API_LEVEL, 0);
String codeName =
PackageParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_CODENAME);
if (codeName.length() == 0) {
codeName = null;
}
mVersion = new AndroidVersion(apiLevel, codeName);
mPkgDesc = PkgDesc.Builder
.newSource(mVersion,
(MajorRevision) getRevision())
.setDescriptions(this)
.create();
}
示例8: DocPackage
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/**
* Creates a new doc package from the attributes and elements of the given XML node.
* This constructor should throw an exception if the package cannot be created.
*
* @param source The {@link SdkSource} where this is loaded from.
* @param packageNode The XML element being parsed.
* @param nsUri The namespace URI of the originating XML document, to be able to deal with
* parameters that vary according to the originating XML schema.
* @param licenses The licenses loaded from the XML originating document.
*/
public DocPackage(SdkSource source,
Node packageNode,
String nsUri,
Map<String,String> licenses) {
super(source, packageNode, nsUri, licenses);
int apiLevel =
PackageParserUtils.getXmlInt (packageNode, SdkRepoConstants.NODE_API_LEVEL, 0);
String codeName =
PackageParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_CODENAME);
if (codeName.length() == 0) {
codeName = null;
}
mVersion = new AndroidVersion(apiLevel, codeName);
mPkgDesc = PkgDesc.Builder
.newDoc(mVersion, (MajorRevision) getRevision())
.setDescriptions(this)
.create();
}
示例9: equals
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof AndroidVersionNode) {
if (Objects.equals(this.version, ((AndroidVersionNode) obj).getVersion())) {
return true;
}
}
if (obj instanceof AndroidVersion) {
if (version.equals(obj)) {
return true;
}
}
return false;
}
示例10: setAvdInfos
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
public final void setAvdInfos(AvdInfo[] infos) {
avdInfos = infos;
DefaultTableModel tableModel = getTableModel();
tableModel.setRowCount(0);
for (AvdInfo info : infos) {
AndroidVersion target = info.getAndroidVersion();
if (target != null) {
tableModel.addRow(new Object[]{
info.getName(), target.getApiLevel(), target.getCodename(), target.getFeatureLevel()
});
} else {
LOG.log(Level.INFO, "Not valid AvdInfo {0}", info);
}
}
if (infos.length > 0) {
avdsTable.setRowSelectionInterval(0, 0); // pre-select 1st row
}
}
示例11: getBuildSdk
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
@Override
public int getBuildSdk() {
IdeaAndroidProject ideaAndroidProject = myFacet.getIdeaAndroidProject();
if (ideaAndroidProject != null) {
String compileTarget = ideaAndroidProject.getDelegate().getCompileTarget();
AndroidVersion version = AndroidTargetHash.getPlatformVersion(compileTarget);
if (version != null) {
return version.getApiLevel();
}
}
AndroidPlatform platform = AndroidPlatform.getInstance(myFacet.getModule());
if (platform != null) {
return platform.getApiLevel();
}
return super.getBuildSdk();
}
示例12: canRunOnAvd
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/** Returns whether a project with given minSdkVersion and target platform can be run on an AVD with given target platform. */
@NotNull
public static LaunchCompatibility canRunOnAvd(@NotNull AndroidVersion minSdkVersion,
@NotNull IAndroidTarget projectTarget,
@NotNull IAndroidTarget avdTarget) {
AndroidVersion avdVersion = avdTarget.getVersion();
if (!avdVersion.canRun(minSdkVersion)) {
String reason = String.format("minSdk(%1$s) %3$s deviceSdk(%2$s)",
minSdkVersion,
avdVersion,
minSdkVersion.getCodename() == null ? ">" : "!=");
return new LaunchCompatibility(ThreeState.NO, reason);
}
return projectTarget.isPlatform() ? YES : isCompatibleAddonAvd(projectTarget, avdTarget);
}
示例13: prefCapableTargetInstalled
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/** Returns if a target capable of rendering preferences file is found. */
private static boolean prefCapableTargetInstalled(@NotNull PsiFile file) {
Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
AndroidPlatform platform = AndroidPlatform.getInstance(module);
if (platform != null) {
IAndroidTarget[] targets = platform.getSdkData().getTargets();
for (int i = targets.length - 1; i >= 0; i--) {
IAndroidTarget target = targets[i];
if (target.isPlatform()) {
AndroidVersion version = target.getVersion();
int featureLevel = version.getFeatureLevel();
if (featureLevel >= PREFERENCES_MIN_API) {
return true;
}
}
}
}
}
return false;
}
示例14: testMinSdk
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
public void testMinSdk() {
final MockPlatformTarget projectTarget = new MockPlatformTarget(14, 0);
final EnumSet<IDevice.HardwareFeature> requiredFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
// cannot run if the API level of device is < API level required by minSdk
LaunchCompatibility compatibility =
LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, createMockDevice(7, null), null);
assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8) > deviceSdk(API 7)"), compatibility);
// can run if the API level of device is >= API level required by minSdk
compatibility =
LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, createMockDevice(8, null), null);
assertEquals(new LaunchCompatibility(ThreeState.YES, null), compatibility);
// cannot run if minSdk uses a code name that is not matched by the device
compatibility =
LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, "P"), projectTarget, requiredFeatures, createMockDevice(9, null), null);
assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8, P preview) != deviceSdk(API 9)"), compatibility);
}
示例15: RemoteDocPkgInfo
import com.android.sdklib.AndroidVersion; //导入依赖的package包/类
/**
* Creates a new doc package from the attributes and elements of the given XML node.
* This constructor should throw an exception if the package cannot be created.
*
* @param source The {@link SdkSource} where this is loaded from.
* @param packageNode The XML element being parsed.
* @param nsUri The namespace URI of the originating XML document, to be able to deal with
* parameters that vary according to the originating XML schema.
* @param licenses The licenses loaded from the XML originating document.
*/
public RemoteDocPkgInfo(SdkSource source, Node packageNode, String nsUri, Map<String, String> licenses) {
super(source, packageNode, nsUri, licenses);
int apiLevel = RemotePackageParserUtils.getXmlInt(packageNode, SdkRepoConstants.NODE_API_LEVEL, 0);
String codeName = RemotePackageParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_CODENAME);
if (codeName.length() == 0) {
codeName = null;
}
AndroidVersion version = new AndroidVersion(apiLevel, codeName);
PkgDesc.Builder pkgDescBuilder = PkgDesc.Builder.newDoc(version, new MajorRevision(getRevision()));
pkgDescBuilder.setDescriptionShort(createShortDescription(mListDisplay, getRevision(), version, isObsolete()));
pkgDescBuilder.setDescriptionUrl(getDescUrl());
pkgDescBuilder.setListDisplay(createListDescription(mListDisplay, version, isObsolete()));
pkgDescBuilder.setIsObsolete(isObsolete());
pkgDescBuilder.setLicense(getLicense());
mPkgDesc = pkgDescBuilder.create();
}