/** Updates an existing Android export project based on command-line parameters */ private void updateExportProject() { ProjectCreator creator = getProjectCreator(); String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath()); String projectName = mSdkCommandLine.getParamName(); if (projectName != null && !ProjectCreator.RE_PROJECT_NAME.matcher(projectName).matches()) { errorAndExit( "Project name '%1$s' contains invalid characters.\nAllowed characters are: %2$s", projectName, ProjectCreator.CHARS_PROJECT_NAME); return; } creator.updateExportProject(projectDir, projectName, mSdkCommandLine.getFlagForce()); }
/** Updates the whole SDK without any UI, just using console output. */ private void updateSdkNoUI() { boolean force = mSdkCommandLine.getFlagForce(); boolean useHttp = mSdkCommandLine.getFlagNoHttps(); boolean dryMode = mSdkCommandLine.getFlagDryMode(); boolean obsolete = mSdkCommandLine.getFlagObsolete(); String proxyHost = mSdkCommandLine.getProxyHost(); String proxyPort = mSdkCommandLine.getProxyPort(); // Check filter types. ArrayList<String> pkgFilter = new ArrayList<String>(); String filter = mSdkCommandLine.getParamFilter(); if (filter != null && filter.length() > 0) { for (String t : filter.split(",")) { // $NON-NLS-1$ if (t != null) { t = t.trim(); if (t.length() > 0) { boolean found = false; for (String t2 : SdkRepoConstants.NODES) { if (t2.equals(t)) { pkgFilter.add(t2); found = true; break; } } if (!found) { errorAndExit( "Unknown package filter type '%1$s'.\nAccepted values are: %2$s", t, Arrays.toString(SdkRepoConstants.NODES)); return; } } } } } UpdateNoWindow upd = new UpdateNoWindow( mOsSdkFolder, mSdkManager, mSdkLog, force, useHttp, proxyHost, proxyPort); upd.updateAll(pkgFilter, obsolete, dryMode); }
/** 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()); } }