From 0dd5a83d0ec4c9d7b51843dd6eebd5ce92a1ad92 Mon Sep 17 00:00:00 2001 From: Zhomart Mukhamejanov Date: Mon, 23 Apr 2018 11:38:54 -0700 Subject: updater_sample: add streaming support - UpdateConfigs: add helper methods for streaming - add PrepareStreamingService intent service Test: manually and junit4 Bug: 77148143 Change-Id: I61711eb9abe051987e725fbd94f8cd029ff21dd3 --- .../android/systemupdatersample/util/FileDownloader.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'updater_sample/src/com/example/android/systemupdatersample/util/FileDownloader.java') diff --git a/updater_sample/src/com/example/android/systemupdatersample/util/FileDownloader.java b/updater_sample/src/com/example/android/systemupdatersample/util/FileDownloader.java index 5c1d71117..ddd0919b8 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/util/FileDownloader.java +++ b/updater_sample/src/com/example/android/systemupdatersample/util/FileDownloader.java @@ -38,22 +38,23 @@ public final class FileDownloader { private String mUrl; private long mOffset; private long mSize; - private File mOut; + private File mDestination; - public FileDownloader(String url, long offset, long size, File out) { + public FileDownloader(String url, long offset, long size, File destination) { this.mUrl = url; this.mOffset = offset; this.mSize = size; - this.mOut = out; + this.mDestination = destination; } /** * Downloads the file with given offset and size. + * @throws IOException when can't download the file */ public void download() throws IOException { - Log.d("FileDownloader", "downloading " + mOut.getName() + Log.d("FileDownloader", "downloading " + mDestination.getName() + " from " + mUrl - + " to " + mOut.getAbsolutePath()); + + " to " + mDestination.getAbsolutePath()); URL url = new URL(mUrl); URLConnection connection = url.openConnection(); @@ -61,7 +62,7 @@ public final class FileDownloader { // download the file try (InputStream input = connection.getInputStream()) { - try (OutputStream output = new FileOutputStream(mOut)) { + try (OutputStream output = new FileOutputStream(mDestination)) { long skipped = input.skip(mOffset); if (skipped != mOffset) { throw new IOException("Can't download file " -- cgit v1.2.3