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);
}
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);
}
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;
}
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);
}
Aggregations