Move failed message to failed state
When we try and send a message and the telephony layer throws an
exception, move that message to the failed state. Otherwise, it
perpetually remains in the outbox and shows as "Sending..." to the
user.
Change-Id: Iaa2a4ed05f67828e8f980228e01a5a34e4fc069e
diff --git a/src/com/android/mms/transaction/SmsReceiverService.java b/src/com/android/mms/transaction/SmsReceiverService.java
index a6f1d1e..edbbb1d 100644
--- a/src/com/android/mms/transaction/SmsReceiverService.java
+++ b/src/com/android/mms/transaction/SmsReceiverService.java
@@ -234,6 +234,9 @@
} catch (MmsException e) {
Log.e(TAG, "sendFirstQueuedMessage: failed to send message " + msgUri
+ ", caught ", e);
+
+ mSending = false;
+ messageFailedToSend(msgUri, SmsManager.RESULT_ERROR_GENERIC_FAILURE);
success = false;
}
}
@@ -284,17 +287,21 @@
}
});
} else {
- if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
- Log.v(TAG, "handleSmsSent msg failed uri: " + uri);
- }
- Sms.moveMessageToFolder(this, uri, Sms.MESSAGE_TYPE_FAILED, error);
- MessagingNotification.notifySendFailed(getApplicationContext(), true);
+ messageFailedToSend(uri, error);
if (sendNextMsg) {
sendFirstQueuedMessage();
}
}
}
+ private void messageFailedToSend(Uri uri, int error) {
+ if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
+ Log.v(TAG, "messageFailedToSend msg failed uri: " + uri);
+ }
+ Sms.moveMessageToFolder(this, uri, Sms.MESSAGE_TYPE_FAILED, error);
+ MessagingNotification.notifySendFailed(getApplicationContext(), true);
+ }
+
private void handleSmsReceived(Intent intent, int error) {
SmsMessage[] msgs = Intents.getMessagesFromIntent(intent);
Uri messageUri = insertMessage(this, msgs, error);