Search in sources :

Example 6 with StudioLoggerProgressIndicator

use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.

the class InstallComponentsPath method deriveValues.

@Override
public void deriveValues(Set<ScopedStateStore.Key> modified) {
    super.deriveValues(modified);
    if (modified.contains(WizardConstants.KEY_SDK_INSTALL_LOCATION)) {
        String sdkPath = myState.get(WizardConstants.KEY_SDK_INSTALL_LOCATION);
        if (sdkPath != null) {
            File sdkLocation = new File(sdkPath);
            if (!FileUtil.filesEqual(myLocalHandler.getLocation(), sdkLocation)) {
                myLocalHandler = AndroidSdkHandler.getInstance(sdkLocation);
                StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
                myLocalHandler.getSdkManager(progress).loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, new StudioDownloader(), StudioSettingsController.getInstance());
                myComponentInstaller = new ComponentInstaller(myLocalHandler);
                myComponentTree.updateState(myLocalHandler);
            }
        }
    }
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) File(java.io.File) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader)

Example 7 with StudioLoggerProgressIndicator

use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator 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 8 with StudioLoggerProgressIndicator

use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.

the class AndroidSdkUtils method isGlassInstalled.

public static boolean isGlassInstalled() {
    StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(AndroidSdkUtils.class);
    AndroidSdkHandler handler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    Collection<IAndroidTarget> targets = handler.getAndroidTargetManager(progress).getTargets(progress);
    for (IAndroidTarget target : targets) {
        if (!target.isPlatform() && target.getName().startsWith("Glass Development Kit")) {
            return true;
        }
    }
    return false;
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) IAndroidTarget(com.android.sdklib.IAndroidTarget)

Example 9 with StudioLoggerProgressIndicator

use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.

the class RepositoryUrlManager method resolveDynamicCoordinateVersion.

@Nullable
@VisibleForTesting
String resolveDynamicCoordinateVersion(@NotNull GradleCoordinate coordinate, @Nullable Project project, @NotNull AndroidSdkHandler sdkHandler) {
    if (coordinate.getGroupId() == null || coordinate.getArtifactId() == null) {
        return null;
    }
    String filter = coordinate.getRevision();
    if (!filter.endsWith("+")) {
        // Already resolved. That was easy.
        return filter;
    }
    filter = filter.substring(0, filter.length() - 1);
    File sdkLocation = sdkHandler.getLocation();
    if (sdkLocation != null) {
        // If this coordinate points to an artifact in one of our repositories, mark it will a comment if they don't
        // have that repository available.
        String libraryCoordinate = getLibraryRevision(coordinate.getGroupId(), coordinate.getArtifactId(), filter, false, sdkLocation, sdkHandler.getFileOp());
        if (libraryCoordinate != null) {
            return libraryCoordinate;
        }
        // If that didn't yield any matches, try again, this time allowing preview platforms.
        // This is necessary if the artifact filter includes enough of a version where there are
        // only preview matches.
        libraryCoordinate = getLibraryRevision(coordinate.getGroupId(), coordinate.getArtifactId(), filter, true, sdkLocation, sdkHandler.getFileOp());
        if (libraryCoordinate != null) {
            return libraryCoordinate;
        }
    }
    // Regular Gradle dependency? Look in Gradle cache
    GradleVersion versionFound = GradleLocalCache.getInstance().findLatestArtifactVersion(coordinate, project, filter);
    if (versionFound != null) {
        return versionFound.toString();
    }
    // Maybe it's available for download as an SDK component
    RemotePackage sdkPackage = SdkMavenRepository.findLatestRemoteVersion(coordinate, sdkHandler, new StudioLoggerProgressIndicator(getClass()));
    if (sdkPackage != null) {
        GradleCoordinate found = SdkMavenRepository.getCoordinateFromSdkPath(sdkPackage.getPath());
        if (found != null) {
            return found.getRevision();
        }
    }
    // Perform network lookup to resolve current best version, if possible
    if (project != null) {
        LintClient client = new LintIdeClient(project);
        Revision latest = GradleDetector.getLatestVersionFromRemoteRepo(client, coordinate, coordinate.isPreview());
        if (latest != null) {
            String version = latest.toShortString();
            if (version.startsWith(filter)) {
                return version;
            }
        }
    }
    return null;
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) GradleCoordinate(com.android.ide.common.repository.GradleCoordinate) Revision(com.android.repository.Revision) LintClient(com.android.tools.lint.client.api.LintClient) LintIdeClient(com.android.tools.idea.lint.LintIdeClient) GradleVersion(com.android.ide.common.repository.GradleVersion) File(java.io.File) RemotePackage(com.android.repository.api.RemotePackage) VisibleForTesting(com.android.annotations.VisibleForTesting) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with StudioLoggerProgressIndicator

use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.

the class AndroidSdkUpdaterPlugin method initComponent.

@Override
public void initComponent() {
    if (isAndroidSdkManagerEnabled()) {
        ExternalComponentManager.getInstance().registerComponentSource(new SdkComponentSource());
        URL offlineRepo = getOfflineRepoDir();
        if (offlineRepo != null) {
            // We don't have an actual RepoManager yet, so just get all the modules statically.
            RepositorySourceProvider provider = new ConstantSourceProvider(offlineRepo.toString(), "Offline Repo", AndroidSdkHandler.getAllModules());
            AndroidSdkHandler.addCustomSourceProvider(provider, new StudioLoggerProgressIndicator(getClass()));
        }
    }
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ConstantSourceProvider(com.android.repository.api.ConstantSourceProvider) RepositorySourceProvider(com.android.repository.api.RepositorySourceProvider) URL(java.net.URL)

Aggregations

StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)40 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)22 File (java.io.File)11 Nullable (org.jetbrains.annotations.Nullable)9 RepoManager (com.android.repository.api.RepoManager)8 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)8 ProgressIndicator (com.android.repository.api.ProgressIndicator)7 Revision (com.android.repository.Revision)6 LocalPackage (com.android.repository.api.LocalPackage)6 RemotePackage (com.android.repository.api.RemotePackage)6 BuildToolInfo (com.android.sdklib.BuildToolInfo)6 NotNull (org.jetbrains.annotations.NotNull)6 IAndroidTarget (com.android.sdklib.IAndroidTarget)4 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)4 VisibleForTesting (com.android.annotations.VisibleForTesting)3 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)3 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)3 GradleSyncInvoker (com.android.tools.idea.gradle.project.sync.GradleSyncInvoker)3 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)3 ImmutableList (com.google.common.collect.ImmutableList)3