Updated logging.

This commit is contained in:
Greyson Parrelli 2018-12-06 12:14:20 -08:00
parent 2489ea0d5b
commit bfdad2f47c
33 changed files with 94 additions and 85 deletions

View File

@ -191,10 +191,9 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
@Override @Override
protected void onBindItemViewHolder(ViewHolder viewHolder, @NonNull MessageRecord messageRecord) { protected void onBindItemViewHolder(ViewHolder viewHolder, @NonNull MessageRecord messageRecord) {
long start = System.currentTimeMillis(); int adapterPosition = viewHolder.getAdapterPosition();
int adapterPosition = viewHolder.getAdapterPosition(); MessageRecord previousRecord = adapterPosition < getItemCount() - 1 && !isFooterPosition(adapterPosition + 1) ? getRecordForPositionOrThrow(adapterPosition + 1) : null;
MessageRecord previousRecord = adapterPosition < getItemCount() - 1 && !isFooterPosition(adapterPosition + 1) ? getRecordForPositionOrThrow(adapterPosition + 1) : null; MessageRecord nextRecord = adapterPosition > 0 && !isHeaderPosition(adapterPosition - 1) ? getRecordForPositionOrThrow(adapterPosition - 1) : null;
MessageRecord nextRecord = adapterPosition > 0 && !isHeaderPosition(adapterPosition - 1) ? getRecordForPositionOrThrow(adapterPosition - 1) : null;
viewHolder.getView().bind(messageRecord, viewHolder.getView().bind(messageRecord,
Optional.fromNullable(previousRecord), Optional.fromNullable(previousRecord),
@ -208,8 +207,6 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
if (messageRecord == recordToPulseHighlight) { if (messageRecord == recordToPulseHighlight) {
recordToPulseHighlight = null; recordToPulseHighlight = null;
} }
Log.d(TAG, "Bind time: " + (System.currentTimeMillis() - start));
} }
@Override @Override

View File

@ -159,7 +159,7 @@ public class ComposeText extends EmojiEditText {
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB_MR2) @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB_MR2)
private static class CommitContentListener implements InputConnectionCompat.OnCommitContentListener { private static class CommitContentListener implements InputConnectionCompat.OnCommitContentListener {
private static final String TAG = CommitContentListener.class.getName(); private static final String TAG = CommitContentListener.class.getSimpleName();
private final InputPanel.MediaListener mediaListener; private final InputPanel.MediaListener mediaListener;

View File

@ -79,7 +79,7 @@ public class RecentPhotoViewRail extends FrameLayout implements LoaderManager.Lo
private static class RecentPhotoAdapter extends CursorRecyclerViewAdapter<RecentPhotoAdapter.RecentPhotoViewHolder> { private static class RecentPhotoAdapter extends CursorRecyclerViewAdapter<RecentPhotoAdapter.RecentPhotoViewHolder> {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String TAG = RecentPhotoAdapter.class.getName(); private static final String TAG = RecentPhotoAdapter.class.getSimpleName();
@NonNull private final Uri baseUri; @NonNull private final Uri baseUri;
@Nullable private OnItemClickedListener clickedListener; @Nullable private OnItemClickedListener clickedListener;

View File

@ -61,7 +61,7 @@ public class ThreadPhotoRailView extends FrameLayout {
private static class ThreadPhotoRailAdapter extends CursorRecyclerViewAdapter<ThreadPhotoRailAdapter.ThreadPhotoViewHolder> { private static class ThreadPhotoRailAdapter extends CursorRecyclerViewAdapter<ThreadPhotoRailAdapter.ThreadPhotoViewHolder> {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String TAG = ThreadPhotoRailAdapter.class.getName(); private static final String TAG = ThreadPhotoRailAdapter.class.getSimpleName();
@NonNull private final GlideRequests glideRequests; @NonNull private final GlideRequests glideRequests;

View File

@ -35,7 +35,7 @@ import java.io.InputStream;
public class ZoomingImageView extends FrameLayout { public class ZoomingImageView extends FrameLayout {
private static final String TAG = ZoomingImageView.class.getName(); private static final String TAG = ZoomingImageView.class.getSimpleName();
private final PhotoView photoView; private final PhotoView photoView;
private final SubsamplingScaleImageView subsamplingImageView; private final SubsamplingScaleImageView subsamplingImageView;

View File

@ -19,7 +19,7 @@ import java.io.InputStream;
public class AttachmentRegionDecoder implements ImageRegionDecoder { public class AttachmentRegionDecoder implements ImageRegionDecoder {
private static final String TAG = AttachmentRegionDecoder.class.getName(); private static final String TAG = AttachmentRegionDecoder.class.getSimpleName();
private SkiaImageRegionDecoder passthrough; private SkiaImageRegionDecoder passthrough;

View File

@ -37,7 +37,7 @@ import java.util.List;
public class PreKeyUtil { public class PreKeyUtil {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String TAG = PreKeyUtil.class.getName(); private static final String TAG = PreKeyUtil.class.getSimpleName();
private static final int BATCH_SIZE = 100; private static final int BATCH_SIZE = 100;

View File

@ -54,9 +54,9 @@ public class UnidentifiedAccessUtil {
ourUnidentifiedAccessKey = Util.getSecretBytes(16); ourUnidentifiedAccessKey = Util.getSecretBytes(16);
} }
Log.i(TAG, "Their access key present? " + (theirUnidentifiedAccessKey != null)); Log.i(TAG, "Their access key present? " + (theirUnidentifiedAccessKey != null) +
Log.i(TAG, "Our access key present? " + (ourUnidentifiedAccessKey != null)); " | Our access key present? " + (ourUnidentifiedAccessKey != null) +
Log.i(TAG, "Our certificate present? " + (ourUnidentifiedAccessCertificate != null)); " | Our certificate present? " + (ourUnidentifiedAccessCertificate != null));
if (theirUnidentifiedAccessKey != null && if (theirUnidentifiedAccessKey != null &&
ourUnidentifiedAccessKey != null && ourUnidentifiedAccessKey != null &&

View File

@ -1103,7 +1103,6 @@ public class MmsDatabase extends MessagingDatabase {
where += (" ELSE " + DATE_RECEIVED + " < " + date + " END)"); where += (" ELSE " + DATE_RECEIVED + " < " + date + " END)");
Log.i("MmsDatabase", "Executing trim query: " + where);
cursor = db.query(TABLE_NAME, new String[] {ID}, where, new String[] {threadId+""}, null, null, null); cursor = db.query(TABLE_NAME, new String[] {ID}, where, new String[] {threadId+""}, null, null, null);
while (cursor != null && cursor.moveToNext()) { while (cursor != null && cursor.moveToNext()) {

View File

@ -374,7 +374,6 @@ public class MmsSmsDatabase extends Database {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
String query = outerQueryBuilder.buildQuery(projection, null, null, null, null, null, null); String query = outerQueryBuilder.buildQuery(projection, null, null, null, null, null, null);
Log.d(TAG, "Executing query: " + query);
SQLiteDatabase db = databaseHelper.getReadableDatabase(); SQLiteDatabase db = databaseHelper.getReadableDatabase();
return db.rawQuery(query, null); return db.rawQuery(query, null);
} }

View File

@ -24,7 +24,7 @@ import okhttp3.Response;
public abstract class GiphyLoader extends AsyncLoader<List<GiphyImage>> { public abstract class GiphyLoader extends AsyncLoader<List<GiphyImage>> {
private static final String TAG = GiphyLoader.class.getName(); private static final String TAG = GiphyLoader.class.getSimpleName();
public static int PAGE_SIZE = 100; public static int PAGE_SIZE = 100;

View File

@ -22,7 +22,7 @@ import okhttp3.ResponseBody;
*/ */
class OkHttpStreamFetcher implements DataFetcher<InputStream> { class OkHttpStreamFetcher implements DataFetcher<InputStream> {
private static final String TAG = OkHttpStreamFetcher.class.getName(); private static final String TAG = OkHttpStreamFetcher.class.getSimpleName();
private final OkHttpClient client; private final OkHttpClient client;
private final GlideUrl url; private final GlideUrl url;

View File

@ -129,7 +129,7 @@ public abstract class Job extends Worker implements Serializable {
} }
final void onSubmit(@NonNull Context context, @NonNull UUID id) { final void onSubmit(@NonNull Context context, @NonNull UUID id) {
Log.i(TAG, buildLog(id, "onSubmit()")); Log.i(TAG, buildLog(id, "onSubmit() network: " + (new NetworkRequirement(getApplicationContext()).isPresent())));
if (this instanceof ContextDependent) { if (this instanceof ContextDependent) {
((ContextDependent) this).setContext(context); ((ContextDependent) this).setContext(context);
@ -257,9 +257,8 @@ public abstract class Job extends Worker implements Serializable {
return "[" + id + "] " + getClass().getSimpleName() + " :: " + message; return "[" + id + "] " + getClass().getSimpleName() + " :: " + message;
} }
private String logSuffix() { protected String logSuffix() {
long timeSinceSubmission = System.currentTimeMillis() - getInputData().getLong(KEY_SUBMIT_TIME, 0); long timeSinceSubmission = System.currentTimeMillis() - getInputData().getLong(KEY_SUBMIT_TIME, 0);
return " (Time since submission: " + timeSinceSubmission + " ms, Run attempt: " + getRunAttemptCount() + ", isStopped: " + isStopped() + ")"; return " (Time since submission: " + timeSinceSubmission + " ms, Run attempt: " + getRunAttemptCount() + ", isStopped: " + isStopped() + ")";
} }
} }

View File

@ -20,7 +20,6 @@ import org.thoughtcrime.securesms.database.documents.NetworkFailure;
import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.jobmanager.JobParameters; import org.thoughtcrime.securesms.jobmanager.JobParameters;
import org.thoughtcrime.securesms.jobmanager.SafeData; import org.thoughtcrime.securesms.jobmanager.SafeData;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.mms.MediaConstraints; import org.thoughtcrime.securesms.mms.MediaConstraints;
import org.thoughtcrime.securesms.mms.MmsException; import org.thoughtcrime.securesms.mms.MmsException;
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
@ -114,12 +113,12 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
List<IdentityKeyMismatch> existingIdentityMismatches = message.getIdentityKeyMismatches(); List<IdentityKeyMismatch> existingIdentityMismatches = message.getIdentityKeyMismatches();
if (database.isSent(messageId)) { if (database.isSent(messageId)) {
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring."); log(TAG, "Message " + messageId + " was already sent. Ignoring.");
return; return;
} }
try { try {
Log.i(TAG, "Sending message: " + messageId); log(TAG, "Sending message: " + messageId);
List<Address> target; List<Address> target;
@ -178,11 +177,11 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
} }
} catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) { } catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) {
Log.w(TAG, e); warn(TAG, e);
database.markAsSentFailed(messageId); database.markAsSentFailed(messageId);
notifyMediaMessageDeliveryFailed(context, messageId); notifyMediaMessageDeliveryFailed(context, messageId);
} catch (UntrustedIdentityException e) { } catch (UntrustedIdentityException e) {
Log.w(TAG, e); warn(TAG, e);
database.markAsSentFailed(messageId); database.markAsSentFailed(messageId);
notifyMediaMessageDeliveryFailed(context, messageId); notifyMediaMessageDeliveryFailed(context, messageId);
} }

View File

@ -13,7 +13,6 @@ import org.thoughtcrime.securesms.database.NoSuchMessageException;
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode; import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.jobmanager.SafeData; import org.thoughtcrime.securesms.jobmanager.SafeData;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.mms.MediaConstraints; import org.thoughtcrime.securesms.mms.MediaConstraints;
import org.thoughtcrime.securesms.mms.MmsException; import org.thoughtcrime.securesms.mms.MmsException;
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
@ -87,12 +86,12 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
OutgoingMediaMessage message = database.getOutgoingMessage(messageId); OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
if (database.isSent(messageId)) { if (database.isSent(messageId)) {
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring."); warn(TAG, "Message " + messageId + " was already sent. Ignoring.");
return; return;
} }
try { try {
Log.i(TAG, "Sending message: " + messageId); log(TAG, "Sending message: " + messageId);
Recipient recipient = message.getRecipient().resolve(); Recipient recipient = message.getRecipient().resolve();
byte[] profileKey = recipient.getProfileKey(); byte[] profileKey = recipient.getProfileKey();
@ -106,13 +105,13 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
if (TextSecurePreferences.isUnidentifiedDeliveryEnabled(context)) { if (TextSecurePreferences.isUnidentifiedDeliveryEnabled(context)) {
if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN && profileKey == null) { 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); DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.UNRESTRICTED);
} else if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN) { } 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); DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.ENABLED);
} else if (!unidentified && accessMode != UnidentifiedAccessMode.DISABLED) { } 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); DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.DISABLED);
} }
} }
@ -122,15 +121,15 @@ 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); log(TAG, "Sent message: " + messageId);
} catch (InsecureFallbackApprovalException ifae) { } catch (InsecureFallbackApprovalException ifae) {
Log.w(TAG, ifae); warn(TAG, "Failure", ifae);
database.markAsPendingInsecureSmsFallback(messageId); database.markAsPendingInsecureSmsFallback(messageId);
notifyMediaMessageDeliveryFailed(context, messageId); notifyMediaMessageDeliveryFailed(context, messageId);
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false)); ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
} catch (UntrustedIdentityException uie) { } catch (UntrustedIdentityException uie) {
Log.w(TAG, uie); warn(TAG, "Failure", uie);
database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey()); database.addMismatchedIdentity(messageId, Address.fromSerialized(uie.getE164Number()), uie.getIdentityKey());
database.markAsSentFailed(messageId); 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(); return messageSender.sendMessage(address, UnidentifiedAccessUtil.getAccessFor(context, message.getRecipient()), mediaMessage).getSuccess().isUnidentified();
} catch (UnregisteredUserException e) { } catch (UnregisteredUserException e) {
Log.w(TAG, e); warn(TAG, e);
throw new InsecureFallbackApprovalException(e); throw new InsecureFallbackApprovalException(e);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
Log.w(TAG, e); warn(TAG, e);
throw new UndeliverableMessageException(e); throw new UndeliverableMessageException(e);
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, e); warn(TAG, e);
throw new RetryLaterException(e); throw new RetryLaterException(e);
} }
} }

