From 353bed11558dcd3ad55f89f2bd4139054fa0f63f Mon Sep 17 00:00:00 2001 From: Mengjun Leng Date: Mon, 30 Jul 2018 15:28:31 +0800 Subject: [PATCH] Pass correct parameters to API sendMultipartTextMessage 1. Pass parameter priority, expectMore and validityPeriod to API sendMultipartTextMessage. 2. Modify validity check algrithm for parameter priority and validityPeriod, so that avoids the exception for invalid inputs. Bug: 112013111 Change-Id: I7a90db6e427b3daf6589e6a2b6dad2c4b3458832 --- .../java/android/telephony/SmsManager.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index 7506f4a85fd57..149a99d251004 100644 --- a/telephony/java/android/telephony/SmsManager.java +++ b/telephony/java/android/telephony/SmsManager.java @@ -271,6 +271,17 @@ public final class SmsManager { private static String DIALOG_TYPE_KEY = "dialog_type"; private static final int SMS_PICK = 2; + /** + * 3gpp2 SMS priority is not specified + * @hide + */ + public static final int SMS_MESSAGE_PRIORITY_NOT_SPECIFIED = -1; + /** + * 3gpp SMS period is not specified + * @hide + */ + public static final int SMS_MESSAGE_PERIOD_NOT_SPECIFIED = -1; + /** * Send a text based SMS. * @@ -457,11 +468,11 @@ public final class SmsManager { } if (priority < 0x00 || priority > 0x03) { - throw new IllegalArgumentException("Invalid priority"); + priority = SMS_MESSAGE_PRIORITY_NOT_SPECIFIED; } if (validityPeriod < 0x05 || validityPeriod > 0x09b0a0) { - throw new IllegalArgumentException("Invalid validity period"); + validityPeriod = SMS_MESSAGE_PERIOD_NOT_SPECIFIED; } try { @@ -716,7 +727,8 @@ public final class SmsManager { ArrayList sentIntents, ArrayList deliveryIntents, int priority, boolean expectMore, int validityPeriod) { sendMultipartTextMessageInternal(destinationAddress, scAddress, parts, sentIntents, - deliveryIntents, true /* persistMessage*/); + deliveryIntents, true /* persistMessage*/, priority, expectMore, + validityPeriod); } private void sendMultipartTextMessageInternal( @@ -731,11 +743,11 @@ public final class SmsManager { } if (priority < 0x00 || priority > 0x03) { - throw new IllegalArgumentException("Invalid priority"); + priority = SMS_MESSAGE_PRIORITY_NOT_SPECIFIED; } if (validityPeriod < 0x05 || validityPeriod > 0x09b0a0) { - throw new IllegalArgumentException("Invalid validity period"); + validityPeriod = SMS_MESSAGE_PERIOD_NOT_SPECIFIED; } if (parts.size() > 1) {