use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class ConfigureAndroidProjectPath method putSdkDependentParams.
/**
* Populate the given state with a set of variables that depend on the user's installed SDK. This method should
* be called early in the initialization of a wizard or path.
* Variables:
* Build Tools Version: Used to populate the project level build.gradle with the correct Gradle plugin version number
* If the required build tools version is not installed, a request is added for installation
* SDK Home: The location of the installed SDK
*
* @param state the state store to populate with the values stored in the SDK
*/
public static void putSdkDependentParams(@NotNull ScopedStateStore state) {
final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(ConfigureAndroidProjectPath.class);
BuildToolInfo buildTool = sdkHandler.getLatestBuildTool(progress, false);
Revision minimumRequiredBuildToolVersion = Revision.parseRevision(SdkConstants.MIN_BUILD_TOOLS_VERSION);
if (buildTool != null && buildTool.getRevision().compareTo(minimumRequiredBuildToolVersion) >= 0) {
state.put(WizardConstants.BUILD_TOOLS_VERSION_KEY, buildTool.getRevision().toString());
} else {
// We need to install a new build tools version
state.listPush(WizardConstants.INSTALL_REQUESTS_KEY, DetailsTypes.getBuildToolsPath(minimumRequiredBuildToolVersion));
state.put(WizardConstants.BUILD_TOOLS_VERSION_KEY, minimumRequiredBuildToolVersion.toString());
}
File location = sdkHandler.getLocation();
if (location != null) {
// Gradle expects a platform-neutral path
state.put(WizardConstants.SDK_DIR_KEY, FileUtil.toSystemIndependentName(location.getPath()));
}
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class AndroidStudioWelcomeScreenProvider method fetchPackages.
@NotNull
private static Map<String, RemotePackage> fetchPackages() {
ConnectionState connectionState = checkInternetConnection();
switch(connectionState) {
case OK:
break;
case NO_CONNECTION:
return ImmutableMap.of();
default:
throw new IllegalArgumentException(connectionState.name());
}
StudioLoggerProgressIndicator logger = new StudioLoggerProgressIndicator(AndroidStudioWelcomeScreenProvider.class);
RepoManager mgr = AndroidSdks.getInstance().tryToChooseSdkHandler().getSdkManager(logger);
mgr.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, logger, new StudioDownloader(), StudioSettingsController.getInstance());
return mgr.getPackages().getRemotePackages();
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class FirstRunWizard method init.
@Override
public void init() {
File initialSdkLocation = FirstRunWizardDefaults.getInitialSdkLocation(myMode);
ConsolidatedProgressStep progressStep = new FirstRunProgressStep();
myComponentsPath = new InstallComponentsPath(myMode, initialSdkLocation, progressStep, true);
if (myMode == FirstRunWizardMode.NEW_INSTALL) {
boolean sdkExists = false;
if (initialSdkLocation.isDirectory()) {
AndroidSdkHandler sdkHandler = AndroidSdkHandler.getInstance(initialSdkLocation);
ProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
sdkExists = ((AndroidSdkHandler) sdkHandler).getLocalPackage(SdkConstants.FD_TOOLS, progress) != null;
}
addPath(new SingleStepPath(new FirstRunWelcomeStep(sdkExists)));
}
if (myMode == FirstRunWizardMode.NEW_INSTALL) {
if (initialSdkLocation.getPath().isEmpty()) {
// We don't have a default path specified, have to do custom install.
myState.put(KEY_CUSTOM_INSTALL, true);
} else {
addPath(new SingleStepPath(new InstallationTypeWizardStep(KEY_CUSTOM_INSTALL)));
}
addPath(new SingleStepPath(new SelectThemeStep(KEY_CUSTOM_INSTALL)));
}
if (myMode == FirstRunWizardMode.MISSING_SDK) {
addPath(new SingleStepPath(new MissingSdkAlertStep()));
}
addPath(myComponentsPath);
if (SystemInfo.isLinux && myMode == FirstRunWizardMode.NEW_INSTALL) {
addPath(new SingleStepPath(new LinuxHaxmInfoStep()));
}
if (myMode != FirstRunWizardMode.INSTALL_HANDOFF) {
addPath(new SingleStepPath(new LicenseAgreementStep(getDisposable())));
}
addPath(new SingleStepPath(progressStep));
super.init();
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class AndroidVirtualDevice method getSystemImageDescription.
private SystemImageDescription getSystemImageDescription(AndroidSdkHandler sdkHandler) throws WizardException {
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
Collection<SystemImage> systemImages = sdkHandler.getSystemImageManager(progress).lookup(ID_ADDON_GOOGLE_API_IMG, myLatestVersion, ID_VENDOR_GOOGLE);
if (systemImages.isEmpty()) {
throw new WizardException("Missing system image required for an AVD setup");
}
return new SystemImageDescription(systemImages.iterator().next());
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class InstallCMakeHyperlink method execute.
@Override
protected void execute(@NotNull Project project) {
// We need to statically fetch the SDK handler each time because the location might change.
// TODO: remove the need for doing this each time.
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
StudioLoggerProgressIndicator progressIndicator = new StudioLoggerProgressIndicator(getClass());
RepoManager sdkManager = sdkHandler.getSdkManager(progressIndicator);
StudioProgressRunner progressRunner = new StudioProgressRunner(false, /* backgroundable */
false, /* cancellable */
"Loading Remote SDK", true, /* in UI thread */
project);
RepoManager.RepoLoadedCallback onComplete = packages -> {
Collection<RemotePackage> cmakePackages = packages.getRemotePackagesForPrefix(FD_CMAKE);
if (!cmakePackages.isEmpty()) {
RemotePackage cmakePackage;
if (cmakePackages.size() == 1) {
cmakePackage = getFirstItem(cmakePackages);
} else {
cmakePackage = sdkHandler.getLatestRemotePackageForPrefix(FD_CMAKE, false, progressIndicator);
}
if (cmakePackage != null) {
ModelWizardDialog dialog = createDialogForPaths(project, ImmutableList.of(cmakePackage.getPath()));
if (dialog != null && dialog.showAndGet()) {
GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
}
return;
}
notifyCMakePackageNotFound(project);
}
};
Runnable onError = () -> notifyCMakePackageNotFound(project);
sdkManager.load(DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), ImmutableList.of(onError), progressRunner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Aggregations