Search in sources :

Example 1 with Archive

use of com.android.repository.impl.meta.Archive in project android by JetBrains.

the class PatchInstaller method doPrepare.

@Override
protected boolean doPrepare(@NotNull File tempDir, @NotNull ProgressIndicator progress) {
    LocalPackage local = getRepoManager().getPackages().getLocalPackages().get(getPackage().getPath());
    Archive archive = getPackage().getArchive();
    assert archive != null;
    Archive.PatchType patch = archive.getPatch(local.getVersion());
    assert patch != null;
    myPatchFile = downloadPatchFile(patch, tempDir, progress);
    if (myPatchFile == null) {
        progress.logWarning("Patch failed to download.");
        return false;
    }
    return true;
}
Also used : Archive(com.android.repository.impl.meta.Archive)

Example 2 with Archive

use of com.android.repository.impl.meta.Archive 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 3 with Archive

use of com.android.repository.impl.meta.Archive 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 4 with Archive

use of com.android.repository.impl.meta.Archive in project android by JetBrains.

the class FullInstaller method downloadAndUnzip.

private boolean downloadAndUnzip(@NotNull File installTempPath, @NotNull Downloader downloader, @NotNull ProgressIndicator progress) {
    URL url = InstallerUtil.resolveCompleteArchiveUrl(getPackage(), progress);
    if (url == null) {
        progress.logWarning("No compatible archive found!");
        return false;
    }
    Archive archive = getPackage().getArchive();
    assert archive != null;
    try {
        File downloadLocation = new File(installTempPath, url.getFile());
        String checksum = archive.getComplete().getChecksum();
        downloader.downloadFully(url, downloadLocation, checksum, progress);
        if (progress.isCanceled()) {
            return false;
        }
        if (!mFop.exists(downloadLocation)) {
            progress.logWarning("Failed to download package!");
            return false;
        }
        File unzip = new File(installTempPath, UNZIP_DIR_FN);
        mFop.mkdirs(unzip);
        InstallerUtil.unzip(downloadLocation, unzip, mFop, archive.getComplete().getSize(), progress);
        if (progress.isCanceled()) {
            return false;
        }
        mFop.delete(downloadLocation);
        return true;
    } catch (IOException e) {
        StringBuilder message = new StringBuilder("An error occurred while preparing SDK package ").append(getPackage().getDisplayName());
        String exceptionMessage = e.getMessage();
        if (exceptionMessage != null && !exceptionMessage.isEmpty()) {
            message.append(": ").append(exceptionMessage);
        } else {
            message.append(".");
        }
        progress.logWarning(message.toString(), e);
    }
    return false;
}
Also used : Archive(com.android.repository.impl.meta.Archive) IOException(java.io.IOException) File(java.io.File) URL(java.net.URL)

Aggregations

Archive (com.android.repository.impl.meta.Archive)4 RemotePackage (com.android.repository.api.RemotePackage)2 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 Nullable (org.jetbrains.annotations.Nullable)1