Exemple #1
0
  private void scanPlatforms(File collectionDir, Collection<LocalPkgInfo> outCollection) {
    for (File platformDir : mFileOp.listFiles(collectionDir)) {
      if (!shouldVisitDir(PkgType.PKG_PLATFORM, 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
      }

      FullRevision minToolsRev = PackageParserUtils.getPropertyFull(props, PkgProps.MIN_TOOLS_REV);
      if (minToolsRev == null) {
        minToolsRev = FullRevision.NOT_SPECIFIED;
      }

      try {
        AndroidVersion vers = new AndroidVersion(props);

        LocalPlatformPkgInfo pkgInfo =
            new LocalPlatformPkgInfo(this, platformDir, props, vers, rev, minToolsRev);
        outCollection.add(pkgInfo);

      } catch (AndroidVersionException e) {
        continue; // skip invalid or missing android version.
      }
    }
  }
Exemple #2
0
  /** Try to find a platform-tools package at the given location. Returns null if not found. */
  private LocalPlatformToolPkgInfo scanPlatformTools(File ptFolder) {
    // Can we find some properties?
    Properties props = parseProperties(new File(ptFolder, SdkConstants.FN_SOURCE_PROP));
    FullRevision rev = PackageParserUtils.getPropertyFull(props, PkgProps.PKG_REVISION);
    if (rev == null) {
      return null;
    }

    LocalPlatformToolPkgInfo info = new LocalPlatformToolPkgInfo(this, ptFolder, props, rev);
    return info;
  }
Exemple #3
0
  /** Try to find an NDK package at the given location. Returns null if not found. */
  @Nullable
  private LocalNdkPkgInfo scanNdk(@NonNull File ndkFolder) {
    // Can we find some properties?
    Properties props = parseProperties(new File(ndkFolder, SdkConstants.FN_SOURCE_PROP));
    FullRevision rev = PackageParserUtils.getPropertyFull(props, PkgProps.PKG_REVISION);
    if (rev == null) {
      return null;
    }

    return new LocalNdkPkgInfo(this, ndkFolder, props, rev);
  }
Exemple #4
0
  /** Try to find a tools package at the given location. Returns null if not found. */
  private LocalToolPkgInfo scanTools(File toolFolder) {
    // Can we find some properties?
    Properties props = parseProperties(new File(toolFolder, SdkConstants.FN_SOURCE_PROP));
    FullRevision rev = PackageParserUtils.getPropertyFull(props, PkgProps.PKG_REVISION);
    if (rev == null) {
      return null;
    }

    FullRevision minPlatToolsRev =
        PackageParserUtils.getPropertyFull(props, PkgProps.MIN_PLATFORM_TOOLS_REV);
    if (minPlatToolsRev == null) {
      minPlatToolsRev = FullRevision.NOT_SPECIFIED;
    }

    LocalToolPkgInfo info = new LocalToolPkgInfo(this, toolFolder, props, rev, minPlatToolsRev);

    // We're not going to check that all tools are present. At the very least
    // we should expect to find android and an emulator adapted to the current OS.
    boolean hasEmulator = false;
    boolean hasAndroid = false;
    String android1 = SdkConstants.androidCmdName().replace(".bat", ".exe");
    String android2 = android1.indexOf('.') == -1 ? null : android1.replace(".exe", ".bat");
    File[] files = mFileOp.listFiles(toolFolder);
    for (File file : files) {
      String name = file.getName();
      if (SdkConstants.FN_EMULATOR.equals(name)) {
        hasEmulator = true;
      }
      if (android1.equals(name) || (android2 != null && android2.equals(name))) {
        hasAndroid = true;
      }
    }
    if (!hasAndroid) {
      info.appendLoadError("Missing %1$s", SdkConstants.androidCmdName());
    }
    if (!hasEmulator) {
      info.appendLoadError("Missing %1$s", SdkConstants.FN_EMULATOR);
    }

    return info;
  }
Exemple #5
0
  private void scanBuildTools(File collectionDir, Collection<LocalPkgInfo> outCollection) {
    // The build-tool root folder contains a list of per-revision folders.
    for (File buildToolDir : mFileOp.listFiles(collectionDir)) {
      if (!shouldVisitDir(PkgType.PKG_BUILD_TOOLS, buildToolDir)) {
        continue;
      }

      Properties props = parseProperties(new File(buildToolDir, SdkConstants.FN_SOURCE_PROP));
      FullRevision rev = PackageParserUtils.getPropertyFull(props, PkgProps.PKG_REVISION);
      if (rev == null) {
        continue; // skip, no revision
      }

      BuildToolInfo btInfo = new BuildToolInfo(rev, buildToolDir);
      LocalBuildToolPkgInfo pkgInfo =
          new LocalBuildToolPkgInfo(this, buildToolDir, props, rev, btInfo);
      outCollection.add(pkgInfo);
    }
  }