View File

@ -11,7 +11,6 @@ import org.thoughtcrime.securesms.TextSecureExpiredException;
import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.contactshare.Contact; import org.thoughtcrime.securesms.contactshare.Contact;
import org.thoughtcrime.securesms.contactshare.ContactModelMapper; import org.thoughtcrime.securesms.contactshare.ContactModelMapper;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil; import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory; 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"); 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

View File

@ -5,7 +5,6 @@ import android.support.annotation.NonNull;
import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode; import org.thoughtcrime.securesms.database.RecipientDatabase.UnidentifiedAccessMode;
import org.thoughtcrime.securesms.jobmanager.SafeData; import org.thoughtcrime.securesms.jobmanager.SafeData;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil; import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
@ -69,7 +68,6 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
@Override @Override
public void onAdded() { public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId);
DatabaseFactory.getSmsDatabase(context).markAsSending(messageId); DatabaseFactory.getSmsDatabase(context).markAsSending(messageId);
} }
@ -80,12 +78,12 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
SmsMessageRecord record = database.getMessage(messageId); SmsMessageRecord record = database.getMessage(messageId);
if (!record.isPending() && !record.isFailed()) { if (!record.isPending() && !record.isFailed()) {
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring."); warn(TAG, "Message " + messageId + " was already sent. Ignoring.");
return; return;
} }
try { try {
Log.i(TAG, "Sending message: " + messageId); log(TAG, "Sending message: " + messageId);
Recipient recipient = record.getRecipient().resolve(); Recipient recipient = record.getRecipient().resolve();
byte[] profileKey = recipient.getProfileKey(); byte[] profileKey = recipient.getProfileKey();
@ -98,13 +96,13 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
if (TextSecurePreferences.isUnidentifiedDeliveryEnabled(context)) { if (TextSecurePreferences.isUnidentifiedDeliveryEnabled(context)) {
if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN && profileKey == null) { 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); DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.UNRESTRICTED);
} else if (unidentified && accessMode == UnidentifiedAccessMode.UNKNOWN) { } 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); DatabaseFactory.getRecipientDatabase(context).setUnidentifiedAccessMode(recipient, UnidentifiedAccessMode.ENABLED);
} else if (!unidentified && accessMode != UnidentifiedAccessMode.DISABLED) { } 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); 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()); expirationManager.scheduleDeletion(record.getId(), record.isMms(), record.getExpiresIn());
} }
Log.i(TAG, "Sent message: " + messageId); log(TAG, "Sent message: " + messageId);
} catch (InsecureFallbackApprovalException e) { } catch (InsecureFallbackApprovalException e) {
Log.w(TAG, e); warn(TAG, "Failure", e);
database.markAsPendingInsecureSmsFallback(record.getId()); database.markAsPendingInsecureSmsFallback(record.getId());
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId()); MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false)); ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(context, false));
} catch (UntrustedIdentityException e) { } catch (UntrustedIdentityException e) {
Log.w(TAG, e); warn(TAG, "Failure", e);
database.addMismatchedIdentity(record.getId(), Address.fromSerialized(e.getE164Number()), e.getIdentityKey()); database.addMismatchedIdentity(record.getId(), Address.fromSerialized(e.getE164Number()), e.getIdentityKey());
database.markAsSentFailed(record.getId()); database.markAsSentFailed(record.getId());
database.markAsPush(record.getId()); database.markAsPush(record.getId());
@ -158,7 +156,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
Optional<byte[]> profileKey = getProfileKey(message.getIndividualRecipient()); Optional<byte[]> profileKey = getProfileKey(message.getIndividualRecipient());
Optional<UnidentifiedAccessPair> unidentifiedAccess = UnidentifiedAccessUtil.getAccessFor(context, 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() SignalServiceDataMessage textSecureMessage = SignalServiceDataMessage.newBuilder()
.withTimestamp(message.getDateSent()) .withTimestamp(message.getDateSent())
@ -170,10 +168,10 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
return messageSender.sendMessage(address, unidentifiedAccess, textSecureMessage).getSuccess().isUnidentified(); return messageSender.sendMessage(address, unidentifiedAccess, textSecureMessage).getSuccess().isUnidentified();
} catch (UnregisteredUserException e) { } catch (UnregisteredUserException e) {
Log.w(TAG, e); warn(TAG, "Failure", e);
throw new InsecureFallbackApprovalException(e); throw new InsecureFallbackApprovalException(e);
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, e); warn(TAG, "Failure", e);
throw new RetryLaterException(e); throw new RetryLaterException(e);
} }
} }

