Search in sources :

Example 11 with RemotePackage

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

the class Platform method findLatestCompatibleBuildTool.

private String findLatestCompatibleBuildTool() {
    Revision revision = null;
    String path = null;
    for (RemotePackage remote : getRepositoryPackages().getRemotePackages().values()) {
        if (!remote.getPath().startsWith(SdkConstants.FD_BUILD_TOOLS)) {
            continue;
        }
        Revision testRevision = remote.getVersion();
        if (testRevision.getMajor() == myVersion.getApiLevel() && (revision == null || testRevision.compareTo(revision) > 0)) {
            revision = testRevision;
            path = remote.getPath();
        }
    }
    return path;
}
Also used : Revision(com.android.repository.Revision) RemotePackage(com.android.repository.api.RemotePackage)

Example 12 with RemotePackage

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

the class InstallComponentsPath method findLatestPlatform.

@Nullable
public static RemotePackage findLatestPlatform(@Nullable Map<String, RemotePackage> remotePackages) {
    if (remotePackages == null) {
        return null;
    }
    AndroidVersion max = null;
    RemotePackage latest = null;
    for (RemotePackage pkg : remotePackages.values()) {
        TypeDetails details = pkg.getTypeDetails();
        if (!(details instanceof DetailsTypes.PlatformDetailsType)) {
            continue;
        }
        DetailsTypes.PlatformDetailsType platformDetails = (DetailsTypes.PlatformDetailsType) details;
        AndroidVersion version = platformDetails.getAndroidVersion();
        if (version.isPreview()) {
            // We only want stable platforms
            continue;
        }
        if (max == null || version.compareTo(max) > 0) {
            latest = pkg;
            max = version;
        }
    }
    return latest;
}
Also used : TypeDetails(com.android.repository.impl.meta.TypeDetails) DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) AndroidVersion(com.android.sdklib.AndroidVersion) RemotePackage(com.android.repository.api.RemotePackage) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with RemotePackage

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

the class InstallSummaryStep method getPackagesTable.

@Nullable
private static String getPackagesTable(@NotNull Collection<RemotePackage> remotePackages) {
    if (remotePackages.isEmpty()) {
        return null;
    }
    TreeSet<RemotePackage> sortedPackagesList = Sets.newTreeSet(new PackageInfoComparator());
    sortedPackagesList.addAll(remotePackages);
    StringBuilder table = new StringBuilder("<table>");
    for (RemotePackage remotePkgInfo : sortedPackagesList) {
        Archive archive = remotePkgInfo.getArchive();
        assert archive != null;
        // Adds some whitespace between name and size columns
        table.append("<tr><td>").append(remotePkgInfo.getDisplayName()).append("</td><td>&nbsp;&nbsp;</td><td>").append(WelcomeUIUtils.getSizeLabel(archive.getComplete().getSize())).append("</td></tr>");
    }
    table.append("</table>");
    return table.toString();
}
Also used : Archive(com.android.repository.impl.meta.Archive) RemotePackage(com.android.repository.api.RemotePackage) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with RemotePackage

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

the class InstallSummaryStep method getDownloadSizeSection.

private static Section getDownloadSizeSection(@NotNull Collection<RemotePackage> remotePackages) {
    long downloadSize = 0;
    for (RemotePackage remotePackage : remotePackages) {
        // TODO: patches?
        Archive archive = remotePackage.getArchive();
        assert archive != null;
        downloadSize += archive.getComplete().getSize();
    }
    return new Section("Total Download Size", downloadSize == 0 ? "" : WelcomeUIUtils.getSizeLabel(downloadSize));
}
Also used : Archive(com.android.repository.impl.meta.Archive) RemotePackage(com.android.repository.api.RemotePackage)

Example 15 with RemotePackage

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

the class AndroidSdk method getLatestCompatibleBuildToolsPath.

/**
   * Find latest build tools revision. Versions compatible with the selected platforms will be installed by the platform components.
   * @return The Revision of the latest build tools package, or null if no remote build tools packages are available.
   */
@Nullable
private String getLatestCompatibleBuildToolsPath() {
    ProgressIndicator progress = new ProgressIndicatorAdapter() {
    };
    RemotePackage latest = mySdkHandler.getLatestRemotePackageForPrefix(SdkConstants.FD_BUILD_TOOLS, false, progress);
    return latest != null ? latest.getPath() : null;
}
Also used : ProgressIndicator(com.android.repository.api.ProgressIndicator) ProgressIndicatorAdapter(com.android.repository.api.ProgressIndicatorAdapter) RemotePackage(com.android.repository.api.RemotePackage) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

RemotePackage (com.android.repository.api.RemotePackage)18 Nullable (org.jetbrains.annotations.Nullable)8 File (java.io.File)7 RepoManager (com.android.repository.api.RepoManager)6 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)6 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)6 GradleCoordinate (com.android.ide.common.repository.GradleCoordinate)4 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)4 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)4 AndroidVersion (com.android.sdklib.AndroidVersion)3 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)3 StudioProgressRunner (com.android.tools.idea.sdk.progress.StudioProgressRunner)3 ImmutableList (com.google.common.collect.ImmutableList)3 Project (com.intellij.openapi.project.Project)3 Map (java.util.Map)3 NotNull (org.jetbrains.annotations.NotNull)3 Revision (com.android.repository.Revision)2 LocalPackage (com.android.repository.api.LocalPackage)2 ProgressIndicator (com.android.repository.api.ProgressIndicator)2 DEFAULT_EXPIRATION_PERIOD_MS (com.android.repository.api.RepoManager.DEFAULT_EXPIRATION_PERIOD_MS)2