From ead27598737791a1ce1f1171c1ff9e99b380438f Mon Sep 17 00:00:00 2001 From: Tom Taylor Date: Wed, 1 Aug 2012 16:51:18 -0700 Subject: [PATCH] SMS isn't converted to MMS even after 7 segments of messages Bug 6903793 Resurrect the mms_config.xml setting "smsToMmsTextThreshold" to allow overlays to specify an sms->mms conversion after a certain number of sms segments have been created. Tested on mysid, yakju, and sojus. All three have different settings for this feature. Also tested bug fixed by https://googleplex-android-review.googlesource.com/#/c/103729/. Change-Id: Ibcfd235edbaa264fede6e48f84f04345d16368fa --- res/xml/mms_config.xml | 10 +++--- src/com/android/mms/MmsConfig.java | 12 +++++++ src/com/android/mms/data/WorkingMessage.java | 35 +++++++++---------- .../mms/ui/ComposeMessageActivity.java | 3 ++ 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/res/xml/mms_config.xml b/res/xml/mms_config.xml index 988458b87..78567e263 100644 --- a/res/xml/mms_config.xml +++ b/res/xml/mms_config.xml @@ -57,15 +57,17 @@ to indicate no limit. --> -1 - - 4 - true + + -1 + diff --git a/src/com/android/mms/MmsConfig.java b/src/com/android/mms/MmsConfig.java index ee4392b6a..faab63048 100755 --- a/src/com/android/mms/MmsConfig.java +++ b/src/com/android/mms/MmsConfig.java @@ -70,6 +70,12 @@ public class MmsConfig { // as an mms message. This feature exists for carriers that don't support multi-part sms's. private static boolean mEnableMultipartSMS = true; + // If mEnableMultipartSMS is true and mSmsToMmsTextThreshold > 1, then multi-part SMS messages + // will be converted into a single mms message. For example, if the mms_config.xml file + // specifies 4, then on the 5th sms segment, the + // message will be converted to an mms. + private static int mSmsToMmsTextThreshold = -1; + private static boolean mEnableSlideDuration = true; private static boolean mEnableMMSReadReports = true; // key: "enableMMSReadReports" private static boolean mEnableSMSDeliveryReports = true; // key: "enableSMSDeliveryReports" @@ -100,6 +106,10 @@ public static void init(Context context) { loadMmsSettings(context); } + public static int getSmsToMmsTextThreshold() { + return mSmsToMmsTextThreshold; + } + public static boolean getMmsEnabled() { return mMmsEnabled == 1 ? true : false; } @@ -337,6 +347,8 @@ private static void loadMmsSettings(Context context) { mAliasRuleMinChars = Integer.parseInt(text); } else if ("aliasMaxChars".equalsIgnoreCase(value)) { mAliasRuleMaxChars = Integer.parseInt(text); + } else if ("smsToMmsTextThreshold".equalsIgnoreCase(value)) { + mSmsToMmsTextThreshold = Integer.parseInt(text); } else if ("maxMessageTextSize".equalsIgnoreCase(value)) { mMaxTextLength = Integer.parseInt(text); } else if ("maxSubjectLength".equalsIgnoreCase(value)) { diff --git a/src/com/android/mms/data/WorkingMessage.java b/src/com/android/mms/data/WorkingMessage.java index d6bd3b101..14dd7b4c2 100755 --- a/src/com/android/mms/data/WorkingMessage.java +++ b/src/com/android/mms/data/WorkingMessage.java @@ -469,26 +469,23 @@ public int setAttachment(int type, Uri dataUri, boolean append) { mStatusListener.onAttachmentChanged(); // have to call whether succeeded or failed, // because a replace that fails, removes the slide - if (!MmsConfig.getMultipartSmsEnabled()) { - if (!append && mAttachmentType == TEXT && type == TEXT) { - int[] params = SmsMessage.calculateLength(getText(), false); - /* SmsMessage.calculateLength returns an int[4] with: - * int[0] being the number of SMS's required, - * int[1] the number of code units used, - * int[2] is the number of code units remaining until the next message. - * int[3] is the encoding type that should be used for the message. - */ - int msgCount = params[0]; - - if (msgCount > 1) { - // The provider doesn't support multi-part sms's so as soon as the user types - // an sms longer than one segment, we have to turn the message into an mms. - setLengthRequiresMms(true, false); - } else { - updateState(HAS_ATTACHMENT, hasAttachment(), true); - } + if (!append && mAttachmentType == TEXT && type == TEXT) { + int[] params = SmsMessage.calculateLength(getText(), false); + /* SmsMessage.calculateLength returns an int[4] with: + * int[0] being the number of SMS's required, + * int[1] the number of code units used, + * int[2] is the number of code units remaining until the next message. + * int[3] is the encoding type that should be used for the message. + */ + int smsSegmentCount = params[0]; + + if (!MmsConfig.getMultipartSmsEnabled()) { + // The provider doesn't support multi-part sms's so as soon as the user types + // an sms longer than one segment, we have to turn the message into an mms. + setLengthRequiresMms(smsSegmentCount > 1, false); } else { - updateState(HAS_ATTACHMENT, hasAttachment(), true); + int threshold = MmsConfig.getSmsToMmsTextThreshold(); + setLengthRequiresMms(threshold > 0 && smsSegmentCount > threshold, false); } } else { // Set HAS_ATTACHMENT if we need it. diff --git a/src/com/android/mms/ui/ComposeMessageActivity.java b/src/com/android/mms/ui/ComposeMessageActivity.java index 2ba2ef28b..638c7bce1 100644 --- a/src/com/android/mms/ui/ComposeMessageActivity.java +++ b/src/com/android/mms/ui/ComposeMessageActivity.java @@ -552,6 +552,9 @@ private void updateCounter(CharSequence text, int start, int before, int count) // The provider doesn't support multi-part sms's so as soon as the user types // an sms longer than one segment, we have to turn the message into an mms. mWorkingMessage.setLengthRequiresMms(msgCount > 1, true); + } else { + int threshold = MmsConfig.getSmsToMmsTextThreshold(); + mWorkingMessage.setLengthRequiresMms(threshold > 0 && msgCount > threshold, true); } // Show the counter only if: