use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class ComponentInstaller method ensureSdkPackagesUninstalled.
public void ensureSdkPackagesUninstalled(@NotNull Collection<String> packageNames, ProgressIndicator progress) throws WizardException {
RepoManager sdkManager = mySdkHandler.getSdkManager(progress);
RepositoryPackages packages = sdkManager.getPackages();
Map<String, LocalPackage> localPackages = packages.getLocalPackages();
List<LocalPackage> packagesToUninstall = new ArrayList<>();
for (String packageName : packageNames) {
LocalPackage p = localPackages.get(packageName);
if (p != null) {
packagesToUninstall.add(p);
} else {
progress.logInfo(String.format("Package '%1$s' does not appear to be installed - ignoring", packageName));
}
}
for (LocalPackage request : packagesToUninstall) {
// This is pretty much symmetric to the installPackages() method above, so the same comments apply.
// Should we have registered listeners, HaxmInstallListener would have invoked another instance of HaxmWizard.
// The good news is that as of writing this,
// this class is used in Welcome and Haxm wizards only, and plays the role of a utility class.
// If we have more packages which require custom pre- and post-installation steps like Haxm,
// then we might still need a way to invoke non-recursive / listener-free uninstall operations for cleanup purposes
// It's possible that a change in packaging API would make sense to support that later -
// there is already some cleanup() support in operation chain implementation, but its limitation is that cleanup()
// is executed unconditionally, whereas in most cases it should be dependent on the next operation success status -
// like stack unwinding after an exception.
InstallerFactory factory = new BasicInstallerFactory();
Uninstaller uninstaller = factory.createUninstaller(request, sdkManager, mySdkHandler.getFileOp());
if (uninstaller.prepare(progress)) {
uninstaller.complete(progress);
}
}
sdkManager.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, null, null);
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class AvdWizardUtilsTest method createMockSdk.
@NotNull
private static AndroidSdkHandler createMockSdk(String versionString, String path) {
FakeLocalPackage p = new FakeLocalPackage(path);
p.setRevision(Revision.parseRevision(versionString));
RepositoryPackages packages = new RepositoryPackages();
packages.setLocalPkgInfos(ImmutableList.of(p));
RepoManager mgr = new FakeRepoManager(null, packages);
return new AndroidSdkHandler(null, null, new MockFileOp(), mgr);
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class SdkBuildToolsTooLowErrorHandler method getQuickFixHyperlinks.
@NotNull
public List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull String minimumVersion, @NotNull Project project, @Nullable Module module) {
List<NotificationHyperlink> hyperlinks = new ArrayList<>();
boolean buildToolInstalled = false;
AndroidSdkHandler sdkHandler = null;
AndroidSdkData androidSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
if (androidSdkData != null) {
sdkHandler = androidSdkData.getSdkHandler();
}
if (sdkHandler != null) {
ProgressIndicator progress = new StudioLoggerProgressIndicator(SdkBuildToolsTooLowErrorHandler.class);
RepositoryPackages packages = sdkHandler.getSdkManager(progress).getPackages();
LocalPackage buildTool = packages.getLocalPackages().get(getBuildToolsPath(parseRevision(minimumVersion)));
buildToolInstalled = buildTool != null;
}
if (module != null) {
VirtualFile buildFile = getGradleBuildFile(module);
AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.find(project);
if (!buildToolInstalled) {
if (androidPluginInfo != null && androidPluginInfo.isExperimental()) {
hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, null));
} else {
hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, buildFile));
}
} else if (buildFile != null && androidPluginInfo != null && !androidPluginInfo.isExperimental()) {
hyperlinks.add(new FixBuildToolsVersionHyperlink(buildFile, minimumVersion));
}
if (buildFile != null) {
hyperlinks.add(new OpenFileHyperlink(buildFile.getPath()));
}
}
return hyperlinks;
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class PatchInstallerFactoryTest method setUp.
@Before
public void setUp() {
myFileOp = new MockFileOp();
myInstallerFactory = new PatchInstallerFactory();
myInstallerFactory.setFallbackFactory(new BasicInstallerFactory());
myRepositoryPackages = new RepositoryPackages();
File root = new File("/sdk");
myRepoManager = new FakeRepoManager(root, myRepositoryPackages);
}
use of com.android.repository.impl.meta.RepositoryPackages in project android by JetBrains.
the class RepositoryUrlManagerTest method testResolvedCoordinateLocalFirst.
public void testResolvedCoordinateLocalFirst() 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(SDK_DIR, ANDROID_HOME, myFileOp, mgr);
GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString("com.google.android.gms:play-services:4.+");
assertNotNull(coordinate);
assertEquals("4.4.52", resolveDynamicCoordinateVersion(coordinate));
}
Aggregations