当前位置: 首页>>代码示例>>Java>>正文


Java AndroidVersion类代码示例

本文整理汇总了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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:27,代码来源:LocalSdk.java

示例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.
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:28,代码来源:LocalSdk.java

示例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.
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:25,代码来源:LocalSdk.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:32,代码来源:PkgDesc.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:28,代码来源:PkgDesc.java

示例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();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:SamplePackage.java

示例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();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:33,代码来源:SourcePackage.java

示例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();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:31,代码来源:DocPackage.java

示例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;
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:20,代码来源:AndroidVersionNode.java

示例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
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:19,代码来源:AvdUISelector.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IntellijLintProject.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:LaunchCompatibility.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:LayoutPullParserFactory.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:LaunchCompatibilityTest.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:RemoteDocPkgInfo.java


注:本文中的com.android.sdklib.AndroidVersion类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。