Mark messages as failed if SIM is inactive
If a SIM is inactive, Mark messages corresponding to the SIM as failed instead of updating selfId as default selfId. The failed messages could be sent through the SIM manually if the SIM is re-activated. Test: Manual Change-Id: I1eee7c12aaedebe8aa3e0c41b4b057758a3b17a2 Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
This commit is contained in:
@@ -335,7 +335,7 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
|
||||
selfId}
|
||||
);
|
||||
|
||||
// Look for messages we cound send
|
||||
// Look for messages we could send
|
||||
cursor = db.query(DatabaseHelper.MESSAGES_TABLE,
|
||||
MessageData.getProjection(),
|
||||
DatabaseHelper.MessageColumns.STATUS + " IN (?, ?) AND "
|
||||
@@ -354,43 +354,34 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
|
||||
values.put(DatabaseHelper.MessageColumns.STATUS,
|
||||
MessageData.BUGLE_STATUS_OUTGOING_FAILED);
|
||||
|
||||
// Prior to L_MR1, isActiveSubscription is true always
|
||||
boolean isActiveSubscription = true;
|
||||
if (OsUtil.isAtLeastL_MR1()) {
|
||||
final ParticipantData messageSelf =
|
||||
BugleDatabaseOperations.getExistingParticipant(db, selfId);
|
||||
if (messageSelf == null || !messageSelf.isActiveSubscription()) {
|
||||
isActiveSubscription = false;
|
||||
}
|
||||
}
|
||||
while (cursor.moveToNext()) {
|
||||
final MessageData message = new MessageData();
|
||||
message.bind(cursor);
|
||||
if (message.getInResendWindow(now)) {
|
||||
// If no messages currently sending
|
||||
if (sendingCnt == 0) {
|
||||
// Resend this message
|
||||
toSendMessageId = message.getMessageId();
|
||||
// Before queuing the message for resending, check if the message's self is
|
||||
// active. If not, switch back to the system's default subscription.
|
||||
if (OsUtil.isAtLeastL_MR1()) {
|
||||
final ParticipantData messageSelf = BugleDatabaseOperations
|
||||
.getExistingParticipant(db, selfId);
|
||||
if (messageSelf == null || !messageSelf.isActiveSubscription()) {
|
||||
final ParticipantData defaultSelf = BugleDatabaseOperations
|
||||
.getOrCreateSelf(db, PhoneUtils.getDefault()
|
||||
.getDefaultSmsSubscriptionId());
|
||||
if (defaultSelf != null) {
|
||||
message.bindSelfId(defaultSelf.getId());
|
||||
final ContentValues selfValues = new ContentValues();
|
||||
selfValues.put(MessageColumns.SELF_PARTICIPANT_ID,
|
||||
defaultSelf.getId());
|
||||
BugleDatabaseOperations.updateMessageRow(db,
|
||||
message.getMessageId(), selfValues);
|
||||
MessagingContentProvider.notifyMessagesChanged(
|
||||
message.getConversationId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
|
||||
// Mark this message as failed if the message's self is inactive or the message is
|
||||
// outside of resend window
|
||||
if (!isActiveSubscription || !message.getInResendWindow(now)) {
|
||||
failedCnt++;
|
||||
|
||||
// Mark message as failed
|
||||
BugleDatabaseOperations.updateMessageRow(db, message.getMessageId(), values);
|
||||
MessagingContentProvider.notifyMessagesChanged(message.getConversationId());
|
||||
} else {
|
||||
// If no messages currently sending
|
||||
if (sendingCnt == 0) {
|
||||
// Send this message
|
||||
toSendMessageId = message.getMessageId();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
|
||||
Reference in New Issue
Block a user