diff options
author | Zhomart Mukhamejanov <zhomart@google.com> | 2018-05-01 21:50:55 +0200 |
---|---|---|
committer | Zhomart Mukhamejanov <zhomart@google.com> | 2018-05-02 21:40:49 +0200 |
commit | da7e23759660ebf76a184e4c4d981f11ef9e2653 (patch) | |
tree | 793aee240bbc3ec4ead128c39a7c25dfa475d078 /updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java | |
parent | Merge "Add ScreenRecoveryUI::ShowMenu()." (diff) | |
download | android_bootable_recovery-da7e23759660ebf76a184e4c4d981f11ef9e2653.tar android_bootable_recovery-da7e23759660ebf76a184e4c4d981f11ef9e2653.tar.gz android_bootable_recovery-da7e23759660ebf76a184e4c4d981f11ef9e2653.tar.bz2 android_bootable_recovery-da7e23759660ebf76a184e4c4d981f11ef9e2653.tar.lz android_bootable_recovery-da7e23759660ebf76a184e4c4d981f11ef9e2653.tar.xz android_bootable_recovery-da7e23759660ebf76a184e4c4d981f11ef9e2653.tar.zst android_bootable_recovery-da7e23759660ebf76a184e4c4d981f11ef9e2653.zip |
Diffstat (limited to '')
-rw-r--r-- | updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java b/updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java index 43c8d75e2..4db448a31 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java +++ b/updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java @@ -16,9 +16,6 @@ package com.example.android.systemupdatersample.util; -import android.annotation.TargetApi; -import android.os.Build; - import com.example.android.systemupdatersample.PayloadSpec; import java.io.BufferedReader; @@ -26,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; @@ -34,7 +32,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; /** The helper class that creates {@link PayloadSpec}. */ -@TargetApi(Build.VERSION_CODES.N) public final class PayloadSpecs { /** @@ -68,14 +65,14 @@ public final class PayloadSpecs { } long length = entry.getCompressedSize(); - if (PackagePropertyFiles.PAYLOAD_BINARY_FILE_NAME.equals(name)) { + if (PackageFiles.PAYLOAD_BINARY_FILE_NAME.equals(name)) { if (entry.getMethod() != ZipEntry.STORED) { throw new IOException("Invalid compression method."); } payloadFound = true; payloadOffset = offset; payloadSize = length; - } else if (PackagePropertyFiles.PAYLOAD_PROPERTIES_FILE_NAME.equals(name)) { + } else if (PackageFiles.PAYLOAD_PROPERTIES_FILE_NAME.equals(name)) { InputStream inputStream = zip.getInputStream(entry); if (inputStream != null) { BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); @@ -101,6 +98,21 @@ public final class PayloadSpecs { } /** + * Creates a {@link PayloadSpec} for streaming update. + */ + public static PayloadSpec forStreaming(String updateUrl, + long offset, + long size, + File propertiesFile) throws IOException { + return PayloadSpec.newBuilder() + .url(updateUrl) + .offset(offset) + .size(size) + .properties(Files.readAllLines(propertiesFile.toPath())) + .build(); + } + + /** * Converts an {@link PayloadSpec} to a string. */ public static String toString(PayloadSpec payloadSpec) { |