View File

@ -24,7 +24,7 @@ public class RotateCertificateJob extends ContextJob implements InjectableType {
private static final long serialVersionUID = 1L; 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; @Inject transient SignalServiceAccountManager accountManager;

View File

@ -25,7 +25,7 @@ import androidx.work.WorkerParameters;
public class RotateSignedPreKeyJob extends ContextJob implements InjectableType { 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; @Inject transient SignalServiceAccountManager accountManager;

View File

@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.jobs;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.thoughtcrime.securesms.BuildConfig; import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
@ -95,4 +96,20 @@ public abstract class SendJob extends ContextJob {
return results; 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);
}
} }

View File

@ -73,18 +73,17 @@ public class SmsSendJob extends SendJob {
@Override @Override
public void onAdded() { public void onAdded() {
Log.i(TAG, "onAdded() messageId: " + messageId);
} }
@Override @Override
public void onSend() throws NoSuchMessageException, RequirementNotMetException, TooManyRetriesException { public void onSend() throws NoSuchMessageException, RequirementNotMetException, TooManyRetriesException {
if (!requirementsMet()) { if (!requirementsMet()) {
Log.w(TAG, "No service. Retrying."); warn(TAG, "No service. Retrying.");
throw new RequirementNotMetException(); throw new RequirementNotMetException();
} }
if (runAttempt >= MAX_ATTEMPTS) { if (runAttempt >= MAX_ATTEMPTS) {
Log.w(TAG, "Hit the retry limit. Failing."); warn(TAG, "Hit the retry limit. Failing.");
throw new TooManyRetriesException(); throw new TooManyRetriesException();
} }
@ -92,16 +91,16 @@ public class SmsSendJob extends SendJob {
SmsMessageRecord record = database.getMessage(messageId); SmsMessageRecord record = database.getMessage(messageId);
if (!record.isPending() && !record.isFailed()) { if (!record.isPending() && !record.isFailed()) {
Log.w(TAG, "Message " + messageId + " was already sent. Ignoring."); warn(TAG, "Message " + messageId + " was already sent. Ignoring.");
return; return;
} }
try { try {
Log.i(TAG, "Sending message: " + messageId + " (attempt " + runAttempt + ")"); log(TAG, "Sending message: " + messageId + " (attempt " + runAttempt + ")");
deliver(record); deliver(record);
Log.i(TAG, "Sent message: " + messageId); log(TAG, "Sent message: " + messageId);
} catch (UndeliverableMessageException ude) { } catch (UndeliverableMessageException ude) {
Log.w(TAG, ude); warn(TAG, ude);
DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId()); DatabaseFactory.getSmsDatabase(context).markAsSentFailed(record.getId());
MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId()); MessageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
} }
@ -114,7 +113,7 @@ public class SmsSendJob extends SendJob {
@Override @Override
public void onCanceled() { public void onCanceled() {
Log.w(TAG, "onCanceled() messageId: " + messageId); warn(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);
@ -165,9 +164,9 @@ public class SmsSendJob extends SendJob {
try { try {
getSmsManagerFor(message.getSubscriptionId()).sendMultipartTextMessage(recipient, null, messages, sentIntents, deliveredIntents); getSmsManagerFor(message.getSubscriptionId()).sendMultipartTextMessage(recipient, null, messages, sentIntents, deliveredIntents);
} catch (NullPointerException | IllegalArgumentException npe) { } catch (NullPointerException | IllegalArgumentException npe) {
Log.w(TAG, npe); warn(TAG, npe);
Log.i(TAG, "Recipient: " + recipient); log(TAG, "Recipient: " + recipient);
Log.i(TAG, "Message Parts: " + messages.size()); log(TAG, "Message Parts: " + messages.size());
try { try {
for (int i=0;i<messages.size();i++) { for (int i=0;i<messages.size();i++) {
@ -176,11 +175,11 @@ public class SmsSendJob extends SendJob {
deliveredIntents == null ? null : deliveredIntents.get(i)); deliveredIntents == null ? null : deliveredIntents.get(i));
} }
} catch (NullPointerException | IllegalArgumentException npe2) { } catch (NullPointerException | IllegalArgumentException npe2) {
Log.w(TAG, npe); warn(TAG, npe);
throw new UndeliverableMessageException(npe2); throw new UndeliverableMessageException(npe2);
} }
} catch (SecurityException se) { } catch (SecurityException se) {
Log.w(TAG, se); warn(TAG, se);
throw new UndeliverableMessageException(se); throw new UndeliverableMessageException(se);
} }
} }

View File

@ -17,8 +17,6 @@
package org.thoughtcrime.securesms.logsubmit.util; package org.thoughtcrime.securesms.logsubmit.util;
import org.thoughtcrime.securesms.logging.Log;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -43,7 +41,6 @@ public class Scrubber {
} }
public String scrub(final String in) { public String scrub(final String in) {
android.util.Log.d(TAG, "scrubbing input");
String out = in; String out = in;
for (Pattern pattern : patterns) { for (Pattern pattern : patterns) {
Matcher matcher = pattern.matcher(out); Matcher matcher = pattern.matcher(out);
@ -59,7 +56,6 @@ public class Scrubber {
builder.append(censored); builder.append(censored);
lastEndingPos = matcher.end(); lastEndingPos = matcher.end();
android.util.Log.i(TAG, "replacing a match on /" + pattern.toString() + "/ => " + censored);
} }
builder.append(out.substring(lastEndingPos)); builder.append(out.substring(lastEndingPos));
out = builder.toString(); out = builder.toString();

View File

@ -18,6 +18,7 @@ package org.thoughtcrime.securesms.notifications;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.AlarmManager; import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@ -288,8 +289,11 @@ public class MessageNotifier {
@NonNull NotificationState notificationState, @NonNull NotificationState notificationState,
boolean signal, boolean bundled) boolean signal, boolean bundled)
{ {
Log.i(TAG, "sendSingleThreadNotification() signal: " + signal + " bundled: " + bundled);
if (notificationState.getNotifications().isEmpty()) { if (notificationState.getNotifications().isEmpty()) {
if (!bundled) cancelActiveNotifications(context); if (!bundled) cancelActiveNotifications(context);
Log.i(TAG, "Empty notification state. Skipping.");
return; return;
} }
@ -336,13 +340,17 @@ public class MessageNotifier {
builder.setGroupSummary(true); builder.setGroupSummary(true);
} }
NotificationManagerCompat.from(context).notify(notificationId, builder.build()); Notification notification = builder.build();
NotificationManagerCompat.from(context).notify(notificationId, notification);
Log.i(TAG, "Posted notification. " + notification.toString());
} }
private static void sendMultipleThreadNotification(@NonNull Context context, private static void sendMultipleThreadNotification(@NonNull Context context,
@NonNull NotificationState notificationState, @NonNull NotificationState notificationState,
boolean signal) boolean signal)
{ {
Log.i(TAG, "sendSingleThreadNotification() signal: " + signal);
MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context)); MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
List<NotificationItem> notifications = notificationState.getNotifications(); List<NotificationItem> notifications = notificationState.getNotifications();
@ -371,7 +379,9 @@ public class MessageNotifier {
notifications.get(0).getText()); notifications.get(0).getText());
} }
Notification notification = builder.build();
NotificationManagerCompat.from(context).notify(SUMMARY_NOTIFICATION_ID, builder.build()); NotificationManagerCompat.from(context).notify(SUMMARY_NOTIFICATION_ID, builder.build());
Log.i(TAG, "Posted notification. " + notification.toString());
} }
private static void sendInThreadNotification(Context context, Recipient recipient) { private static void sendInThreadNotification(Context context, Recipient recipient) {

View File

@ -12,7 +12,7 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager;
public class AccountManagerFactory { public class AccountManagerFactory {
private static final String TAG = AccountManagerFactory.class.getName(); private static final String TAG = AccountManagerFactory.class.getSimpleName();
public static SignalServiceAccountManager createManager(Context context) { public static SignalServiceAccountManager createManager(Context context) {
return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(context), return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(context),

View File

@ -22,7 +22,7 @@ import okhttp3.TlsVersion;
public class SignalServiceNetworkAccess { public class SignalServiceNetworkAccess {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final String TAG = SignalServiceNetworkAccess.class.getName(); private static final String TAG = SignalServiceNetworkAccess.class.getSimpleName();
private static final String COUNTRY_CODE_EGYPT = "+20"; private static final String COUNTRY_CODE_EGYPT = "+20";
private static final String COUNTRY_CODE_UAE = "+971"; private static final String COUNTRY_CODE_UAE = "+971";

View File

@ -20,7 +20,7 @@ import org.whispersystems.libsignal.util.guava.Optional;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class ScribbleActivity extends PassphraseRequiredActionBarActivity implements ScribbleFragment.Controller { public class ScribbleActivity extends PassphraseRequiredActionBarActivity implements ScribbleFragment.Controller {
private static final String TAG = ScribbleActivity.class.getName(); private static final String TAG = ScribbleActivity.class.getSimpleName();
public static final int SCRIBBLE_REQUEST_CODE = 31424; public static final int SCRIBBLE_REQUEST_CODE = 31424;

View File

@ -48,7 +48,7 @@ import static android.app.Activity.RESULT_OK;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public class ScribbleFragment extends Fragment implements ScribbleHud.EventListener, VerticalSlideColorPicker.OnColorChangeListener { public class ScribbleFragment extends Fragment implements ScribbleHud.EventListener, VerticalSlideColorPicker.OnColorChangeListener {
private static final String TAG = ScribbleFragment.class.getName(); private static final String TAG = ScribbleFragment.class.getSimpleName();
private static final String KEY_IMAGE_URI = "image_uri"; private static final String KEY_IMAGE_URI = "image_uri";
private static final String KEY_LOCALE = "locale"; private static final String KEY_LOCALE = "locale";

View File

@ -27,7 +27,7 @@ import java.io.IOException;
class StickerLoader extends AsyncLoader<String[]> { class StickerLoader extends AsyncLoader<String[]> {
private static final String TAG = StickerLoader.class.getName(); private static final String TAG = StickerLoader.class.getSimpleName();
private final String assetDirectory; private final String assetDirectory;

View File

@ -37,7 +37,7 @@ import org.thoughtcrime.securesms.R;
public class StickerSelectActivity extends FragmentActivity implements StickerSelectFragment.StickerSelectionListener { public class StickerSelectActivity extends FragmentActivity implements StickerSelectFragment.StickerSelectionListener {
private static final String TAG = StickerSelectActivity.class.getName(); private static final String TAG = StickerSelectActivity.class.getSimpleName();
public static final String EXTRA_STICKER_FILE = "extra_sticker_file"; public static final String EXTRA_STICKER_FILE = "extra_sticker_file";

View File

@ -25,7 +25,7 @@ import android.view.MotionEvent;
*/ */
public class RotateGestureDetector extends TwoFingerGestureDetector { public class RotateGestureDetector extends TwoFingerGestureDetector {
private static final String TAG = RotateGestureDetector.class.getName(); private static final String TAG = RotateGestureDetector.class.getSimpleName();
private final OnRotateGestureListener mListener; private final OnRotateGestureListener mListener;
private boolean mSloppyGesture; private boolean mSloppyGesture;

View File

@ -19,7 +19,7 @@ import java.util.Map;
*/ */
public class StickyHeaderDecoration extends RecyclerView.ItemDecoration { public class StickyHeaderDecoration extends RecyclerView.ItemDecoration {
private static final String TAG = StickyHeaderDecoration.class.getName(); private static final String TAG = StickyHeaderDecoration.class.getSimpleName();
private static final long NO_HEADER_ID = -1L; private static final long NO_HEADER_ID = -1L;

View File

@ -66,7 +66,7 @@ import java.io.IOException;
public class VideoPlayer extends FrameLayout { public class VideoPlayer extends FrameLayout {
private static final String TAG = VideoPlayer.class.getName(); private static final String TAG = VideoPlayer.class.getSimpleName();
@Nullable private final VideoView videoView; @Nullable private final VideoView videoView;
@Nullable private final PlayerView exoView; @Nullable private final PlayerView exoView;

View File

@ -22,7 +22,7 @@ import java.lang.reflect.Method;
*/ */
public class IncomingPstnCallReceiver extends BroadcastReceiver { public class IncomingPstnCallReceiver extends BroadcastReceiver {
private static final String TAG = IncomingPstnCallReceiver.class.getName(); private static final String TAG = IncomingPstnCallReceiver.class.getSimpleName();
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {