summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Brad Ebinger <breadley@google.com> 2017-10-10 19:09:28 +0000
committer android-build-merger <android-build-merger@google.com> 2017-10-10 19:09:28 +0000
commitc51777b9b87d6b9f12f80cc998c30f6dea8de7d0 (patch)
tree5a3e8c27d0b0318415b2a8c60f0a7a53a7da7795
parentd3a55f4a1a5cb46b7a61993c831532800ffcd05a (diff)
parentd0c9d44df9e93c3508b8b75c0e0743d5e2e7e746 (diff)
Merge "Require DownloadRequest#Builder to have mandatory Source URI" am: 432c2b0fb9 am: 3b6df532f3 am: 8765abcc9e
am: d0c9d44df9 Change-Id: I953f87ddf1b78d7da88d8516744abf6806572d59
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--api/test-current.txt3
-rw-r--r--telephony/java/android/telephony/mbms/DownloadRequest.java30
4 files changed, 21 insertions, 18 deletions
diff --git a/api/current.txt b/api/current.txt
index f1335626e638..ecb6e420bec3 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -40701,11 +40701,10 @@ package android.telephony.mbms {
}
public static class DownloadRequest.Builder {
- ctor public DownloadRequest.Builder();
+ ctor public DownloadRequest.Builder(android.net.Uri);
method public android.telephony.mbms.DownloadRequest build();
method public android.telephony.mbms.DownloadRequest.Builder setAppIntent(android.content.Intent);
method public android.telephony.mbms.DownloadRequest.Builder setServiceInfo(android.telephony.mbms.FileServiceInfo);
- method public android.telephony.mbms.DownloadRequest.Builder setSource(android.net.Uri);
method public android.telephony.mbms.DownloadRequest.Builder setSubscriptionId(int);
}
diff --git a/api/system-current.txt b/api/system-current.txt
index c1b109c652e4..183fb4bfdad7 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -44330,13 +44330,12 @@ package android.telephony.mbms {
}
public static class DownloadRequest.Builder {
- ctor public DownloadRequest.Builder();
+ ctor public DownloadRequest.Builder(android.net.Uri);
method public android.telephony.mbms.DownloadRequest build();
method public android.telephony.mbms.DownloadRequest.Builder setAppIntent(android.content.Intent);
method public android.telephony.mbms.DownloadRequest.Builder setOpaqueData(byte[]);
method public android.telephony.mbms.DownloadRequest.Builder setServiceId(java.lang.String);
method public android.telephony.mbms.DownloadRequest.Builder setServiceInfo(android.telephony.mbms.FileServiceInfo);
- method public android.telephony.mbms.DownloadRequest.Builder setSource(android.net.Uri);
method public android.telephony.mbms.DownloadRequest.Builder setSubscriptionId(int);
}
diff --git a/api/test-current.txt b/api/test-current.txt
index 91b47d5c07b6..fd3729ff1caa 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -41082,11 +41082,10 @@ package android.telephony.mbms {
}
public static class DownloadRequest.Builder {
- ctor public DownloadRequest.Builder();
+ ctor public DownloadRequest.Builder(android.net.Uri);
method public android.telephony.mbms.DownloadRequest build();
method public android.telephony.mbms.DownloadRequest.Builder setAppIntent(android.content.Intent);
method public android.telephony.mbms.DownloadRequest.Builder setServiceInfo(android.telephony.mbms.FileServiceInfo);
- method public android.telephony.mbms.DownloadRequest.Builder setSource(android.net.Uri);
method public android.telephony.mbms.DownloadRequest.Builder setSubscriptionId(int);
}
diff --git a/telephony/java/android/telephony/mbms/DownloadRequest.java b/telephony/java/android/telephony/mbms/DownloadRequest.java
index 5a57f3221d3a..f0d60b68eb94 100644
--- a/telephony/java/android/telephony/mbms/DownloadRequest.java
+++ b/telephony/java/android/telephony/mbms/DownloadRequest.java
@@ -16,6 +16,7 @@
package android.telephony.mbms;
+import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.content.Intent;
import android.net.Uri;
@@ -26,7 +27,6 @@ import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@@ -71,6 +71,19 @@ public final class DownloadRequest implements Parcelable {
private String appIntent;
private int version = CURRENT_VERSION;
+
+ /**
+ * Builds a new DownloadRequest.
+ * @param sourceUri the source URI for the DownloadRequest to be built. This URI should
+ * never be null.
+ */
+ public Builder(@NonNull Uri sourceUri) {
+ if (sourceUri == null) {
+ throw new IllegalArgumentException("Source URI must be non-null.");
+ }
+ source = sourceUri;
+ }
+
/**
* Sets the service from which the download request to be built will download from.
* @param serviceInfo
@@ -92,15 +105,6 @@ public final class DownloadRequest implements Parcelable {
}
/**
- * Sets the source URI for the download request to be built.
- * @param source
- */
- public Builder setSource(Uri source) {
- this.source = source;
- return this;
- }
-
- /**
* Set the subscription ID on which the file(s) should be downloaded.
* @param subscriptionId
*/
@@ -316,9 +320,11 @@ public final class DownloadRequest implements Parcelable {
throw new RuntimeException("Could not get sha256 hash object");
}
if (version >= 1) {
- // Hash the source URI, destination URI, and the app intent
+ // Hash the source URI and the app intent
digest.update(sourceUri.toString().getBytes(StandardCharsets.UTF_8));
- digest.update(serializedResultIntentForApp.getBytes(StandardCharsets.UTF_8));
+ if (serializedResultIntentForApp != null) {
+ digest.update(serializedResultIntentForApp.getBytes(StandardCharsets.UTF_8));
+ }
}
// Add updates for future versions here
return Base64.encodeToString(digest.digest(), Base64.URL_SAFE | Base64.NO_WRAP);