Search in sources :

Example 26 with AndroidSdkHandler

use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.

the class StudioSdkUtil method reloadRemoteSdkWithModalProgress.

/**
   * Convenience method to reload the local and remote SDK, showing a modal, non-cancellable progress window.
   */
public static void reloadRemoteSdkWithModalProgress() {
    final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    StudioProgressRunner runner = new StudioProgressRunner(true, false, "Refreshing SDK", false, null);
    StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(StudioSdkUtil.class);
    RepoManager sdkManager = sdkHandler.getSdkManager(progress);
    sdkManager.load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, null, null, null, runner, new StudioDownloader(null), StudioSettingsController.getInstance(), true);
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) RepoManager(com.android.repository.api.RepoManager) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler)

Example 27 with AndroidSdkHandler

use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.

the class HaxmWizard method doCancelAction.

@Override
public void doCancelAction() {
    if (myHaxmPath.canPerformFinishingActions()) {
        doFinishAction();
        return;
    }
    // Have to ensure the SDK package is removed
    if (!myInvokedToUninstall) {
        try {
            AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
            ComponentInstaller componentInstaller = new ComponentInstaller(sdkHandler);
            ProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
            sdkHandler.getSdkManager(progress).reloadLocalIfNeeded(progress);
            componentInstaller.ensureSdkPackagesUninstalled(myHaxmPath.myHaxm.getRequiredSdkPackages(), progress);
        } catch (Exception e) {
            Messages.showErrorDialog(SDK_PACKAGE_CLEANUP_FAILED, "Cleanup Error");
            LOG.warn("Failed to make sure HAXM SDK package is uninstalled after HAXM wizard was cancelled", e);
        }
    }
    super.doCancelAction();
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) IOException(java.io.IOException)

Example 28 with AndroidSdkHandler

use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.

the class SdkMerger method compareSdks.

@NotNull
private static Collection<MergeablePackage> compareSdks(@NotNull File srcDir, @NotNull File destDir, @Nullable ProgressIndicator progress) {
    com.android.repository.api.ProgressIndicator repoProgress = getRepoProgress(progress);
    Collection<MergeablePackage> results = Lists.newArrayList();
    AndroidSdkHandler srcHandler = AndroidSdkHandler.getInstance(srcDir);
    AndroidSdkHandler destHandler = AndroidSdkHandler.getInstance(destDir);
    Map<String, ? extends LocalPackage> srcPackages = srcHandler.getSdkManager(repoProgress).getPackages().getLocalPackages();
    Map<String, ? extends LocalPackage> destPackages = destHandler.getSdkManager(repoProgress).getPackages().getLocalPackages();
    for (LocalPackage srcPkg : srcPackages.values()) {
        LocalPackage destPkg = destPackages.get(srcPkg.getPath());
        if (destPkg != null) {
            if (srcPkg.getVersion().compareTo(destPkg.getVersion()) > 0) {
                // Package exists in destination but is old; replace it.
                results.add(new MergeablePackage(srcPkg, destPkg, destDir));
            }
        } else {
            // Package doesn't exist in destination; copy it over.
            results.add(new MergeablePackage(srcPkg, null, destDir));
        }
    }
    return results;
}
Also used : LocalPackage(com.android.repository.api.LocalPackage) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with AndroidSdkHandler

use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.

the class AaptInvoker method getPathToAapt.

/**
   * @return the path to aapt from the latest version of build tools that is installed, null if there are no build tools
   */
@Nullable
private static Path getPathToAapt() {
    AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    BuildToolInfo latestBuildTool = sdkHandler.getLatestBuildTool(new StudioLoggerProgressIndicator(AaptInvoker.class), true);
    if (latestBuildTool == null) {
        return null;
    }
    return latestBuildTool.getLocation().toPath().resolve(SdkConstants.FN_AAPT);
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) BuildToolInfo(com.android.sdklib.BuildToolInfo) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) Nullable(org.jetbrains.annotations.Nullable)

Example 30 with AndroidSdkHandler

use of com.android.sdklib.repository.AndroidSdkHandler in project android by JetBrains.

the class NewModuleWizardState method putSdkDependentParams.

public void putSdkDependentParams() {
    final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    BuildToolInfo buildTool = sdkHandler.getLatestBuildTool(new StudioLoggerProgressIndicator(getClass()), false);
    if (buildTool != null) {
        // If buildTool is null, the template will use buildApi instead, which might be good enough.
        put(ATTR_BUILD_TOOLS_VERSION, buildTool.getRevision().toString());
    }
    File location = sdkHandler.getLocation();
    if (location != null) {
        // Gradle expects a platform-neutral path
        put(ATTR_SDK_DIR, FileUtil.toSystemIndependentName(location.getPath()));
    }
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) BuildToolInfo(com.android.sdklib.BuildToolInfo) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)38 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)23 File (java.io.File)11 Nullable (org.jetbrains.annotations.Nullable)11 RepoManager (com.android.repository.api.RepoManager)10 NotNull (org.jetbrains.annotations.NotNull)9 RemotePackage (com.android.repository.api.RemotePackage)8 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)8 ProgressIndicator (com.android.repository.api.ProgressIndicator)6 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)6 BuildToolInfo (com.android.sdklib.BuildToolInfo)6 IAndroidTarget (com.android.sdklib.IAndroidTarget)6 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)6 ImmutableList (com.google.common.collect.ImmutableList)4 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)3 Revision (com.android.repository.Revision)3 LocalPackage (com.android.repository.api.LocalPackage)3 RepoPackage (com.android.repository.api.RepoPackage)3 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)3 MockFileOp (com.android.repository.testframework.MockFileOp)3