Rescheduling pending messages after outside window failure am: 0ff700cea4 am: 3bf899c587 am: 1e144034d1

Change-Id: I573a2677ae98dbab953bb5bef67b99d95610ff41
This commit is contained in:
Taesu Lee
2020-05-19 01:08:32 +00:00
committed by Automerger Merge Worker
5 changed files with 24 additions and 14 deletions

View File

@@ -83,7 +83,7 @@ public class ProcessDownloadedMmsAction extends Action {
// Set when message downloaded by us (legacy)
private static final String KEY_STATUS = "status";
private static final String KEY_RAW_STATUS = "raw_status";
private static final String KEY_MMS_URI = "mms_uri";
private static final String KEY_MMS_URI = "mms_uri";
// Used to send a deferred response in response to auto-download failure
private static final String KEY_SEND_DEFERRED_RESP_STATUS = "send_deferred_resp_status";
@@ -329,6 +329,8 @@ public class ProcessDownloadedMmsAction extends Action {
if (response == null) {
// No message download to process; doBackgroundWork sent a notify deferred response
Assert.isTrue(actionParameters.getBoolean(KEY_SEND_DEFERRED_RESP_STATUS));
ProcessPendingMessagesAction.scheduleProcessPendingMessagesAction(
true /* failed */, this);
return null;
}
@@ -343,7 +345,9 @@ public class ProcessDownloadedMmsAction extends Action {
final int subId = actionParameters.getInt(KEY_SUB_ID, ParticipantData.DEFAULT_SELF_SUB_ID);
// If we were trying to auto-download but have failed need to send the deferred response
if (autoDownload && message == null && status == MmsUtils.MMS_REQUEST_MANUAL_RETRY) {
final boolean needToSendDeferredResp =
autoDownload && (status == MmsUtils.MMS_REQUEST_MANUAL_RETRY);
if (needToSendDeferredResp) {
final String transactionId = actionParameters.getString(KEY_TRANSACTION_ID);
final String contentLocation = actionParameters.getString(KEY_CONTENT_LOCATION);
sendDeferredRespStatus(messageId, transactionId, contentLocation, subId);
@@ -373,7 +377,11 @@ public class ProcessDownloadedMmsAction extends Action {
}
final boolean failed = (messageUri == null);
ProcessPendingMessagesAction.scheduleProcessPendingMessagesAction(failed, this);
// Scheduling pending messages. If auto downloading is failed and it needs to send the
// deferred response, Skip it here and it will be scheduled after sending the response.
if (!needToSendDeferredResp) {
ProcessPendingMessagesAction.scheduleProcessPendingMessagesAction(failed, this);
}
if (failed) {
BugleNotifications.update(false, BugleNotifications.UPDATE_ERRORS);
}

View File

@@ -301,12 +301,16 @@ public class ProcessPendingMessagesAction extends Action implements Parcelable {
unregister(subId);
if (PhoneUtils.getDefault().isDefaultSmsApp()) {
queueActions(this);
if (!queueActions(this)) {
LogUtil.v(TAG, "ProcessPendingMessagesAction: rescheduling");
// TODO: Need to clear retry count here?
scheduleProcessPendingMessagesAction(true /* failed */, this);
}
} else {
if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
LogUtil.v(TAG, "ProcessPendingMessagesAction: Not default SMS app; rescheduling");
}
scheduleProcessPendingMessagesAction(true, this);
scheduleProcessPendingMessagesAction(true /* failed */, this);
}
return null;

View File

@@ -207,6 +207,8 @@ public class ProcessSentMessageAction extends Action {
if (message == null) {
LogUtil.w(TAG, "ProcessSentMessageAction: Sent message " + messageId
+ " missing from local database");
ProcessPendingMessagesAction.scheduleProcessPendingMessagesAction(
true /* failed */, processingAction);
return;
}
final String conversationId = message.getConversationId();

View File

@@ -44,7 +44,6 @@ import java.util.ArrayList;
* Action used to send an outgoing message. It writes MMS messages to the telephony db
* ({@link InsertNewMessageAction}) writes SMS messages to the telephony db). It also
* initiates the actual sending. It will all be used for re-sending a failed message.
* NOTE: This action must queue a ProcessPendingMessagesAction when it is done (success or failure).
* <p>
* This class is public (not package-private) because the SMS/MMS (e.g. MmsUtils) classes need to
* access the EXTRA_* fields for setting up the 'sent' pending intent.
@@ -294,9 +293,6 @@ public class SendMessageAction extends Action implements Parcelable {
MmsUtils.MMS_REQUEST_MANUAL_RETRY, MessageData.RAW_TELEPHONY_STATUS_UNDEFINED,
isSms, this, subId, resultCode, httpStatusCode);
// Whether we succeeded or failed we will check and maybe schedule some more work
ProcessPendingMessagesAction.scheduleProcessPendingMessagesAction(true, this);
return null;
}

View File

@@ -582,7 +582,7 @@ public class MessageData implements Parcelable {
// primary user.
return false;
}
// Should show option for manual download iff status is manual download or failed
// Should show option for manual download if status is manual download or failed
return (status == BUGLE_STATUS_INCOMING_DOWNLOAD_FAILED ||
status == BUGLE_STATUS_INCOMING_YET_TO_MANUAL_DOWNLOAD ||
// If debug is enabled, allow to download an expired or unavailable message.
@@ -596,7 +596,7 @@ public class MessageData implements Parcelable {
// primary user.
return false;
}
// Can download iff status is retrying auto/manual downloading
// Can download if status is retrying auto/manual downloading
return (mStatus == BUGLE_STATUS_INCOMING_RETRYING_MANUAL_DOWNLOAD ||
mStatus == BUGLE_STATUS_INCOMING_RETRYING_AUTO_DOWNLOAD);
}
@@ -607,7 +607,7 @@ public class MessageData implements Parcelable {
// primary user.
return false;
}
// Can redownload iff status is manual download not started or download failed
// Can redownload if status is manual download not started or download failed
return (mStatus == BUGLE_STATUS_INCOMING_DOWNLOAD_FAILED ||
mStatus == BUGLE_STATUS_INCOMING_YET_TO_MANUAL_DOWNLOAD ||
// If debug is enabled, allow to download an expired or unavailable message.
@@ -616,12 +616,12 @@ public class MessageData implements Parcelable {
}
static boolean getShowResendMessage(final int status) {
// Should show option to resend iff status is failed
// Should show option to resend if status is failed
return (status == BUGLE_STATUS_OUTGOING_FAILED);
}
static boolean getOneClickResendMessage(final int status, final int rawStatus) {
// Should show option to resend iff status is failed
// Should show option to resend if status is failed
return (status == BUGLE_STATUS_OUTGOING_FAILED
&& rawStatus == RAW_TELEPHONY_STATUS_UNDEFINED);
}