|
65 | 65 |
|
66 | 66 | public abstract class SMSDispatcher extends Handler { |
67 | 67 | private static final String TAG = "SMS"; |
| 68 | + private static final String SEND_NEXT_MSG_EXTRA = "SendNextMsg"; |
68 | 69 |
|
69 | 70 | /** Default checking period for SMS sent without user permit */ |
70 | 71 | private static final int DEFAULT_SMS_CHECK_PERIOD = 3600000; |
@@ -153,6 +154,8 @@ public abstract class SMSDispatcher extends Handler { |
153 | 154 | protected boolean mStorageAvailable = true; |
154 | 155 | protected boolean mReportMemoryStatusPending = false; |
155 | 156 |
|
| 157 | + protected static int mRemainingMessages = -1; |
| 158 | + |
156 | 159 | protected static int getNextConcatenatedRef() { |
157 | 160 | sConcatenatedRef += 1; |
158 | 161 | return sConcatenatedRef; |
@@ -463,7 +466,17 @@ protected void handleSendComplete(AsyncResult ar) { |
463 | 466 |
|
464 | 467 | if (sentIntent != null) { |
465 | 468 | 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 | + } |
467 | 480 | } catch (CanceledException ex) {} |
468 | 481 | } |
469 | 482 | } else { |
@@ -502,8 +515,15 @@ protected void handleSendComplete(AsyncResult ar) { |
502 | 515 | if (ar.result != null) { |
503 | 516 | fillIn.putExtra("errorCode", ((SmsResponse)ar.result).errorCode); |
504 | 517 | } |
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 | + } |
506 | 525 |
|
| 526 | + tracker.mSentIntent.send(mContext, error, fillIn); |
507 | 527 | } catch (CanceledException ex) {} |
508 | 528 | } |
509 | 529 | } |
|
0 commit comments