Added more logging around message sending and attachment downloads.

This commit is contained in:
Greyson Parrelli 2018-08-02 09:50:36 -04:00
parent 43068e0613
commit d0db6aa509
12 changed files with 53 additions and 7 deletions

View File

@ -856,12 +856,15 @@ public class ConversationItem extends LinearLayout
private class AttachmentDownloadClickListener implements SlideClickListener { private class AttachmentDownloadClickListener implements SlideClickListener {
@Override @Override
public void onClick(View v, final Slide slide) { public void onClick(View v, final Slide slide) {
Log.i(TAG, "onClick() for attachment download");
if (messageRecord.isMmsNotification()) { if (messageRecord.isMmsNotification()) {
Log.i(TAG, "Scheduling MMS attachment download");
ApplicationContext.getInstance(context) ApplicationContext.getInstance(context)
.getJobManager() .getJobManager()
.add(new MmsDownloadJob(context, messageRecord.getId(), .add(new MmsDownloadJob(context, messageRecord.getId(),
messageRecord.getThreadId(), false)); messageRecord.getThreadId(), false));
} else { } else {
Log.i(TAG, "Scheduling push attachment download");
DatabaseFactory.getAttachmentDatabase(context).setTransferState(messageRecord.getId(), DatabaseFactory.getAttachmentDatabase(context).setTransferState(messageRecord.getId(),
slide.asAttachment(), slide.asAttachment(),
AttachmentDatabase.TRANSFER_PROGRESS_STARTED); AttachmentDatabase.TRANSFER_PROGRESS_STARTED);

View File

@ -380,8 +380,11 @@ public class ThumbnailView extends FrameLayout {
private class DownloadClickDispatcher implements View.OnClickListener { private class DownloadClickDispatcher implements View.OnClickListener {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Log.i(TAG, "onClick() for download button");
if (downloadClickListener != null && slide != null) { if (downloadClickListener != null && slide != null) {
downloadClickListener.onClick(view, slide); downloadClickListener.onClick(view, slide);
} else {
Log.w(TAG, "Received a download button click, but unable to execute it. slide: " + String.valueOf(slide) + " downloadClickListener: " + String.valueOf(downloadClickListener));
} }
} }
} }

View File

@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
import org.thoughtcrime.securesms.jobmanager.Job; import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.dependencies.ContextDependent; import org.thoughtcrime.securesms.jobmanager.dependencies.ContextDependent;
import org.thoughtcrime.securesms.logging.Log;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -13,6 +14,8 @@ import java.util.concurrent.TimeUnit;
*/ */
public class NetworkBackoffRequirement implements Requirement, ContextDependent { public class NetworkBackoffRequirement implements Requirement, ContextDependent {
private static final String TAG = NetworkBackoffRequirement.class.getSimpleName();
private static final long MAX_WAIT = TimeUnit.SECONDS.toMillis(30); private static final long MAX_WAIT = TimeUnit.SECONDS.toMillis(30);
private transient Context context; private transient Context context;
@ -28,7 +31,10 @@ public class NetworkBackoffRequirement implements Requirement, ContextDependent
@Override @Override
public void onRetry(@NonNull Job job) { public void onRetry(@NonNull Job job) {
Log.i(TAG, "onRetry()");
if (!(new NetworkRequirement(context).isPresent())) { if (!(new NetworkRequirement(context).isPresent())) {
Log.i(TAG, "No network. Resetting run stats.");
job.resetRunStats(); job.resetRunStats();
return; return;
} }

View File

@ -64,10 +64,13 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
@Override @Override
public void onAdded() { public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId + " partRowId: " + partRowId + " partUniqueId: " + partUniqueId + " manual: " + manual);
} }
@Override @Override
public void onRun(MasterSecret masterSecret) throws IOException { public void onRun(MasterSecret masterSecret) throws IOException {
Log.i(TAG, "onRun() messageId: " + messageId + " partRowId: " + partRowId + " partUniqueId: " + partUniqueId + " manual: " + manual);
final AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context); final AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
final AttachmentId attachmentId = new AttachmentId(partRowId, partUniqueId); final AttachmentId attachmentId = new AttachmentId(partRowId, partUniqueId);
final DatabaseAttachment attachment = database.getAttachment(attachmentId); final DatabaseAttachment attachment = database.getAttachment(attachmentId);
@ -96,6 +99,8 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
@Override @Override
public void onCanceled() { public void onCanceled() {
Log.w(TAG, "onCanceled() messageId: " + messageId + " partRowId: " + partRowId + " partUniqueId: " + partUniqueId + " manual: " + manual);
final AttachmentId attachmentId = new AttachmentId(partRowId, partUniqueId); final AttachmentId attachmentId = new AttachmentId(partRowId, partUniqueId);
markFailed(messageId, attachmentId); markFailed(messageId, attachmentId);
} }
@ -122,7 +127,7 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
database.insertAttachmentsForPlaceholder(messageId, attachmentId, stream); database.insertAttachmentsForPlaceholder(messageId, attachmentId, stream);
} catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) { } catch (InvalidPartException | NonSuccessfulResponseCodeException | InvalidMessageException | MmsException e) {
Log.w(TAG, e); Log.w(TAG, "Experienced exception while trying to download an attachment.", e);
markFailed(messageId, attachmentId); markFailed(messageId, attachmentId);
} finally { } finally {
if (attachmentFile != null) { if (attachmentFile != null) {

View File

@ -70,7 +70,7 @@ public class MmsSendJob extends SendJob {
@Override @Override
public void onAdded() { public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId);
} }
@Override @Override
@ -79,6 +79,8 @@ public class MmsSendJob extends SendJob {
OutgoingMediaMessage message = database.getOutgoingMessage(messageId); OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
try { try {
Log.i(TAG, "Sending message: " + messageId);
SendReq pdu = constructSendPdu(message); SendReq pdu = constructSendPdu(message);
validateDestinations(message, pdu); validateDestinations(message, pdu);
@ -89,6 +91,8 @@ public class MmsSendJob extends SendJob {
database.markAsSent(messageId, false); database.markAsSent(messageId, false);
markAttachmentsUploaded(messageId, message.getAttachments()); markAttachmentsUploaded(messageId, message.getAttachments());
Log.i(TAG, "Sent message: " + messageId);
} catch (UndeliverableMessageException | IOException e) { } catch (UndeliverableMessageException | IOException e) {
Log.w(TAG, e); Log.w(TAG, e);
database.markAsSentFailed(messageId); database.markAsSentFailed(messageId);
@ -107,6 +111,7 @@ public class MmsSendJob extends SendJob {
@Override @Override
public void onCanceled() { public void onCanceled() {
Log.i(TAG, "onCanceled() messageId: " + messageId);
DatabaseFactory.getMmsDatabase(context).markAsSentFailed(messageId); DatabaseFactory.getMmsDatabase(context).markAsSentFailed(messageId);
notifyMediaMessageDeliveryFailed(context, messageId); notifyMediaMessageDeliveryFailed(context, messageId);
} }

View File

@ -76,6 +76,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
@Override @Override
public void onAdded() { public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId);
} }
@Override @Override
@ -86,6 +87,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
OutgoingMediaMessage message = database.getOutgoingMessage(messageId); OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
try { try {
Log.i(TAG, "Sending message: " + messageId);
deliver(message, filterAddress == null ? null : Address.fromSerialized(filterAddress)); deliver(message, filterAddress == null ? null : Address.fromSerialized(filterAddress));
database.markAsSent(messageId, true); database.markAsSent(messageId, true);
@ -97,6 +100,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
.getExpiringMessageManager() .getExpiringMessageManager()
.scheduleDeletion(messageId, true, message.getExpiresIn()); .scheduleDeletion(messageId, true, message.getExpiresIn());
} }
Log.i(TAG, "Sent message: " + messageId);
} catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) { } catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) {
Log.w(TAG, e); Log.w(TAG, e);
database.markAsSentFailed(messageId); database.markAsSentFailed(messageId);

View File

@ -49,7 +49,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
@Override @Override
public void onAdded() { public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId);
} }
@Override @Override
@ -62,6 +62,8 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
OutgoingMediaMessage message = database.getOutgoingMessage(messageId); OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
try { try {
Log.i(TAG, "Sending message: " + messageId);
deliver(message); deliver(message);
database.markAsSent(messageId, true); database.markAsSent(messageId, true);
markAttachmentsUploaded(messageId, message.getAttachments()); markAttachmentsUploaded(messageId, message.getAttachments());
@ -71,6 +73,8 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn()); expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
} }
Log.i(TAG, "Sent message: " + messageId);
} catch (InsecureFallbackApprovalException ifae) { } catch (InsecureFallbackApprovalException ifae) {
Log.w(TAG, ifae); Log.w(TAG, ifae);
database.markAsPendingInsecureSmsFallback(messageId); database.markAsPendingInsecureSmsFallback(messageId);

View File

@ -70,14 +70,18 @@ public abstract class PushSendJob extends SendJob {
throw new TextSecureExpiredException("Too many signed prekey rotation failures"); throw new TextSecureExpiredException("Too many signed prekey rotation failures");
} }
Log.i(TAG, "Starting message send attempt");
onPushSend(); onPushSend();
Log.i(TAG, "Message send completed");
} }
@Override @Override
public void onRetry() { public void onRetry() {
super.onRetry(); super.onRetry();
Log.i(TAG, "onRetry()");
if (getRunIteration() > 1) { if (getRunIteration() > 1) {
Log.i(TAG, "Scheduling service outage detection job.");
ApplicationContext.getInstance(context).getJobManager().add(new ServiceOutageDetectionJob(context)); ApplicationContext.getInstance(context).getJobManager().add(new ServiceOutageDetectionJob(context));
} }
} }

View File

@ -42,7 +42,9 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
} }
@Override @Override
public void onAdded() {} public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId);
}
@Override @Override
public void onPushSend() throws NoSuchMessageException, RetryLaterException { public void onPushSend() throws NoSuchMessageException, RetryLaterException {
@ -61,6 +63,8 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
expirationManager.scheduleDeletion(record.getId(), record.isMms(), record.getExpiresIn()); expirationManager.scheduleDeletion(record.getId(), record.isMms(), record.getExpiresIn());
} }
Log.i(TAG, "Sent message: " + messageId);
} catch (InsecureFallbackApprovalException e) { } catch (InsecureFallbackApprovalException e) {
Log.w(TAG, e); Log.w(TAG, e);
database.markAsPendingInsecureSmsFallback(record.getId()); database.markAsPendingInsecureSmsFallback(record.getId());

View File

@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.AttachmentDatabase; import org.thoughtcrime.securesms.database.AttachmentDatabase;
import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.jobmanager.JobParameters; import org.thoughtcrime.securesms.jobmanager.JobParameters;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.mms.MediaConstraints; import org.thoughtcrime.securesms.mms.MediaConstraints;
import org.thoughtcrime.securesms.mms.MediaStream; import org.thoughtcrime.securesms.mms.MediaStream;
import org.thoughtcrime.securesms.mms.MmsException; import org.thoughtcrime.securesms.mms.MmsException;
@ -38,7 +39,9 @@ public abstract class SendJob extends MasterSecretJob {
System.currentTimeMillis())); System.currentTimeMillis()));
} }
Log.i(TAG, "Starting message send attempt");
onSend(masterSecret); onSend(masterSecret);
Log.i(TAG, "Message send completed");
} }
protected abstract void onSend(MasterSecret masterSecret) throws Exception; protected abstract void onSend(MasterSecret masterSecret) throws Exception;

