use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class UnresolvedDependenciesReporter method getRemotePackages.
@NotNull
private static Collection<RemotePackage> getRemotePackages(@NotNull ProgressIndicator indicator) {
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
RepositoryPackages packages = sdkHandler.getSdkManager(indicator).getPackages();
return packages.getRemotePackages().values();
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class PatchInstallerUtilTest method getLatestPatcher.
@Test
public void getLatestPatcher() throws Exception {
LocalPackage target = new FakeLocalPackage("patcher;v3");
List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("patcher;v1"), target, new FakeLocalPackage("patcher;v2"));
RepositoryPackages packages = new RepositoryPackages(local, ImmutableList.of());
FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages);
LocalPackage patcher = PatchInstallerUtil.getLatestPatcher(mgr);
assertEquals(target, patcher);
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class SdkQuickfixUtils method createDialog.
@VisibleForTesting
@Nullable
static ModelWizardDialog createDialog(@Nullable Project project, @Nullable Component parent, @Nullable Collection<String> requestedPaths, @Nullable Collection<UpdatablePackage> requestedPackages, @Nullable Collection<LocalPackage> requestedUninstalls, @Nullable AndroidSdkHandler sdkHandler, boolean backgroundable) {
if (sdkHandler == null) {
return null;
}
RepoManager mgr = sdkHandler.getSdkManager(REPO_LOGGER);
if (mgr.getLocalPath() == null) {
String title = "SDK Problem";
String msg = "<html>" + "Your Android SDK is missing or out of date." + "<br>" + "You can configure your SDK via <b>Configure | Project Defaults | Project Structure | SDKs</b></html>";
Messages.showErrorDialog(msg, title);
return null;
}
List<String> unknownPaths = new ArrayList<>();
List<UpdatablePackage> resolvedPackages;
mgr.loadSynchronously(0, new StudioLoggerProgressIndicator(SdkQuickfixUtils.class), new StudioDownloader(), StudioSettingsController.getInstance());
RepositoryPackages packages = mgr.getPackages();
if (requestedPackages == null) {
requestedPackages = new ArrayList<>();
}
requestedPackages.addAll(lookupPaths(requestedPaths, packages, unknownPaths));
try {
resolvedPackages = resolve(requestedPackages, packages);
} catch (PackageResolutionException e) {
Messages.showErrorDialog(e.getMessage(), "Error Resolving Packages");
return null;
}
Set<LocalPackage> resolvedUninstalls = new HashSet<>();
if (requestedUninstalls != null) {
resolvedUninstalls.addAll(requestedUninstalls);
// We don't want to uninstall something required by a package we're installing
resolvedPackages.forEach(updatable -> resolvedUninstalls.remove(updatable.getLocal()));
}
List<UpdatablePackage> unavailableDownloads = Lists.newArrayList();
verifyAvailability(resolvedPackages, unavailableDownloads);
// If there were requests we didn't understand or can't download, show an error.
if (!unknownPaths.isEmpty() || !unavailableDownloads.isEmpty()) {
String title = "Packages Unavailable";
HtmlBuilder builder = new HtmlBuilder();
builder.openHtmlBody().add(String.format("%1$s packages are not available for download!", resolvedPackages.isEmpty() ? "All" : "Some")).newline().newline().add("The following packages are not available:").beginList();
for (UpdatablePackage p : unavailableDownloads) {
builder.listItem().add(p.getRepresentative().getDisplayName());
}
for (String p : unknownPaths) {
builder.listItem().add("Package id " + p);
}
builder.endList().closeHtmlBody();
Messages.showErrorDialog(builder.getHtml(), title);
}
// If everything was removed, don't continue.
if (resolvedPackages.isEmpty() && resolvedUninstalls.isEmpty()) {
return null;
}
List<RemotePackage> installRequests = resolvedPackages.stream().map(UpdatablePackage::getRemote).collect(Collectors.toList());
ModelWizard.Builder wizardBuilder = new ModelWizard.Builder();
wizardBuilder.addStep(new LicenseAgreementStep(new LicenseAgreementModel(mgr.getLocalPath()), installRequests));
InstallSelectedPackagesStep installStep = new InstallSelectedPackagesStep(resolvedPackages, resolvedUninstalls, sdkHandler, backgroundable);
wizardBuilder.addStep(installStep);
ModelWizard wizard = wizardBuilder.build();
String title = "SDK Quickfix Installation";
return new StudioWizardDialogBuilder(wizard, title, parent).setProject(project).setModalityType(DialogWrapper.IdeModalityType.IDE).setCancellationPolicy(ModelWizardDialog.CancellationPolicy.CAN_CANCEL_UNTIL_CAN_FINISH).build();
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class RepositoryUrlManagerTest method testResolvedCoordinateRemoteSdk.
public void testResolvedCoordinateRemoteSdk() throws Exception {
RemotePackage pkg = new FakePackage.FakeRemotePackage("extras;m2repository;com;google;android;gms;play-services;4.5.0");
RepositoryPackages pkgs = new RepositoryPackages(ImmutableList.of(), ImmutableList.of(pkg));
RepoManager mgr = new FakeRepoManager(pkgs);
mySdkHandler = new AndroidSdkHandler(new File("/emptysdk"), ANDROID_HOME, myFileOp, mgr);
GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString("com.google.android.gms:play-services:4.+");
assertNotNull(coordinate);
assertEquals("4.5.0", resolveDynamicCoordinateVersion(coordinate));
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class SystemImageListModel method refreshImages.
public void refreshImages(final boolean forceRefresh) {
synchronized (myLock) {
myCompletedCalls = 0;
}
myIndicator.onRefreshStart("Refreshing...");
final List<SystemImageDescription> items = Lists.newArrayList();
RepoManager.RepoLoadedCallback localComplete = new RepoManager.RepoLoadedCallback() {
@Override
public void doRun(@NotNull RepositoryPackages packages) {
// getLocalImages() doesn't use SdkPackages, so it's ok that we're not using what's passed in.
items.addAll(getLocalImages());
// Update list in the UI immediately with the locally available system images
setItems(items);
// Assume the remote has not completed yet
completedDownload("");
}
};
RepoManager.RepoLoadedCallback remoteComplete = new RepoManager.RepoLoadedCallback() {
@Override
public void doRun(@NotNull RepositoryPackages packages) {
List<SystemImageDescription> remotes = getRemoteImages(packages);
if (remotes != null) {
items.addAll(remotes);
setItems(items);
}
completedDownload("");
}
};
Runnable error = new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
completedDownload("Error loading remote images");
}
});
}
};
StudioProgressRunner runner = new StudioProgressRunner(false, false, "Loading Images", true, myProject);
mySdkHandler.getSdkManager(LOGGER).load(forceRefresh ? 0 : RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, ImmutableList.of(localComplete), ImmutableList.of(remoteComplete), ImmutableList.of(error), runner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Aggregations