From 6aa5fb0bbe8d074208648593d177553e732e6d9d Mon Sep 17 00:00:00 2001 From: Zhomart Mukhamejanov Date: Wed, 9 May 2018 14:28:49 -0700 Subject: updater_sample: add http header demo Added demo passing http headers to UpdateEngine#applyPayload. Bug: 79483768 Test: manually Change-Id: I3e9c812dba2066acadbcea8d07c933368806e20c Signed-off-by: Zhomart Mukhamejanov --- .../android/systemupdatersample/UpdateConfig.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'updater_sample/src/com/example/android/systemupdatersample/UpdateConfig.java') diff --git a/updater_sample/src/com/example/android/systemupdatersample/UpdateConfig.java b/updater_sample/src/com/example/android/systemupdatersample/UpdateConfig.java index 1851724ed..b08bfd0f6 100644 --- a/updater_sample/src/com/example/android/systemupdatersample/UpdateConfig.java +++ b/updater_sample/src/com/example/android/systemupdatersample/UpdateConfig.java @@ -25,6 +25,7 @@ import org.json.JSONObject; import java.io.File; import java.io.Serializable; +import java.util.Optional; /** * An update description. It will be parsed from JSON, which is intended to @@ -78,7 +79,9 @@ public class UpdateConfig implements Parcelable { p.getLong("offset"), p.getLong("size")); } - c.mAbStreamingMetadata = new StreamingMetadata(propertyFiles); + c.mAbStreamingMetadata = new StreamingMetadata( + propertyFiles, + meta.getString("authorization_token")); } c.mRawJson = json; return c; @@ -178,17 +181,23 @@ public class UpdateConfig implements Parcelable { /** defines beginning of update data in archive */ private PackageFile[] mPropertyFiles; - public StreamingMetadata() { - mPropertyFiles = new PackageFile[0]; - } + /** SystemUpdaterSample receives the authorization token from the OTA server, in addition + * to the package URL. It passes on the info to update_engine, so that the latter can + * fetch the data from the package server directly with the token. */ + private String mAuthorization; - public StreamingMetadata(PackageFile[] propertyFiles) { + public StreamingMetadata(PackageFile[] propertyFiles, String authorization) { this.mPropertyFiles = propertyFiles; + this.mAuthorization = authorization; } public PackageFile[] getPropertyFiles() { return mPropertyFiles; } + + public Optional getAuthorization() { + return Optional.of(mAuthorization); + } } /** @@ -224,7 +233,6 @@ public class UpdateConfig implements Parcelable { public long getSize() { return mSize; } - } } -- cgit v1.2.3