Skip to content

Commit 4ddd990

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Fix the Multi-page SMS sending error to several receipents" into gingerbread
2 parents 2703b84 + b9ef00e commit 4ddd990

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

telephony/java/com/android/internal/telephony/SMSDispatcher.java

100644100755
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
public abstract class SMSDispatcher extends Handler {
6767
private static final String TAG = "SMS";
68+
private static final String SEND_NEXT_MSG_EXTRA = "SendNextMsg";
6869

6970
/** Default checking period for SMS sent without user permit */
7071
private static final int DEFAULT_SMS_CHECK_PERIOD = 3600000;
@@ -153,6 +154,8 @@ public abstract class SMSDispatcher extends Handler {
153154
protected boolean mStorageAvailable = true;
154155
protected boolean mReportMemoryStatusPending = false;
155156

157+
protected static int mRemainingMessages = -1;
158+
156159
protected static int getNextConcatenatedRef() {
157160
sConcatenatedRef += 1;
158161
return sConcatenatedRef;
@@ -463,7 +466,17 @@ protected void handleSendComplete(AsyncResult ar) {
463466

464467
if (sentIntent != null) {
465468
try {
466-
sentIntent.send(Activity.RESULT_OK);
469+
if (mRemainingMessages > -1) {
470+
mRemainingMessages--;
471+
}
472+
473+
if (mRemainingMessages == 0) {
474+
Intent sendNext = new Intent();
475+
sendNext.putExtra(SEND_NEXT_MSG_EXTRA, true);
476+
sentIntent.send(mContext, Activity.RESULT_OK, sendNext);
477+
} else {
478+
sentIntent.send(Activity.RESULT_OK);
479+
}
467480
} catch (CanceledException ex) {}
468481
}
469482
} else {
@@ -502,8 +515,15 @@ protected void handleSendComplete(AsyncResult ar) {
502515
if (ar.result != null) {
503516
fillIn.putExtra("errorCode", ((SmsResponse)ar.result).errorCode);
504517
}
505-
tracker.mSentIntent.send(mContext, error, fillIn);
518+
if (mRemainingMessages > -1) {
519+
mRemainingMessages--;
520+
}
521+
522+
if (mRemainingMessages == 0) {
523+
fillIn.putExtra(SEND_NEXT_MSG_EXTRA, true);
524+
}
506525

526+
tracker.mSentIntent.send(mContext, error, fillIn);
507527
} catch (CanceledException ex) {}
508528
}
509529
}

telephony/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ protected void sendMultipartText(String destinationAddress, String scAddress,
180180
int msgCount = parts.size();
181181
int encoding = android.telephony.SmsMessage.ENCODING_UNKNOWN;
182182

183+
mRemainingMessages = msgCount;
184+
183185
for (int i = 0; i < msgCount; i++) {
184186
TextEncodingDetails details = SmsMessage.calculateLength(parts.get(i), false);
185187
if (encoding != details.codeUnitSize
@@ -269,6 +271,8 @@ private void sendMultipartTextWithPermit(String destinationAddress,
269271
int msgCount = parts.size();
270272
int encoding = android.telephony.SmsMessage.ENCODING_UNKNOWN;
271273

274+
mRemainingMessages = msgCount;
275+
272276
for (int i = 0; i < msgCount; i++) {
273277
TextEncodingDetails details = SmsMessage.calculateLength(parts.get(i), false);
274278
if (encoding != details.codeUnitSize

0 commit comments

Comments
 (0)