Search in sources :

Example 1 with RepoManager

use of com.android.repository.api.RepoManager in project android by JetBrains.

the class InstantRunPositionManager method getAllPlatformSourcePackages.

private static Collection<? extends LocalPackage> getAllPlatformSourcePackages() {
    AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    RepoManager sdkManager = sdkHandler.getSdkManager(new StudioLoggerProgressIndicator(InstantRunPositionManager.class));
    return sdkManager.getPackages().getLocalPackagesForPrefix(SdkConstants.FD_ANDROID_SOURCES);
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler)

Example 2 with RepoManager

use of com.android.repository.api.RepoManager in project android by JetBrains.

the class InstallComponentsPath method createComponentTree.

private ComponentTreeNode createComponentTree(@NotNull FirstRunWizardMode reason, @NotNull ScopedStateStore stateStore, boolean createAvd) {
    List<ComponentTreeNode> components = Lists.newArrayList();
    components.add(new AndroidSdk(stateStore, myInstallUpdates));
    DynamicWizard wizard = getWizard();
    ProgressWindow progressWindow = new ProgressWindow(false, false, null);
    if (wizard != null) {
        Disposer.register(wizard.getDisposable(), progressWindow);
    }
    com.android.repository.api.ProgressIndicator progress = new RepoProgressIndicatorAdapter(progressWindow);
    RepoManager sdkManager = myLocalHandler.getSdkManager(new StudioLoggerProgressIndicator(getClass()));
    sdkManager.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, new StudioDownloader(progressWindow), StudioSettingsController.getInstance());
    Map<String, RemotePackage> remotePackages = sdkManager.getPackages().getRemotePackages();
    ComponentTreeNode platforms = Platform.createSubtree(stateStore, remotePackages, myInstallUpdates);
    if (platforms != null) {
        components.add(platforms);
    }
    if (Haxm.canRun() && reason == FirstRunWizardMode.NEW_INSTALL) {
        Haxm.HaxmInstallationIntention haxmInstallationIntention = myInstallUpdates ? Haxm.HaxmInstallationIntention.INSTALL_WITH_UPDATES : Haxm.HaxmInstallationIntention.INSTALL_WITHOUT_UPDATES;
        components.add(new Haxm(haxmInstallationIntention, stateStore, FirstRunWizard.KEY_CUSTOM_INSTALL));
    }
    if (createAvd) {
        components.add(new AndroidVirtualDevice(stateStore, remotePackages, myInstallUpdates, myFileOp));
    }
    return new ComponentCategory("Root", "Root node that is not supposed to appear in the UI", components);
}
Also used : StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) DynamicWizard(com.android.tools.idea.wizard.dynamic.DynamicWizard) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) RepoProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.RepoProgressIndicatorAdapter) ProgressWindow(com.intellij.openapi.progress.util.ProgressWindow) RemotePackage(com.android.repository.api.RemotePackage)

Example 3 with RepoManager

use of com.android.repository.api.RepoManager in project android by JetBrains.

the class AndroidStudioWelcomeScreenProvider method fetchPackages.

@NotNull
private static Map<String, RemotePackage> fetchPackages() {
    ConnectionState connectionState = checkInternetConnection();
    switch(connectionState) {
        case OK:
            break;
        case NO_CONNECTION:
            return ImmutableMap.of();
        default:
            throw new IllegalArgumentException(connectionState.name());
    }
    StudioLoggerProgressIndicator logger = new StudioLoggerProgressIndicator(AndroidStudioWelcomeScreenProvider.class);
    RepoManager mgr = AndroidSdks.getInstance().tryToChooseSdkHandler().getSdkManager(logger);
    mgr.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, logger, new StudioDownloader(), StudioSettingsController.getInstance());
    return mgr.getPackages().getRemotePackages();
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with RepoManager

use of com.android.repository.api.RepoManager in project android by JetBrains.

the class InstallCMakeHyperlink method execute.

@Override
protected void execute(@NotNull Project project) {
    // We need to statically fetch the SDK handler each time because the location might change.
    // TODO: remove the need for doing this each time.
    AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    StudioLoggerProgressIndicator progressIndicator = new StudioLoggerProgressIndicator(getClass());
    RepoManager sdkManager = sdkHandler.getSdkManager(progressIndicator);
    StudioProgressRunner progressRunner = new StudioProgressRunner(false, /* backgroundable */
    false, /* cancellable */
    "Loading Remote SDK", true, /* in UI thread */
    project);
    RepoManager.RepoLoadedCallback onComplete = packages -> {
        Collection<RemotePackage> cmakePackages = packages.getRemotePackagesForPrefix(FD_CMAKE);
        if (!cmakePackages.isEmpty()) {
            RemotePackage cmakePackage;
            if (cmakePackages.size() == 1) {
                cmakePackage = getFirstItem(cmakePackages);
            } else {
                cmakePackage = sdkHandler.getLatestRemotePackageForPrefix(FD_CMAKE, false, progressIndicator);
            }
            if (cmakePackage != null) {
                ModelWizardDialog dialog = createDialogForPaths(project, ImmutableList.of(cmakePackage.getPath()));
                if (dialog != null && dialog.showAndGet()) {
                    GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
                }
                return;
            }
            notifyCMakePackageNotFound(project);
        }
    };
    Runnable onError = () -> notifyCMakePackageNotFound(project);
    sdkManager.load(DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), ImmutableList.of(onError), progressRunner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Also used : AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) ContainerUtil.getFirstItem(com.intellij.util.containers.ContainerUtil.getFirstItem) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) Collection(java.util.Collection) DEFAULT_EXPIRATION_PERIOD_MS(com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS) RemotePackage(com.android.repository.api.RemotePackage) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) StudioSettingsController(com.android.tools.idea.sdk.StudioSettingsController) ImmutableList(com.google.common.collect.ImmutableList) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) FD_CMAKE(com.android.SdkConstants.FD_CMAKE) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) RepoManager(com.android.repository.api.RepoManager) NotNull(org.jetbrains.annotations.NotNull) GradleSyncInvoker(com.android.tools.idea.gradle.project.sync.GradleSyncInvoker) SdkQuickfixUtils.createDialogForPaths(com.android.tools.idea.sdk.wizard.SdkQuickfixUtils.createDialogForPaths) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) Collection(java.util.Collection) RemotePackage(com.android.repository.api.RemotePackage) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader)

