summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhomart Mukhamejanov <zhomart@google.com>2018-05-03 05:27:20 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-05-03 05:27:20 +0200
commit98837bdcd169eb47f55340c00bf99ec2f6b959d8 (patch)
tree117a4ef98300db186f55d137a7010bd23f10c2bf
parentMerge "screen_ui: Use std::string in DrawTextLine() and siblings." (diff)
parentMerge "updater_sample: Add streaming to PayloadSpec" (diff)
downloadandroid_bootable_recovery-98837bdcd169eb47f55340c00bf99ec2f6b959d8.tar
android_bootable_recovery-98837bdcd169eb47f55340c00bf99ec2f6b959d8.tar.gz
android_bootable_recovery-98837bdcd169eb47f55340c00bf99ec2f6b959d8.tar.bz2
android_bootable_recovery-98837bdcd169eb47f55340c00bf99ec2f6b959d8.tar.lz
android_bootable_recovery-98837bdcd169eb47f55340c00bf99ec2f6b959d8.tar.xz
android_bootable_recovery-98837bdcd169eb47f55340c00bf99ec2f6b959d8.tar.zst
android_bootable_recovery-98837bdcd169eb47f55340c00bf99ec2f6b959d8.zip
Diffstat (limited to '')
-rw-r--r--updater_sample/res/raw/sample.json16
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java2
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/util/PackageFiles.java (renamed from updater_sample/src/com/example/android/systemupdatersample/util/PackagePropertyFiles.java)27
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/util/PayloadSpecs.java24
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineErrorCodes.java1
-rw-r--r--updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineStatuses.java2
-rw-r--r--updater_sample/tests/res/raw/update_config_stream_001.json4
-rw-r--r--updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java2
-rw-r--r--updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java4
9 files changed, 56 insertions, 26 deletions
diff --git a/updater_sample/res/raw/sample.json b/updater_sample/res/raw/sample.json
index 03335cc97..b6f4cdce6 100644
--- a/updater_sample/res/raw/sample.json
+++ b/updater_sample/res/raw/sample.json
@@ -1,18 +1,18 @@
{
"__name": "name will be visible on UI",
- "__url": "https:// or file:// uri to update file (zip, xz, ...)",
- "__type": "NON_STREAMING (from local file) OR STREAMING (on the fly)",
+ "__url": "https:// or file:// uri to update package (zip, xz, ...)",
+ "__type": "NON_STREAMING (from a local file) OR STREAMING (on the fly)",
"name": "SAMPLE-cake-release BUILD-12345",
- "url": "file:///data/builds/android-update.zip",
- "type": "NON_STREAMING",
- "streaming_metadata": {
+ "url": "http://foo.bar/builds/ota-001.zip",
+ "ab_install_type": "NON_STREAMING",
+ "ab_streaming_metadata": {
"__": "streaming_metadata is required only for streaming update",
"__property_files": "name, offset and size of files",
"property_files": [
{
- "__filename": "payload.bin and payload_properties.txt are required",
- "__offset": "defines beginning of update data in archive",
- "__size": "size of the update data in archive",
+ "__filename": "name of the file in package",
+ "__offset": "defines beginning of the file in package",
+ "__size": "size of the file in package",
"filename": "payload.bin",
"offset": 531,
"size": 5012323
diff --git a/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java b/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java
index 8507a9e84..9f1e5d170 100644
--- a/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java
+++ b/updater_sample/src/com/example/android/systemupdatersample/ui/MainActivity.java
@@ -297,7 +297,7 @@ public class MainActivity extends Activity {
}
/**
- * Helper class to delegate UpdateEngine callbacks to MainActivity
+ * Helper class to delegate {@code update_engine} callbacks to MainActivity
*/
class UpdateEngineCallbackImpl extends UpdateEngineCallback {
@Override
diff --git a/updater_sample/src/com/example/android/systemupdatersample/util/PackagePropertyFiles.java b/updater_sample/src/com/example/android/systemupdatersample/util/PackageFiles.java
index 3988b5928..b485234ea 100644
--- a/updater_sample/src/com/example/android/systemupdatersample/util/PackagePropertyFiles.java
+++ b/updater_sample/src/com/example/android/systemupdatersample/util/PackageFiles.java
@@ -16,13 +16,30 @@
package com.example.android.systemupdatersample.util;
-/** Utility class for property files in a package. */
-public final class PackagePropertyFiles {
+/** Utility class for an OTA package. */
+public final class PackageFiles {
- public static final String PAYLOAD_BINARY_FILE_NAME = "payload.bin";
+ /**
+ * Directory used to perform updates.
+ */
+ public static final String OTA_PACKAGE_DIR = "/data/ota_package";
- public static final String PAYLOAD_HEADER_FILE_NAME = "payload_header.bin";
+ /**
+ * update payload, it will be passed to {@code UpdateEngine#applyPayload}.
+ */
+ public static final String PAYLOAD_BINARY_FILE_NAME = "payload.bin";
+ /**
+ * Currently, when calling {@code UpdateEngine#applyPayload} to perform actions
+ * that don't require network access (e.g. change slot), update_engine still
+ * talks to the server to download/verify file.
+ * {@code update_engine} might throw error when rebooting if {@code UpdateEngine#applyPayload}
+ * is not supplied right headers and tokens.
+ * This behavior might change in future android versions.
+ *
+ * To avoid extra network request in {@code update_engine}, this file has to be
+ * downloaded and put in {@code OTA_PACKAGE_DIR}.
+ */
public static final String PAYLOAD_METADATA_FILE_NAME = "payload_metadata.bin";
public static final String PAYLOAD_PROPERTIES_FILE_NAME = "payload_properties.txt";
@@ -38,5 +55,5 @@ public final class PackagePropertyFiles {
*/
public static final String COMPATIBILITY_ZIP_FILE_NAME = "compatibility.zip";
- private PackagePropertyFiles() {}
+ private PackageFiles() {}
}
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) {
diff --git a/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineErrorCodes.java b/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineErrorCodes.java
index e63da6298..6d319c5af 100644
--- a/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineErrorCodes.java
+++ b/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineErrorCodes.java
@@ -50,6 +50,7 @@ public final class UpdateEngineErrorCodes {
CODE_TO_NAME_MAP.put(10, "PAYLOAD_HASH_MISMATCH_ERROR");
CODE_TO_NAME_MAP.put(11, "PAYLOAD_SIZE_MISMATCH_ERROR");
CODE_TO_NAME_MAP.put(12, "DOWNLOAD_PAYLOAD_VERIFICATION_ERROR");
+ CODE_TO_NAME_MAP.put(15, "NEW_ROOTFS_VERIFICATION_ERROR");
CODE_TO_NAME_MAP.put(20, "DOWNLOAD_STATE_INITIALIZATION_ERROR");
CODE_TO_NAME_MAP.put(48, "USER_CANCELLED");
CODE_TO_NAME_MAP.put(52, "UPDATED_BUT_NOT_ACTIVE");
diff --git a/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineStatuses.java b/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineStatuses.java
index 6203b201a..a96f19d84 100644
--- a/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineStatuses.java
+++ b/updater_sample/src/com/example/android/systemupdatersample/util/UpdateEngineStatuses.java
@@ -20,7 +20,7 @@ import android.util.SparseArray;
/**
* Helper class to work with update_engine's error codes.
- * Many error codes are defined in {@link UpdateEngine.UpdateStatusConstants},
+ * Many error codes are defined in {@code UpdateEngine.UpdateStatusConstants},
* but you can find more in system/update_engine/common/error_code.h.
*/
public final class UpdateEngineStatuses {
diff --git a/updater_sample/tests/res/raw/update_config_stream_001.json b/updater_sample/tests/res/raw/update_config_stream_001.json
index a9afd331c..15127cf2c 100644
--- a/updater_sample/tests/res/raw/update_config_stream_001.json
+++ b/updater_sample/tests/res/raw/update_config_stream_001.json
@@ -6,8 +6,8 @@
"property_files": [
{
"filename": "payload.bin",
- "offset": 531,
- "size": 5012323
+ "offset": 195,
+ "size": 8
}
]
}
diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java
index df47c8ca8..dc7ec09e1 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/util/FileDownloaderTest.java
@@ -73,7 +73,7 @@ public class FileDownloaderTest {
FileDownloader downloader = new FileDownloader(url, 160, 8, outFile);
downloader.download();
String downloadedContent = String.join("\n", Files.readAllLines(outFile.toPath()));
- // Look at tools/create_test_ota.py
+ // archive contains text files with uppercase filenames
assertEquals("CARE_MAP", downloadedContent);
}
diff --git a/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java b/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java
index 6f06ca3e1..c13ba5556 100644
--- a/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java
+++ b/updater_sample/tests/src/com/example/android/systemupdatersample/util/PayloadSpecsTest.java
@@ -16,8 +16,8 @@
package com.example.android.systemupdatersample.util;
-import static com.example.android.systemupdatersample.util.PackagePropertyFiles.PAYLOAD_BINARY_FILE_NAME;
-import static com.example.android.systemupdatersample.util.PackagePropertyFiles.PAYLOAD_PROPERTIES_FILE_NAME;
+import static com.example.android.systemupdatersample.util.PackageFiles.PAYLOAD_BINARY_FILE_NAME;
+import static com.example.android.systemupdatersample.util.PackageFiles.PAYLOAD_PROPERTIES_FILE_NAME;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;