use of com.android.tools.idea.wizard.WizardConstants.INSTALL_REQUESTS_KEY in project android by JetBrains.
the class SmwOldApiDirectInstall method startSdkInstallUsingNonSwtOldApi.
private void startSdkInstallUsingNonSwtOldApi() {
// Get the SDK instance.
final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
if (sdkHandler.getLocation() == null) {
myErrorLabel.setText("Error: can't get SDK instance.");
myErrorLabel.setIcon(AllIcons.General.BalloonError);
return;
}
File androidSdkPath = IdeSdks.getInstance().getAndroidSdkPath();
if (androidSdkPath != null && androidSdkPath.exists() && !androidSdkPath.canWrite()) {
myErrorLabel.setText(String.format("SDK folder is read-only: '%1$s'", androidSdkPath.getPath()));
myErrorLabel.setIcon(AllIcons.General.BalloonError);
return;
}
myLabelSdkPath.setText(sdkHandler.getLocation().getPath());
final CustomLogger logger = new CustomLogger();
final com.android.repository.api.ProgressIndicator repoProgress = new StudioLoggerProgressIndicator(getClass());
RepoManager.RepoLoadedCallback onComplete = packages -> UIUtil.invokeLaterIfNeeded(() -> {
List<String> requestedChanges = myState.get(INSTALL_REQUESTS_KEY);
if (requestedChanges == null) {
assert false : "Shouldn't be in installer with no requests";
myInstallFinished = true;
invokeUpdate(null);
return;
}
Map<String, RemotePackage> remotes = packages.getRemotePackages();
List<RemotePackage> requestedPackages = Lists.newArrayList();
boolean notFound = false;
for (String path : requestedChanges) {
RemotePackage remotePackage = remotes.get(path);
if (remotePackage != null) {
requestedPackages.add(remotePackage);
} else {
notFound = true;
}
}
if (requestedPackages.isEmpty()) {
myInstallFinished = true;
invokeUpdate(null);
} else {
requestedPackages = InstallerUtil.computeRequiredPackages(requestedPackages, packages, repoProgress);
if (requestedPackages == null) {
notFound = true;
} else {
InstallTask task = new InstallTask(sdkHandler, requestedPackages, logger);
BackgroundableProcessIndicator indicator = new BackgroundableProcessIndicator(task);
logger.setIndicator(indicator);
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, indicator);
}
}
if (notFound) {
myErrorLabel.setText("Problem: Some required packages could not be installed. Check internet connection.");
myErrorLabel.setIcon(AllIcons.General.BalloonError);
}
});
StudioProgressRunner runner = new StudioProgressRunner(false, false, "Updating SDK", false, null);
sdkHandler.getSdkManager(repoProgress).load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), null, runner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Aggregations