Mark messages as failed if SIM is inactive am: 8c08a3f419 am: 947784d4f3 am: 5b6d2cb110
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Messaging/+/1449316 Change-Id: I07d62d0098cf3c1e22f3b8f8c0f5dd9d3cc400e3
This commit is contained in:
@@ -335,7 +335,7 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
|
|||||||
selfId}
|
selfId}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Look for messages we cound send
|
// Look for messages we could send
|
||||||
cursor = db.query(DatabaseHelper.MESSAGES_TABLE,
|
cursor = db.query(DatabaseHelper.MESSAGES_TABLE,
|
||||||
MessageData.getProjection(),
|
MessageData.getProjection(),
|
||||||
DatabaseHelper.MessageColumns.STATUS + " IN (?, ?) AND "
|
DatabaseHelper.MessageColumns.STATUS + " IN (?, ?) AND "
|
||||||
@@ -354,43 +354,34 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
|
|||||||
values.put(DatabaseHelper.MessageColumns.STATUS,
|
values.put(DatabaseHelper.MessageColumns.STATUS,
|
||||||
MessageData.BUGLE_STATUS_OUTGOING_FAILED);
|
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()) {
|
while (cursor.moveToNext()) {
|
||||||
final MessageData message = new MessageData();
|
final MessageData message = new MessageData();
|
||||||
message.bind(cursor);
|
message.bind(cursor);
|
||||||
if (message.getInResendWindow(now)) {
|
|
||||||
// If no messages currently sending
|
// Mark this message as failed if the message's self is inactive or the message is
|
||||||
if (sendingCnt == 0) {
|
// outside of resend window
|
||||||
// Resend this message
|
if (!isActiveSubscription || !message.getInResendWindow(now)) {
|
||||||
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 {
|
|
||||||
failedCnt++;
|
failedCnt++;
|
||||||
|
|
||||||
// Mark message as failed
|
// Mark message as failed
|
||||||
BugleDatabaseOperations.updateMessageRow(db, message.getMessageId(), values);
|
BugleDatabaseOperations.updateMessageRow(db, message.getMessageId(), values);
|
||||||
MessagingContentProvider.notifyMessagesChanged(message.getConversationId());
|
MessagingContentProvider.notifyMessagesChanged(message.getConversationId());
|
||||||
|
} else {
|
||||||
|
// If no messages currently sending
|
||||||
|
if (sendingCnt == 0) {
|
||||||
|
// Send this message
|
||||||
|
toSendMessageId = message.getMessageId();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
|
|||||||
Reference in New Issue
Block a user