mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Added more logging around message sending and attachment downloads.
This commit is contained in:
parent
43068e0613
commit
d0db6aa509
@ -856,12 +856,15 @@ public class ConversationItem extends LinearLayout
|
||||
private class AttachmentDownloadClickListener implements SlideClickListener {
|
||||
@Override
|
||||
public void onClick(View v, final Slide slide) {
|
||||
Log.i(TAG, "onClick() for attachment download");
|
||||
if (messageRecord.isMmsNotification()) {
|
||||
Log.i(TAG, "Scheduling MMS attachment download");
|
||||
ApplicationContext.getInstance(context)
|
||||
.getJobManager()
|
||||
.add(new MmsDownloadJob(context, messageRecord.getId(),
|
||||
messageRecord.getThreadId(), false));
|
||||
} else {
|
||||
Log.i(TAG, "Scheduling push attachment download");
|
||||
DatabaseFactory.getAttachmentDatabase(context).setTransferState(messageRecord.getId(),
|
||||
slide.asAttachment(),
|
||||
AttachmentDatabase.TRANSFER_PROGRESS_STARTED);
|
||||
|
@ -380,8 +380,11 @@ public class ThumbnailView extends FrameLayout {
|
||||
private class DownloadClickDispatcher implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.i(TAG, "onClick() for download button");
|
||||
if (downloadClickListener != null && slide != null) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.dependencies.ContextDependent;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -13,6 +14,8 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
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 transient Context context;
|
||||
@ -28,7 +31,10 @@ public class NetworkBackoffRequirement implements Requirement, ContextDependent
|
||||
|
||||
@Override
|
||||
public void onRetry(@NonNull Job job) {
|
||||
Log.i(TAG, "onRetry()");
|
||||
|
||||
if (!(new NetworkRequirement(context).isPresent())) {
|
||||
Log.i(TAG, "No network. Resetting run stats.");
|
||||
job.resetRunStats();
|
||||
return;
|
||||
}
|
||||
|
@ -64,10 +64,13 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId + " partRowId: " + partRowId + " partUniqueId: " + partUniqueId + " manual: " + manual);
|
||||
}
|
||||
|
||||
@Override
|
||||
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 AttachmentId attachmentId = new AttachmentId(partRowId, partUniqueId);
|
||||
final DatabaseAttachment attachment = database.getAttachment(attachmentId);
|
||||
@ -96,6 +99,8 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
Log.w(TAG, "onCanceled() messageId: " + messageId + " partRowId: " + partRowId + " partUniqueId: " + partUniqueId + " manual: " + manual);
|
||||
|
||||
final AttachmentId attachmentId = new AttachmentId(partRowId, partUniqueId);
|
||||
markFailed(messageId, attachmentId);
|
||||
}
|
||||
@ -122,7 +127,7 @@ public class AttachmentDownloadJob extends MasterSecretJob implements Injectable
|
||||
|
||||
database.insertAttachmentsForPlaceholder(messageId, attachmentId, stream);
|
||||
} 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);
|
||||
} finally {
|
||||
if (attachmentFile != null) {
|
||||
|
@ -70,7 +70,7 @@ public class MmsSendJob extends SendJob {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,6 +79,8 @@ public class MmsSendJob extends SendJob {
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId);
|
||||
|
||||
SendReq pdu = constructSendPdu(message);
|
||||
|
||||
validateDestinations(message, pdu);
|
||||
@ -89,6 +91,8 @@ public class MmsSendJob extends SendJob {
|
||||
|
||||
database.markAsSent(messageId, false);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
} catch (UndeliverableMessageException | IOException e) {
|
||||
Log.w(TAG, e);
|
||||
database.markAsSentFailed(messageId);
|
||||
@ -107,6 +111,7 @@ public class MmsSendJob extends SendJob {
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
Log.i(TAG, "onCanceled() messageId: " + messageId);
|
||||
DatabaseFactory.getMmsDatabase(context).markAsSentFailed(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,6 +87,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId);
|
||||
|
||||
deliver(message, filterAddress == null ? null : Address.fromSerialized(filterAddress));
|
||||
|
||||
database.markAsSent(messageId, true);
|
||||
@ -97,6 +100,8 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
.getExpiringMessageManager()
|
||||
.scheduleDeletion(messageId, true, message.getExpiresIn());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
} catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) {
|
||||
Log.w(TAG, e);
|
||||
database.markAsSentFailed(messageId);
|
||||
|
@ -49,7 +49,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,6 +62,8 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId);
|
||||
|
||||
deliver(message);
|
||||
database.markAsSent(messageId, true);
|
||||
markAttachmentsUploaded(messageId, message.getAttachments());
|
||||
@ -71,6 +73,8 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
|
||||
} catch (InsecureFallbackApprovalException ifae) {
|
||||
Log.w(TAG, ifae);
|
||||
database.markAsPendingInsecureSmsFallback(messageId);
|
||||
|
@ -70,14 +70,18 @@ public abstract class PushSendJob extends SendJob {
|
||||
throw new TextSecureExpiredException("Too many signed prekey rotation failures");
|
||||
}
|
||||
|
||||
Log.i(TAG, "Starting message send attempt");
|
||||
onPushSend();
|
||||
Log.i(TAG, "Message send completed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRetry() {
|
||||
super.onRetry();
|
||||
Log.i(TAG, "onRetry()");
|
||||
|
||||
if (getRunIteration() > 1) {
|
||||
Log.i(TAG, "Scheduling service outage detection job.");
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new ServiceOutageDetectionJob(context));
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,9 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {}
|
||||
public void onAdded() {
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
|
||||
} catch (InsecureFallbackApprovalException e) {
|
||||
Log.w(TAG, e);
|
||||
database.markAsPendingInsecureSmsFallback(record.getId());
|
||||
|
@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobParameters;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.MediaStream;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
@ -38,7 +39,9 @@ public abstract class SendJob extends MasterSecretJob {
|
||||
System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
Log.i(TAG, "Starting message send attempt");
|
||||
onSend(masterSecret);
|
||||
Log.i(TAG, "Message send completed");
|
||||
}
|
||||
|
||||
protected abstract void onSend(MasterSecret masterSecret) throws Exception;
|
||||
|
@ -36,6 +36,8 @@ public class ServiceOutageDetectionJob extends ContextJob {
|
||||
|
||||
@Override
|
||||
public void onRun() throws RetryLaterException {
|
||||
Log.i(TAG, "onRun()");
|
||||
|
||||
long timeSinceLastCheck = System.currentTimeMillis() - TextSecurePreferences.getLastOutageCheckTime(context);
|
||||
if (timeSinceLastCheck < CHECK_TIME) {
|
||||
Log.w(TAG, "Skipping service outage check. Too soon.");
|
||||
|
@ -40,7 +40,9 @@ public class SmsSendJob extends SendJob {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded() {}
|
||||
public void onAdded() {
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend(MasterSecret masterSecret) throws NoSuchMessageException {
|
||||
@ -49,8 +51,8 @@ public class SmsSendJob extends SendJob {
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId);
|
||||
|
||||
deliver(record);
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
} catch (UndeliverableMessageException ude) {
|
||||
Log.w(TAG, ude);
|
||||
DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId());
|
||||
@ -65,7 +67,7 @@ public class SmsSendJob extends SendJob {
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
Log.w(TAG, "onCanceled()");
|
||||
Log.w(TAG, "onCanceled() messageId: " + messageId);
|
||||
long threadId = DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageId);
|
||||
Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user