Merge "Fix SMS status handling" am: 4e3db63e41 am: 8f649c7078
am: 91e9df451b
Change-Id: Ifa13bd79605bd60bdfe2a72dc377b5d432b53ebb
This commit is contained in:
@@ -202,11 +202,11 @@ class SyncMessageBatch {
|
|||||||
// For a message we sync either
|
// For a message we sync either
|
||||||
if (isOutgoing) {
|
if (isOutgoing) {
|
||||||
// Outgoing message not yet been sent
|
// Outgoing message not yet been sent
|
||||||
if (type == Telephony.Sms.MESSAGE_TYPE_FAILED ||
|
if (type == Telephony.Sms.MESSAGE_TYPE_FAILED
|
||||||
type == Telephony.Sms.MESSAGE_TYPE_OUTBOX ||
|
|| type == Telephony.Sms.MESSAGE_TYPE_OUTBOX
|
||||||
type == Telephony.Sms.MESSAGE_TYPE_QUEUED ||
|
|| type == Telephony.Sms.MESSAGE_TYPE_QUEUED
|
||||||
(type == Telephony.Sms.MESSAGE_TYPE_SENT &&
|
|| (type == Telephony.Sms.MESSAGE_TYPE_SENT
|
||||||
status == Telephony.Sms.STATUS_FAILED)) {
|
&& status >= Telephony.Sms.STATUS_FAILED)) {
|
||||||
// Not sent counts as failed and available for manual resend
|
// Not sent counts as failed and available for manual resend
|
||||||
bugleStatus = MessageData.BUGLE_STATUS_OUTGOING_FAILED;
|
bugleStatus = MessageData.BUGLE_STATUS_OUTGOING_FAILED;
|
||||||
} else if (status == Sms.STATUS_COMPLETE) {
|
} else if (status == Sms.STATUS_COMPLETE) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.provider.Telephony.Sms;
|
||||||
import android.telephony.SmsMessage;
|
import android.telephony.SmsMessage;
|
||||||
|
|
||||||
import com.android.messaging.datamodel.action.ProcessDeliveryReportAction;
|
import com.android.messaging.datamodel.action.ProcessDeliveryReportAction;
|
||||||
@@ -81,9 +82,32 @@ public class SendStatusReceiver extends BroadcastReceiver {
|
|||||||
LogUtil.e(LogUtil.BUGLE_TAG, "SendStatusReceiver: empty report message");
|
LogUtil.e(LogUtil.BUGLE_TAG, "SendStatusReceiver: empty report message");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int status = 0;
|
int status = Sms.STATUS_COMPLETE;
|
||||||
try {
|
try {
|
||||||
|
final String format = intent.getStringExtra("format");
|
||||||
status = smsMessage.getStatus();
|
status = smsMessage.getStatus();
|
||||||
|
// Simple matching up CDMA status with GSM status.
|
||||||
|
if (SmsMessage.FORMAT_3GPP2.equals(format)) {
|
||||||
|
final int errorClass = (status >> 24) & 0x03;
|
||||||
|
final int statusCode = (status >> 16) & 0x3f;
|
||||||
|
switch (errorClass) {
|
||||||
|
case 0: /*ERROR_NONE*/
|
||||||
|
if (statusCode == 0x02 /*STATUS_DELIVERED*/) {
|
||||||
|
status = Sms.STATUS_COMPLETE;
|
||||||
|
} else status = Sms.STATUS_PENDING;
|
||||||
|
break;
|
||||||
|
case 2: /*ERROR_TEMPORARY*/
|
||||||
|
// TODO: Need to check whether SC still trying to deliver the SMS to
|
||||||
|
// destination and will send the report again?
|
||||||
|
status = Sms.STATUS_PENDING;
|
||||||
|
break;
|
||||||
|
case 3: /*ERROR_PERMANENT*/
|
||||||
|
status = Sms.STATUS_FAILED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
status = Sms.STATUS_PENDING;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (final NullPointerException e) {
|
} catch (final NullPointerException e) {
|
||||||
// Sometimes, SmsMessage.mWrappedSmsMessage is null causing NPE when we access
|
// Sometimes, SmsMessage.mWrappedSmsMessage is null causing NPE when we access
|
||||||
// the methods on it although the SmsMessage itself is not null.
|
// the methods on it although the SmsMessage itself is not null.
|
||||||
|
|||||||
Reference in New Issue
Block a user