Example 5 with RepoManager

use of com.android.repository.api.RepoManager in project android by JetBrains.

the class InstallNdkHyperlink method execute.

@Override
protected void execute(@NotNull Project project) {
    File path = getNdkPath(project);
    if (path != null) {
        // Try to install SDK in local.properties.
        SelectNdkDialog dialog = new SelectNdkDialog(path.getPath(), false, true);
        dialog.setModal(true);
        if (dialog.showAndGet() && setNdkPath(project, dialog.getAndroidNdkPath())) {
            // Saving NDK path is successful.
            GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
        }
        return;
    }
    // There is no path. Try installing from SDK.
    AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    StudioLoggerProgressIndicator progressIndicator = new StudioLoggerProgressIndicator(getClass());
    RepoManager sdkManager = sdkHandler.getSdkManager(progressIndicator);
    StudioProgressRunner progressRunner = new StudioProgressRunner(false, /* backgroundable */
    false, /* cancellable */
    "Loading Remote SDK", true, /* in UI thread */
    project);
    RepoManager.RepoLoadedCallback onComplete = packages -> {
        Map<String, RemotePackage> remotePackages = packages.getRemotePackages();
        RemotePackage ndkPackage = remotePackages.get(FD_NDK);
        if (ndkPackage != null) {
            ModelWizardDialog dialog = createDialogForPaths(project, ImmutableList.of(ndkPackage.getPath()));
            if (dialog != null && dialog.showAndGet()) {
                GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
            }
            return;
        }
        notifyNdkPackageNotFound(project);
    };
    Runnable onError = () -> notifyNdkPackageNotFound(project);
    sdkManager.load(DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), ImmutableList.of(onError), progressRunner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Also used : AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) IOException(java.io.IOException) DEFAULT_EXPIRATION_PERIOD_MS(com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS) RemotePackage(com.android.repository.api.RemotePackage) LocalProperties(com.android.tools.idea.gradle.util.LocalProperties) File(java.io.File) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog) Nullable(org.jetbrains.annotations.Nullable) SelectNdkDialog(com.android.tools.idea.sdk.SelectNdkDialog) StudioSettingsController(com.android.tools.idea.sdk.StudioSettingsController) ImmutableList(com.google.common.collect.ImmutableList) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) Map(java.util.Map) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) RepoManager(com.android.repository.api.RepoManager) Logger(com.intellij.openapi.diagnostic.Logger) NotNull(org.jetbrains.annotations.NotNull) FD_NDK(com.android.SdkConstants.FD_NDK) GradleSyncInvoker(com.android.tools.idea.gradle.project.sync.GradleSyncInvoker) SdkQuickfixUtils.createDialogForPaths(com.android.tools.idea.sdk.wizard.SdkQuickfixUtils.createDialogForPaths) SelectNdkDialog(com.android.tools.idea.sdk.SelectNdkDialog) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) File(java.io.File) Map(java.util.Map) RemotePackage(com.android.repository.api.RemotePackage) ModelWizardDialog(com.android.tools.idea.wizard.model.ModelWizardDialog)

Aggregations

RepoManager (com.android.repository.api.RepoManager)10 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)7 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)7 RemotePackage (com.android.repository.api.RemotePackage)5 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)4 NotNull (org.jetbrains.annotations.NotNull)4 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)3 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)3 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)3 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)2 DEFAULT_EXPIRATION_PERIOD_MS (com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS)2 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)2 AndroidSdks (com.android.tools.idea.sdk.AndroidSdks)2 StudioSettingsController (com.android.tools.idea.sdk.StudioSettingsController)2 SdkQuickfixUtils.createDialogForPaths (com.android.tools.idea.sdk.wizard.SdkQuickfixUtils.createDialogForPaths)2 ModelWizardDialog (com.android.tools.idea.wizard.model.ModelWizardDialog)2 ImmutableList (com.google.common.collect.ImmutableList)2 Project (com.intellij.openapi.project.Project)2 Messages (com.intellij.openapi.ui.Messages)2 File (java.io.File)2