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;
}
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> </td><td>").append(WelcomeUIUtils.getSizeLabel(archive.getComplete().getSize())).append("</td></tr>");
}
table.append("</table>");
return table.toString();
}
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));
}
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;
}
Aggregations