diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2019-06-12 00:18:44 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-06-12 00:18:44 +0000 |
commit | 4e3db63e4114fa8c9ca6338a6e39f1ff2a2069c6 (patch) | |
tree | 9cfbf2a53b032f05c547fa342f1f9abc46f62e05 | |
parent | aa5bde8dbe206dfbc06800460b7e48f071bc9504 (diff) | |
parent | 4b1c6eb2c96c3b71c1a24a4e2814086b890f87b3 (diff) | |
download | Messaging-4e3db63e4114fa8c9ca6338a6e39f1ff2a2069c6.tar.gz |
Merge "Fix SMS status handling"
-rw-r--r-- | src/com/android/messaging/datamodel/action/SyncMessageBatch.java | 10 | ||||
-rw-r--r-- | src/com/android/messaging/receiver/SendStatusReceiver.java | 26 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/com/android/messaging/datamodel/action/SyncMessageBatch.java b/src/com/android/messaging/datamodel/action/SyncMessageBatch.java index 972d691..a623666 100644 --- a/src/com/android/messaging/datamodel/action/SyncMessageBatch.java +++ b/src/com/android/messaging/datamodel/action/SyncMessageBatch.java @@ -202,11 +202,11 @@ class SyncMessageBatch { // For a message we sync either if (isOutgoing) { // Outgoing message not yet been sent - if (type == Telephony.Sms.MESSAGE_TYPE_FAILED || - type == Telephony.Sms.MESSAGE_TYPE_OUTBOX || - type == Telephony.Sms.MESSAGE_TYPE_QUEUED || - (type == Telephony.Sms.MESSAGE_TYPE_SENT && - status == Telephony.Sms.STATUS_FAILED)) { + if (type == Telephony.Sms.MESSAGE_TYPE_FAILED + || type == Telephony.Sms.MESSAGE_TYPE_OUTBOX + || type == Telephony.Sms.MESSAGE_TYPE_QUEUED + || (type == Telephony.Sms.MESSAGE_TYPE_SENT + && status >= Telephony.Sms.STATUS_FAILED)) { // Not sent counts as failed and available for manual resend bugleStatus = MessageData.BUGLE_STATUS_OUTGOING_FAILED; } else if (status == Sms.STATUS_COMPLETE) { diff --git a/src/com/android/messaging/receiver/SendStatusReceiver.java b/src/com/android/messaging/receiver/SendStatusReceiver.java index fc0e8c9..3af65f2 100644 --- a/src/com/android/messaging/receiver/SendStatusReceiver.java +++ b/src/com/android/messaging/receiver/SendStatusReceiver.java @@ -20,6 +20,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.provider.Telephony.Sms; import android.telephony.SmsMessage; 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"); return; } - int status = 0; + int status = Sms.STATUS_COMPLETE; try { + final String format = intent.getStringExtra("format"); 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) { // Sometimes, SmsMessage.mWrappedSmsMessage is null causing NPE when we access // the methods on it although the SmsMessage itself is not null. |