mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-23 20:03:47 +00:00
Updated logging.
This commit is contained in:
@@ -20,7 +20,6 @@ import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobParameters;
|
||||
import org.thoughtcrime.securesms.jobmanager.SafeData;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
||||
@@ -114,12 +113,12 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
List<IdentityKeyMismatch> existingIdentityMismatches = message.getIdentityKeyMismatches();
|
||||
|
||||
if (database.isSent(messageId)) {
|
||||
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
log(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId);
|
||||
log(TAG, "Sending message: " + messageId);
|
||||
|
||||
List<Address> target;
|
||||
|
||||
@@ -178,11 +177,11 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
} catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, e);
|
||||
database.markAsSentFailed(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
} catch (UntrustedIdentityException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, e);
|
||||
database.markAsSentFailed(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ import org.thoughtcrime.securesms.database.NoSuchMessageException;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.SafeData;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
@@ -87,12 +86,12 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
|
||||
if (database.isSent(messageId)) {
|
||||
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
warn(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId);
|
||||
log(TAG, "Sending message: " + messageId);
|
||||
|
||||
Recipient recipient = message.getRecipient().resolve();
|
||||
byte[] profileKey = recipient.getProfileKey();
|
||||
@@ -106,13 +105,13 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
if (TextSecurePreferences.isUnidentifiedDeliveryEnabled(context)) {
|
||||
if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN && profileKey == null) {
|
||||
Log.i(TAG, "Marking recipient as UD-unrestricted following a UD send.");
|
||||
log(TAG, "Marking recipient as UD-unrestricted following a UD send.");
|
||||
DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.UNRESTRICTED);
|
||||
} else if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN) {
|
||||
Log.i(TAG, "Marking recipient as UD-enabled following a UD send.");
|
||||
log(TAG, "Marking recipient as UD-enabled following a UD send.");
|
||||
DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.ENABLED);
|
||||
} else if (!unidentified && accessMode != UnidentifiedAccessMode.DISABLED) {
|
||||
Log.i(TAG, "Marking recipient as UD-disabled following a non-UD send.");
|
||||
log(TAG, "Marking recipient as UD-disabled following a non-UD send.");
|
||||
DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.DISABLED);
|
||||
}
|
||||
}
|
||||
@@ -122,15 +121,15 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
log(TAG, "Sent message: " + messageId);
|
||||
|
||||
} catch (InsecureFallbackApprovalException ifae) {
|
||||
Log.w(TAG, ifae);
|
||||
warn(TAG, "Failure", ifae);
|
||||
database.markAsPendingInsecureSmsFallback(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
|
||||
} catch (UntrustedIdentityException uie) {
|
||||
Log.w(TAG, uie);
|
||||
warn(TAG, "Failure", uie);
|
||||
database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey());
|
||||
database.markAsSentFailed(messageId);
|
||||
}
|
||||
@@ -179,13 +178,13 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
return messageSender.sendMessage(address, UnidentifiedAccessUtil.getAccessFor(context, message.getRecipient()), mediaMessage).getSuccess().isUnidentified();
|
||||
} catch (UnregisteredUserException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, e);
|
||||
throw new InsecureFallbackApprovalException(e);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, e);
|
||||
throw new UndeliverableMessageException(e);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, e);
|
||||
throw new RetryLaterException(e);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ import org.thoughtcrime.securesms.TextSecureExpiredException;
|
||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
||||
import org.thoughtcrime.securesms.contactshare.ContactModelMapper;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
@@ -76,9 +75,7 @@ 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
|
||||
|
@@ -5,7 +5,6 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
|
||||
import org.thoughtcrime.securesms.jobmanager.SafeData;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
@@ -69,7 +68,6 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId);
|
||||
DatabaseFactory.getSmsDatabase(context).markAsSending(messageId);
|
||||
}
|
||||
|
||||
@@ -80,12 +78,12 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
SmsMessageRecord record = database.getMessage(messageId);
|
||||
|
||||
if (!record.isPending() && !record.isFailed()) {
|
||||
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
warn(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId);
|
||||
log(TAG, "Sending message: " + messageId);
|
||||
|
||||
Recipient recipient = record.getRecipient().resolve();
|
||||
byte[] profileKey = recipient.getProfileKey();
|
||||
@@ -98,13 +96,13 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
if (TextSecurePreferences.isUnidentifiedDeliveryEnabled(context)) {
|
||||
if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN && profileKey == null) {
|
||||
Log.i(TAG, "Marking recipient as UD-unrestricted following a UD send.");
|
||||
log(TAG, "Marking recipient as UD-unrestricted following a UD send.");
|
||||
DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.UNRESTRICTED);
|
||||
} else if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN) {
|
||||
Log.i(TAG, "Marking recipient as UD-enabled following a UD send.");
|
||||
log(TAG, "Marking recipient as UD-enabled following a UD send.");
|
||||
DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.ENABLED);
|
||||
} else if (!unidentified && accessMode != UnidentifiedAccessMode.DISABLED) {
|
||||
Log.i(TAG, "Marking recipient as UD-disabled following a non-UD send.");
|
||||
log(TAG, "Marking recipient as UD-disabled following a non-UD send.");
|
||||
DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.DISABLED);
|
||||
}
|
||||
}
|
||||
@@ -114,15 +112,15 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
expirationManager.scheduleDeletion(record.getId(), record.isMms(), record.getExpiresIn());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
log(TAG, "Sent message: " + messageId);
|
||||
|
||||
} catch (InsecureFallbackApprovalException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, "Failure", e);
|
||||
database.markAsPendingInsecureSmsFallback(record.getId());
|
||||
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
|
||||
} catch (UntrustedIdentityException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, "Failure", e);
|
||||
database.addMismatchedIdentity(record.getId(), Address.fromSerialized(e.getE164Number()), e.getIdentityKey());
|
||||
database.markAsSentFailed(record.getId());
|
||||
database.markAsPush(record.getId());
|
||||
@@ -158,7 +156,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
Optional<byte[]> profileKey = getProfileKey(message.getIndividualRecipient());
|
||||
Optional<UnidentifiedAccessPair> unidentifiedAccess = UnidentifiedAccessUtil.getAccessFor(context, message.getIndividualRecipient());
|
||||
|
||||
Log.w(TAG, "Have access key to use: " + unidentifiedAccess.isPresent());
|
||||
log(TAG, "Have access key to use: " + unidentifiedAccess.isPresent());
|
||||
|
||||
SignalServiceDataMessage textSecureMessage = SignalServiceDataMessage.newBuilder()
|
||||
.withTimestamp(message.getDateSent())
|
||||
@@ -170,10 +168,10 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
return messageSender.sendMessage(address, unidentifiedAccess, textSecureMessage).getSuccess().isUnidentified();
|
||||
} catch (UnregisteredUserException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, "Failure", e);
|
||||
throw new InsecureFallbackApprovalException(e);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
warn(TAG, "Failure", e);
|
||||
throw new RetryLaterException(e);
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public class RotateCertificateJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static final String TAG = RotateCertificateJob.class.getName();
|
||||
private static final String TAG = RotateCertificateJob.class.getSimpleName();
|
||||
|
||||
@Inject transient SignalServiceAccountManager accountManager;
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import androidx.work.WorkerParameters;
|
||||
|
||||
public class RotateSignedPreKeyJob extends ContextJob implements InjectableType {
|
||||
|
||||
private static final String TAG = RotateSignedPreKeyJob.class.getName();
|
||||
private static final String TAG = RotateSignedPreKeyJob.class.getSimpleName();
|
||||
|
||||
@Inject transient SignalServiceAccountManager accountManager;
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
@@ -95,4 +96,20 @@ public abstract class SendJob extends ContextJob {
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
protected void log(@NonNull String tag, @NonNull String message) {
|
||||
Log.i(tag, "[" + getId().toString() + "] " + message + logSuffix());
|
||||
}
|
||||
|
||||
protected void warn(@NonNull String tag, @NonNull String message) {
|
||||
warn(tag, message, null);
|
||||
}
|
||||
|
||||
protected void warn(@NonNull String tag, @Nullable Throwable t) {
|
||||
warn(tag, "", t);
|
||||
}
|
||||
|
||||
protected void warn(@NonNull String tag, @NonNull String message, @Nullable Throwable t) {
|
||||
Log.w(tag, "[" + getId().toString() + "] " + message + logSuffix(), t);
|
||||
}
|
||||
}
|
||||
|
@@ -73,18 +73,17 @@ public class SmsSendJob extends SendJob {
|
||||
|
||||
@Override
|
||||
public void onAdded() {
|
||||
Log.i(TAG, "onAdded() messageId: " + messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSend() throws NoSuchMessageException, RequirementNotMetException, TooManyRetriesException {
|
||||
if (!requirementsMet()) {
|
||||
Log.w(TAG, "No service. Retrying.");
|
||||
warn(TAG, "No service. Retrying.");
|
||||
throw new RequirementNotMetException();
|
||||
}
|
||||
|
||||
if (runAttempt >= MAX_ATTEMPTS) {
|
||||
Log.w(TAG, "Hit the retry limit. Failing.");
|
||||
warn(TAG, "Hit the retry limit. Failing.");
|
||||
throw new TooManyRetriesException();
|
||||
}
|
||||
|
||||
@@ -92,16 +91,16 @@ public class SmsSendJob extends SendJob {
|
||||
SmsMessageRecord record = database.getMessage(messageId);
|
||||
|
||||
if (!record.isPending() && !record.isFailed()) {
|
||||
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
warn(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Log.i(TAG, "Sending message: " + messageId + " (attempt " + runAttempt + ")");
|
||||
log(TAG, "Sending message: " + messageId + " (attempt " + runAttempt + ")");
|
||||
deliver(record);
|
||||
Log.i(TAG, "Sent message: " + messageId);
|
||||
log(TAG, "Sent message: " + messageId);
|
||||
} catch (UndeliverableMessageException ude) {
|
||||
Log.w(TAG, ude);
|
||||
warn(TAG, ude);
|
||||
DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId());
|
||||
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
|
||||
}
|
||||
@@ -114,7 +113,7 @@ public class SmsSendJob extends SendJob {
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
Log.w(TAG, "onCanceled() messageId: " + messageId);
|
||||
warn(TAG, "onCanceled() messageId: " + messageId);
|
||||
long threadId = DatabaseFactory.getSmsDatabase(context).getThreadIdForMessage(messageId);
|
||||
Recipient recipient = DatabaseFactory.getThreadDatabase(context).getRecipientForThreadId(threadId);
|
||||
|
||||
@@ -165,9 +164,9 @@ public class SmsSendJob extends SendJob {
|
||||
try {
|
||||
getSmsManagerFor(message.getSubscriptionId()).sendMultipartTextMessage(recipient, null, messages, sentIntents, deliveredIntents);
|
||||
} catch (NullPointerException | IllegalArgumentException npe) {
|
||||
Log.w(TAG, npe);
|
||||
Log.i(TAG, "Recipient: " + recipient);
|
||||
Log.i(TAG, "Message Parts: " + messages.size());
|
||||
warn(TAG, npe);
|
||||
log(TAG, "Recipient: " + recipient);
|
||||
log(TAG, "Message Parts: " + messages.size());
|
||||
|
||||
try {
|
||||
for (int i=0;i<messages.size();i++) {
|
||||
@@ -176,11 +175,11 @@ public class SmsSendJob extends SendJob {
|
||||
deliveredIntents == null ? null : deliveredIntents.get(i));
|
||||
}
|
||||
} catch (NullPointerException | IllegalArgumentException npe2) {
|
||||
Log.w(TAG, npe);
|
||||
warn(TAG, npe);
|
||||
throw new UndeliverableMessageException(npe2);
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
Log.w(TAG, se);
|
||||
warn(TAG, se);
|
||||
throw new UndeliverableMessageException(se);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user