コード例 #1
0
ファイル: Main.java プロジェクト: MIPS/sdk
  /** Displays the skins valid for the given target. */
  private void displaySkinList(IAndroidTarget target, String message) {
    String[] skins = target.getSkins();
    String defaultSkin = target.getDefaultSkin();
    mSdkLog.printf(message);
    if (skins != null) {
      boolean first = true;
      for (String skin : skins) {
        if (first == false) {
          mSdkLog.printf(", ");
        } else {
          first = false;
        }
        mSdkLog.printf(skin);

        if (skin.equals(defaultSkin)) {
          mSdkLog.printf(" (default)");
        }
      }
      mSdkLog.printf("\n");
    } else {
      mSdkLog.printf("no skins.\n");
    }
  }
コード例 #2
0
ファイル: Main.java プロジェクト: MIPS/sdk
  /** Creates a new AVD. This is a text based creation with command line prompt. */
  private void createAvd() {
    // find a matching target
    int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
    IAndroidTarget[] targets = mSdkManager.getTargets();

    if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
      errorAndExit(
          "Target id is not valid. Use '%s list targets' to get the target ids.",
          SdkConstants.androidCmdName());
    }

    IAndroidTarget target = targets[targetId - 1]; // target id is 1-based

    try {
      boolean removePrevious = mSdkCommandLine.getFlagForce();
      AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog);

      String avdName = mSdkCommandLine.getParamName();

      if (!AvdManager.RE_AVD_NAME.matcher(avdName).matches()) {
        errorAndExit(
            "AVD name '%1$s' contains invalid characters.\nAllowed characters are: %2$s",
            avdName, AvdManager.CHARS_AVD_NAME);
        return;
      }

      AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
      if (info != null) {
        if (removePrevious) {
          mSdkLog.warning(
              "Android Virtual Device '%s' already exists and will be replaced.", avdName);
        } else {
          errorAndExit(
              "Android Virtual Device '%s' already exists.\n"
                  + "Use --force if you want to replace it.",
              avdName);
          return;
        }
      }

      String paramFolderPath = mSdkCommandLine.getParamLocationPath();
      File avdFolder = null;
      if (paramFolderPath != null) {
        avdFolder = new File(paramFolderPath);
      } else {
        avdFolder = AvdManager.AvdInfo.getAvdFolder(avdName);
      }

      // Validate skin is either default (empty) or NNNxMMM or a valid skin name.
      Map<String, String> skinHardwareConfig = null;
      String skin = mSdkCommandLine.getParamSkin();
      if (skin != null && skin.length() == 0) {
        skin = null;
      }

      if (skin != null && target != null) {
        boolean valid = false;
        // Is it a know skin name for this target?
        for (String s : target.getSkins()) {
          if (skin.equalsIgnoreCase(s)) {
            skin = s; // Make skin names case-insensitive.
            valid = true;

            // get the hardware properties for this skin
            File skinFolder = avdManager.getSkinPath(skin, target);
            FileWrapper skinHardwareFile = new FileWrapper(skinFolder, AvdManager.HARDWARE_INI);
            if (skinHardwareFile.isFile()) {
              skinHardwareConfig = ProjectProperties.parsePropertyFile(skinHardwareFile, mSdkLog);
            }
            break;
          }
        }

        // Is it NNNxMMM?
        if (!valid) {
          valid = AvdManager.NUMERIC_SKIN_SIZE.matcher(skin).matches();
        }

        if (!valid) {
          displaySkinList(target, "Valid skins: ");
          errorAndExit("'%s' is not a valid skin name or size (NNNxMMM)", skin);
          return;
        }
      }

      Map<String, String> hardwareConfig = null;
      if (target != null && target.isPlatform()) {
        try {
          hardwareConfig = promptForHardware(target, skinHardwareConfig);
        } catch (IOException e) {
          errorAndExit(e.getMessage());
        }
      }

      @SuppressWarnings("unused") // oldAvdInfo is never read, yet useful for debugging
      AvdInfo oldAvdInfo = null;
      if (removePrevious) {
        oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/);
      }

      @SuppressWarnings("unused") // newAvdInfo is never read, yet useful for debugging
      AvdInfo newAvdInfo =
          avdManager.createAvd(
              avdFolder,
              avdName,
              target,
              skin,
              mSdkCommandLine.getParamSdCard(),
              hardwareConfig,
              removePrevious,
              mSdkCommandLine.getFlagSnapshot(),
              mSdkLog);

    } catch (AndroidLocationException e) {
      errorAndExit(e.getMessage());
    }
  }
コード例 #3
0
 @Override
 public String[] getSkins() {
   return myWrapee.getSkins();
 }