Search in sources :

Example 6 with RepositoryPackages

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);
}
Also used : BasicInstallerFactory(com.android.repository.impl.installer.BasicInstallerFactory) BasicInstallerFactory(com.android.repository.impl.installer.BasicInstallerFactory) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages)

Example 7 with RepositoryPackages

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);
}
Also used : FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) RepoManager(com.android.repository.api.RepoManager) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) MockFileOp(com.android.repository.testframework.MockFileOp) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with RepositoryPackages

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalPackage(com.android.repository.api.LocalPackage) FixBuildToolsVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixBuildToolsVersionHyperlink) ArrayList(java.util.ArrayList) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) InstallBuildToolsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) AndroidPluginInfo(com.android.tools.idea.gradle.plugin.AndroidPluginInfo) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) OpenFileHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with RepositoryPackages

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);
}
Also used : BasicInstallerFactory(com.android.repository.impl.installer.BasicInstallerFactory) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) MockFileOp(com.android.repository.testframework.MockFileOp) File(java.io.File) Before(org.junit.Before)

Example 10 with RepositoryPackages

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));
}
Also used : RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) RepoManager(com.android.repository.api.RepoManager) GradleCoordinate(com.android.ide.common.repository.GradleCoordinate) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) RemotePackage(com.android.repository.api.RemotePackage)

Aggregations

RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)15 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)9 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)7 File (java.io.File)6 LocalPackage (com.android.repository.api.LocalPackage)5 FakeLocalPackage (com.android.repository.testframework.FakePackage.FakeLocalPackage)5 NotNull (org.jetbrains.annotations.NotNull)5 RemotePackage (com.android.repository.api.RemotePackage)4 RepoManager (com.android.repository.api.RepoManager)4 Test (org.junit.Test)4 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)3 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)3 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)2 BasicInstallerFactory (com.android.repository.impl.installer.BasicInstallerFactory)2 FakeDependency (com.android.repository.testframework.FakeDependency)2 FakeRemotePackage (com.android.repository.testframework.FakePackage.FakeRemotePackage)2 MockFileOp (com.android.repository.testframework.MockFileOp)2 HtmlBuilder (com.android.utils.HtmlBuilder)2 Before (org.junit.Before)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1