Exemple #1
0
  /**
   * Clear the tracked visited folders & the cached {@link LocalPkgInfo} for the given filter types.
   *
   * @param filters A set of PkgType constants or {@link PkgType#PKG_ALL} to clear everything.
   */
  public void clearLocalPkg(@NonNull EnumSet<PkgType> filters) {
    mLegacyBuildTools = null;

    synchronized (mLocalPackages) {
      for (PkgType filter : filters) {
        mVisitedDirs.removeAll(filter);
        mLocalPackages.removeAll(filter);
      }

      // Clear the targets if the platforms or addons are being cleared
      if (filters.contains(PkgType.PKG_PLATFORM) || filters.contains(PkgType.PKG_ADDON)) {
        mCachedMissingTargets = null;
        mCachedTargets = null;
      }
    }
  }
Exemple #2
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;
  }
Exemple #3
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()]);
   }
 }
Exemple #4
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));
 }