Ejemplo 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;
  }
Ejemplo n.º 2
0
 /**
  * Returns the targets (platforms & addons) that are available in the SDK. The target list is
  * created on demand the first time then cached. It will not refreshed unless {@link
  * #clearLocalPkg} is called to clear platforms and/or add-ons.
  *
  * <p>The array can be empty but not null.
  */
 @NonNull
 public IAndroidTarget[] getTargets() {
   synchronized (mLocalPackages) {
     if (mCachedTargets == null) {
       List<IAndroidTarget> result = Lists.newArrayList();
       LocalPkgInfo[] pkgsInfos =
           getPkgsInfos(EnumSet.of(PkgType.PKG_PLATFORM, PkgType.PKG_ADDON));
       for (LocalPkgInfo info : pkgsInfos) {
         assert info instanceof LocalPlatformPkgInfo;
         IAndroidTarget target = ((LocalPlatformPkgInfo) info).getAndroidTarget();
         if (target != null) {
           result.add(target);
         }
       }
       mCachedTargets = result;
     }
     return mCachedTargets.toArray(new IAndroidTarget[mCachedTargets.size()]);
   }
 }
Ejemplo n.º 3
0
 /**
  * Retrieve all the info about the requested package type. This is used for the package types that
  * have one or more instances, each with different versions. The resulting array is sorted
  * according to the PkgInfo's sort order.
  *
  * <p>Note: you can use this with {@link PkgType#PKG_TOOLS}, {@link PkgType#PKG_PLATFORM_TOOLS}
  * and {@link PkgType#PKG_DOC} but since there can only be one package of these types, it is more
  * efficient to use {@link #getPkgInfo(PkgType)} to query them.
  *
  * @param filter One of {@link PkgType} constants.
  * @return A list (possibly empty) of matching installed packages. Never returns null.
  */
 @NonNull
 public LocalPkgInfo[] getPkgsInfos(@NonNull PkgType filter) {
   return getPkgsInfos(EnumSet.of(filter));
 }