summaryrefslogtreecommitdiffstats
path: root/updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java
diff options
context:
space:
mode:
Diffstat (limited to 'updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java')
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java24
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) {