View File

@ -36,6 +36,8 @@ public class ServiceOutageDetectionJob extends ContextJob {
@Override @Override
public void onRun() throws RetryLaterException { public void onRun() throws RetryLaterException {
Log.i(TAG, "onRun()");
long timeSinceLastCheck = System.currentTimeMillis() - TextSecurePreferences.getLastOutageCheckTime(context); long timeSinceLastCheck = System.currentTimeMillis() - TextSecurePreferences.getLastOutageCheckTime(context);
if (timeSinceLastCheck < CHECK_TIME) { if (timeSinceLastCheck < CHECK_TIME) {
Log.w(TAG, "Skipping service outage check. Too soon."); Log.w(TAG, "Skipping service outage check. Too soon.");

View File

@ -40,7 +40,9 @@ public class SmsSendJob extends SendJob {
} }
@Override @Override
public void onAdded() {} public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId);
}
@Override @Override
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException { public void onSend(MasterSecret masterSecret) throws NoSuchMessageException {
@ -49,8 +51,8 @@ public class SmsSendJob extends SendJob {
try { try {
Log.i(TAG, "Sending message: " + messageId); Log.i(TAG, "Sending message: " + messageId);
deliver(record); deliver(record);
Log.i(TAG, "Sent message: " + messageId);
} catch (UndeliverableMessageException ude) { } catch (UndeliverableMessageException ude) {
Log.w(TAG, ude); Log.w(TAG, ude);
DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId()); DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId());
@ -65,7 +67,7 @@ public class SmsSendJob extends SendJob {
@Override @Override
public void onCanceled() { public void onCanceled() {
Log.w(TAG, "onCanceled()"); Log.w(TAG, "onCanceled() messageId: " + messageId);
long threadId = DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageId); long threadId = DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageId);
Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId); Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);