Search in sources :

Example 1 with BasicInstallerFactory

use of com.android.repository.impl.installer.BasicInstallerFactory 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 2 with BasicInstallerFactory

use of com.android.repository.impl.installer.BasicInstallerFactory in project android by JetBrains.

the class ComponentInstaller method installPackages.

public void installPackages(@NotNull List<RemotePackage> packages, ProgressIndicator progress) throws WizardException {
    RepoManager sdkManager = mySdkHandler.getSdkManager(progress);
    for (RemotePackage request : packages) {
        // Intentionally don't register any listeners on the installer, so we don't recurse on haxm
        // TODO: This is a hack. Any future rewrite of this shouldn't require this behavior.
        InstallerFactory factory = new BasicInstallerFactory();
        Installer installer = factory.createInstaller(request, sdkManager, new StudioDownloader(), mySdkHandler.getFileOp());
        if (installer.prepare(progress)) {
            installer.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) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader)

Example 3 with BasicInstallerFactory

use of com.android.repository.impl.installer.BasicInstallerFactory in project android by JetBrains.

the class StudioSdkInstallerUtil method createInstallerFactory.

/**
   * Find the best {@link InstallerFactory} for the given {@link RepoPackage}.
   */
@NotNull
public static InstallerFactory createInstallerFactory(@NotNull AndroidSdkHandler sdkHandler) {
    InstallerFactory factory;
    InstallerFactory basicFactory = new BasicInstallerFactory();
    if (Boolean.getBoolean("sdk.patches.disable")) {
        factory = basicFactory;
    } else {
        factory = new PatchInstallerFactory();
        factory.setFallbackFactory(basicFactory);
    }
    factory.setListenerFactory(new StudioSdkInstallListenerFactory(sdkHandler));
    return factory;
}
Also used : BasicInstallerFactory(com.android.repository.impl.installer.BasicInstallerFactory) InstallerFactory(com.android.repository.api.InstallerFactory) PatchInstallerFactory(com.android.tools.idea.sdk.install.patch.PatchInstallerFactory) BasicInstallerFactory(com.android.repository.impl.installer.BasicInstallerFactory) PatchInstallerFactory(com.android.tools.idea.sdk.install.patch.PatchInstallerFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with BasicInstallerFactory

use of com.android.repository.impl.installer.BasicInstallerFactory 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)

Aggregations

BasicInstallerFactory (com.android.repository.impl.installer.BasicInstallerFactory)4 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)2 InstallerFactory (com.android.repository.api.InstallerFactory)1 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)1 MockFileOp (com.android.repository.testframework.MockFileOp)1 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)1 PatchInstallerFactory (com.android.tools.idea.sdk.install.patch.PatchInstallerFactory)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1 Before (org.junit.Before)1