Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
SMS isn't converted to MMS even after 7 segments of messages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tom Taylor authored and The Android Automerger committed Aug 6, 2012
1 parent 8f14a05 commit ead2759
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
10 changes: 6 additions & 4 deletions res/xml/mms_config.xml
Expand Up @@ -57,15 +57,17 @@
to indicate no limit. -->
<int name="recipientLimit">-1</int>

<!-- Maximum number of SMS message segments in a long text message before converting
the SMS message to an MMS message. -->
<int name="smsToMmsTextThreshold">4</int>

<!-- If true, The text message over 160 characters will be sent in multi part.
If false, The text message over 160 characters will be sent
via multi media message. -->
<bool name="enableMultipartSMS">true</bool>

<!-- If enableMultipartSMS is true and smsToMmsTextThreshold > 1, then multi-part SMS messages
will be converted into a single mms message. For example, if the mms_config.xml file
specifies <int name="smsToMmsTextThreshold">7</int>, then on the 8th sms segment, the
message will be converted to an mms. -->
<int name="smsToMmsTextThreshold">-1</int>

<!-- If true, The mms support slide duration.
If false, The mms does not support slide duration and we have to
set duration value. -->
Expand Down
12 changes: 12 additions & 0 deletions src/com/android/mms/MmsConfig.java
Expand Up @@ -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 <int name="smsToMmsTextThreshold">4</int>, 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"
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down
35 changes: 16 additions & 19 deletions src/com/android/mms/data/WorkingMessage.java
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/com/android/mms/ui/ComposeMessageActivity.java
Expand Up @@ -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:
Expand Down

0 comments on commit ead2759

Please sign in to comment.