diff --git a/core/api/current.txt b/core/api/current.txt index 78b4f80cd791b..0eb3b49ac8b1c 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -42162,6 +42162,7 @@ package android.telephony { method @NonNull public android.telephony.SmsManager createForSubscriptionId(int); method public java.util.ArrayList divideMessage(String); method public void downloadMultimediaMessage(android.content.Context, String, android.net.Uri, android.os.Bundle, android.app.PendingIntent); + method public void downloadMultimediaMessage(@NonNull android.content.Context, @NonNull String, @NonNull android.net.Uri, @Nullable android.os.Bundle, @Nullable android.app.PendingIntent, long); method @NonNull public android.os.Bundle getCarrierConfigValues(); method @Deprecated public static android.telephony.SmsManager getDefault(); method public static int getDefaultSmsSubscriptionId(); @@ -42173,6 +42174,7 @@ package android.telephony { method public void injectSmsPdu(byte[], String, android.app.PendingIntent); method public void sendDataMessage(String, String, short, byte[], android.app.PendingIntent, android.app.PendingIntent); method public void sendMultimediaMessage(android.content.Context, android.net.Uri, String, android.os.Bundle, android.app.PendingIntent); + method public void sendMultimediaMessage(@NonNull android.content.Context, @NonNull android.net.Uri, @Nullable String, @Nullable android.os.Bundle, @Nullable android.app.PendingIntent, long); method public void sendMultipartTextMessage(String, String, java.util.ArrayList, java.util.ArrayList, java.util.ArrayList); method public void sendMultipartTextMessage(@NonNull String, @Nullable String, @NonNull java.util.List, @Nullable java.util.List, @Nullable java.util.List, long); method public void sendMultipartTextMessage(@NonNull String, @Nullable String, @NonNull java.util.List, @Nullable java.util.List, @Nullable java.util.List, @NonNull String, @Nullable String); diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index 6c013df668408..4926687f67240 100644 --- a/telephony/java/android/telephony/SmsManager.java +++ b/telephony/java/android/telephony/SmsManager.java @@ -2649,6 +2649,37 @@ public final class SmsManager { */ public void sendMultimediaMessage(Context context, Uri contentUri, String locationUrl, Bundle configOverrides, PendingIntent sentIntent) { + sendMultimediaMessage(context, contentUri, locationUrl, configOverrides, sentIntent, + 0L /* messageId */); + } + + /** + * Send an MMS message + * + * Same as {@link #sendMultimediaMessage(Context context, Uri contentUri, String locationUrl, + * Bundle configOverrides, PendingIntent sentIntent)}, but adds an optional messageId. + *

Note: If {@link #getDefault()} is used to instantiate this + * manager on a multi-SIM device, this operation may fail sending the MMS message because no + * suitable default subscription could be found. In this case, if {@code sentIntent} is + * non-null, then the {@link PendingIntent} will be sent with an error code + * {@code RESULT_NO_DEFAULT_SMS_APP}. See {@link #getDefault()} for more information on the + * conditions where this operation may fail. + *

+ * + * @param context application context + * @param contentUri the content Uri from which the message pdu will be read + * @param locationUrl the optional location url where message should be sent to + * @param configOverrides the carrier-specific messaging configuration values to override for + * sending the message. + * @param sentIntent if not NULL this PendingIntent is + * broadcast when the message is successfully sent, or failed + * @param messageId an id that uniquely identifies the message requested to be sent. + * Used for logging and diagnostics purposes. The id may be 0. + * @throws IllegalArgumentException if contentUri is empty + */ + public void sendMultimediaMessage(@NonNull Context context, @NonNull Uri contentUri, + @Nullable String locationUrl, @Nullable Bundle configOverrides, + @Nullable PendingIntent sentIntent, long messageId) { if (contentUri == null) { throw new IllegalArgumentException("Uri contentUri null"); } @@ -2658,7 +2689,7 @@ public final class SmsManager { @Override public void onSuccess(int subId) { m.sendMultimediaMessage(subId, contentUri, locationUrl, configOverrides, - sentIntent, 0L /* messageId */); + sentIntent, messageId); } @Override @@ -2692,6 +2723,39 @@ public final class SmsManager { */ public void downloadMultimediaMessage(Context context, String locationUrl, Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent) { + downloadMultimediaMessage(context, locationUrl, contentUri, configOverrides, + downloadedIntent, 0L /* messageId */); + } + + /** + * Download an MMS message from carrier by a given location URL + * + * Same as {@link #downloadMultimediaMessage(Context context, String locationUrl, + * Uri contentUri, Bundle configOverrides, PendingIntent downloadedIntent)}, + * but adds an optional messageId. + *

Note: If {@link #getDefault()} is used to instantiate this + * manager on a multi-SIM device, this operation may fail downloading the MMS message because no + * suitable default subscription could be found. In this case, if {@code downloadedIntent} is + * non-null, then the {@link PendingIntent} will be sent with an error code + * {@code RESULT_NO_DEFAULT_SMS_APP}. See {@link #getDefault()} for more information on the + * conditions where this operation may fail. + *

+ * + * @param context application context + * @param locationUrl the location URL of the MMS message to be downloaded, usually obtained + * from the MMS WAP push notification + * @param contentUri the content uri to which the downloaded pdu will be written + * @param configOverrides the carrier-specific messaging configuration values to override for + * downloading the message. + * @param downloadedIntent if not NULL this PendingIntent is + * broadcast when the message is downloaded, or the download is failed + * @param messageId an id that uniquely identifies the message requested to be downloaded. + * Used for logging and diagnostics purposes. The id may be 0. + * @throws IllegalArgumentException if locationUrl or contentUri is empty + */ + public void downloadMultimediaMessage(@NonNull Context context, @NonNull String locationUrl, + @NonNull Uri contentUri, @Nullable Bundle configOverrides, + @Nullable PendingIntent downloadedIntent, long messageId) { if (TextUtils.isEmpty(locationUrl)) { throw new IllegalArgumentException("Empty MMS location URL"); } @@ -2704,7 +2768,7 @@ public final class SmsManager { @Override public void onSuccess(int subId) { m.downloadMultimediaMessage(subId, locationUrl, contentUri, configOverrides, - downloadedIntent, 0L /* messageId */); + downloadedIntent, messageId); } @Override