Exemplo n.º 1
0
  /**
   * Retrieves information on a package identified by an {@link IPkgDesc}.
   *
   * @param descriptor {@link IPkgDesc} describing a package.
   * @return The first package found with the same descriptor or null.
   */
  @Nullable
  public LocalPkgInfo getPkgInfo(@NonNull IPkgDesc descriptor) {

    for (LocalPkgInfo pkg : getPkgsInfos(EnumSet.of(descriptor.getType()))) {
      IPkgDesc d = pkg.getDesc();
      if (d.equals(descriptor)) {
        return pkg;
      }
    }

    return null;
  }
Exemplo n.º 2
0
  /**
   * Retrieves information on a package identified by its {@link String} path.
   *
   * <p>For add-ons and platforms, the path is the target hash string (see {@link AndroidTargetHash}
   * for helpers methods to generate this string.)
   *
   * @param filter {@link PkgType#PKG_ADDON}, {@link PkgType#PKG_PLATFORM}.
   * @param path The vendor/path uniquely identifying this package.
   * @return An existing package information or null if not found.
   */
  @Nullable
  public LocalPkgInfo getPkgInfo(@NonNull PkgType filter, @NonNull String path) {

    assert filter == PkgType.PKG_ADDON || filter == PkgType.PKG_PLATFORM;

    for (LocalPkgInfo pkg : getPkgsInfos(filter)) {
      IPkgDesc d = pkg.getDesc();
      if (d.hasPath() && path.equals(d.getPath())) {
        return pkg;
      }
    }
    return null;
  }
Exemplo n.º 3
0
  /**
   * Retrieves information on a package identified by its {@link FullRevision}.
   *
   * <p>Note that {@link PkgType#PKG_TOOLS} and {@link PkgType#PKG_PLATFORM_TOOLS} are unique in a
   * local SDK so you'll want to use {@link #getPkgInfo(PkgType)} to retrieve them instead.
   *
   * @param filter {@link PkgType#PKG_BUILD_TOOLS}.
   * @param revision The {@link FullRevision} uniquely identifying this package.
   * @return An existing package information or null if not found.
   */
  @Nullable
  public LocalPkgInfo getPkgInfo(@NonNull PkgType filter, @NonNull FullRevision revision) {

    assert filter == PkgType.PKG_BUILD_TOOLS;

    for (LocalPkgInfo pkg : getPkgsInfos(filter)) {
      IPkgDesc d = pkg.getDesc();
      if (d.hasFullRevision() && d.getFullRevision().equals(revision)) {
        return pkg;
      }
    }
    return null;
  }
Exemplo n.º 4
0
 private static void addOrphanedSystemImage(
     ISystemImage image, IPkgDesc desc, Map<MissingTarget, MissingTarget> targets) {
   IdDisplay vendor = desc.getVendor();
   MissingTarget target =
       new MissingTarget(
           vendor == null ? null : vendor.getDisplay(),
           desc.getTag().getDisplay(),
           desc.getAndroidVersion());
   MissingTarget existing = targets.get(target);
   if (existing == null) {
     existing = target;
     targets.put(target, target);
   }
   existing.addSystemImage(image);
 }
Exemplo n.º 5
0
  /**
   * Retrieves information on a package identified by an {@link AndroidVersion}.
   *
   * <p>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;
  }
Exemplo n.º 6
0
  /**
   * Retrieves information on a package identified by both vendor and path strings.
   *
   * <p>For add-ons the path is target hash string (see {@link AndroidTargetHash} for helpers
   * methods to generate this string.)
   *
   * @param filter {@link PkgType#PKG_EXTRA}, {@link PkgType#PKG_ADDON}.
   * @param vendor The vendor id of the extra package.
   * @param path The path uniquely identifying this package for its vendor.
   * @return An existing package information or null if not found.
   */
  @Nullable
  public LocalPkgInfo getPkgInfo(
      @NonNull PkgType filter, @NonNull String vendor, @NonNull String path) {

    assert filter == PkgType.PKG_EXTRA || filter == PkgType.PKG_ADDON;

    for (LocalPkgInfo pkg : getPkgsInfos(filter)) {
      IPkgDesc d = pkg.getDesc();
      if (d.hasVendor() && vendor.equals(d.getVendor().getId())) {
        if (d.hasPath() && path.equals(d.getPath())) {
          return pkg;
        }
      }
    }
    return null;
  }