From bfdad2f47c916ddf46679bb0711810709fbe1fe6 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Thu, 6 Dec 2018 12:14:20 -0800 Subject: [PATCH] Updated logging. --- .../securesms/ConversationAdapter.java | 9 +++---- .../securesms/components/ComposeText.java | 2 +- .../components/RecentPhotoViewRail.java | 2 +- .../components/ThreadPhotoRailView.java | 2 +- .../components/ZoomingImageView.java | 2 +- .../subsampling/AttachmentRegionDecoder.java | 2 +- .../securesms/crypto/PreKeyUtil.java | 2 +- .../crypto/UnidentifiedAccessUtil.java | 6 ++--- .../securesms/database/MmsDatabase.java | 1 - .../securesms/database/MmsSmsDatabase.java | 1 - .../securesms/giph/net/GiphyLoader.java | 2 +- .../securesms/glide/OkHttpStreamFetcher.java | 2 +- .../securesms/jobmanager/Job.java | 5 ++-- .../securesms/jobs/PushGroupSendJob.java | 9 +++---- .../securesms/jobs/PushMediaSendJob.java | 23 ++++++++--------- .../securesms/jobs/PushSendJob.java | 3 --- .../securesms/jobs/PushTextSendJob.java | 24 ++++++++---------- .../securesms/jobs/RotateCertificateJob.java | 2 +- .../securesms/jobs/RotateSignedPreKeyJob.java | 2 +- .../thoughtcrime/securesms/jobs/SendJob.java | 17 +++++++++++++ .../securesms/jobs/SmsSendJob.java | 25 +++++++++---------- .../securesms/logsubmit/util/Scrubber.java | 4 --- .../notifications/MessageNotifier.java | 12 ++++++++- .../securesms/push/AccountManagerFactory.java | 2 +- .../push/SignalServiceNetworkAccess.java | 2 +- .../securesms/scribbles/ScribbleActivity.java | 2 +- .../securesms/scribbles/ScribbleFragment.java | 2 +- .../securesms/scribbles/StickerLoader.java | 2 +- .../scribbles/StickerSelectActivity.java | 2 +- .../multitouch/RotateGestureDetector.java | 2 +- .../util/StickyHeaderDecoration.java | 2 +- .../securesms/video/VideoPlayer.java | 2 +- .../webrtc/IncomingPstnCallReceiver.java | 2 +- 33 files changed, 94 insertions(+), 85 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationAdapter.java b/src/org/thoughtcrime/securesms/ConversationAdapter.java index 93da2ca23a..2c4d25d982 100644 --- a/src/org/thoughtcrime/securesms/ConversationAdapter.java +++ b/src/org/thoughtcrime/securesms/ConversationAdapter.java @@ -191,10 +191,9 @@ public class ConversationAdapter @Override protected void onBindItemViewHolder(ViewHolder viewHolder, @NonNull MessageRecord messageRecord) { - long start = System.currentTimeMillis(); - int adapterPosition = viewHolder.getAdapterPosition(); - MessageRecord previousRecord = adapterPosition < getItemCount() - 1 && !isFooterPosition(adapterPosition + 1) ? getRecordForPositionOrThrow(adapterPosition + 1) : null; - MessageRecord nextRecord = adapterPosition > 0 && !isHeaderPosition(adapterPosition - 1) ? getRecordForPositionOrThrow(adapterPosition - 1) : null; + int adapterPosition = viewHolder.getAdapterPosition(); + MessageRecord previousRecord = adapterPosition < getItemCount() - 1 && !isFooterPosition(adapterPosition + 1) ? getRecordForPositionOrThrow(adapterPosition + 1) : null; + MessageRecord nextRecord = adapterPosition > 0 && !isHeaderPosition(adapterPosition - 1) ? getRecordForPositionOrThrow(adapterPosition - 1) : null; viewHolder.getView().bind(messageRecord, Optional.fromNullable(previousRecord), @@ -208,8 +207,6 @@ public class ConversationAdapter if (messageRecord == recordToPulseHighlight) { recordToPulseHighlight = null; } - - Log.d(TAG, "Bind time: " + (System.currentTimeMillis() - start)); } @Override diff --git a/src/org/thoughtcrime/securesms/components/ComposeText.java b/src/org/thoughtcrime/securesms/components/ComposeText.java index 44ac4b148c..bcef821698 100644 --- a/src/org/thoughtcrime/securesms/components/ComposeText.java +++ b/src/org/thoughtcrime/securesms/components/ComposeText.java @@ -159,7 +159,7 @@ public class ComposeText extends EmojiEditText { @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB_MR2) 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; diff --git a/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java b/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java index 96c7c44b25..e2064f2e0c 100644 --- a/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java +++ b/src/org/thoughtcrime/securesms/components/RecentPhotoViewRail.java @@ -79,7 +79,7 @@ public class RecentPhotoViewRail extends FrameLayout implements LoaderManager.Lo private static class RecentPhotoAdapter extends CursorRecyclerViewAdapter { @SuppressWarnings("unused") - private static final String TAG = RecentPhotoAdapter.class.getName(); + private static final String TAG = RecentPhotoAdapter.class.getSimpleName(); @NonNull private final Uri baseUri; @Nullable private OnItemClickedListener clickedListener; diff --git a/src/org/thoughtcrime/securesms/components/ThreadPhotoRailView.java b/src/org/thoughtcrime/securesms/components/ThreadPhotoRailView.java index a69f77bb4c..37aee0527d 100644 --- a/src/org/thoughtcrime/securesms/components/ThreadPhotoRailView.java +++ b/src/org/thoughtcrime/securesms/components/ThreadPhotoRailView.java @@ -61,7 +61,7 @@ public class ThreadPhotoRailView extends FrameLayout { private static class ThreadPhotoRailAdapter extends CursorRecyclerViewAdapter { @SuppressWarnings("unused") - private static final String TAG = ThreadPhotoRailAdapter.class.getName(); + private static final String TAG = ThreadPhotoRailAdapter.class.getSimpleName(); @NonNull private final GlideRequests glideRequests; diff --git a/src/org/thoughtcrime/securesms/components/ZoomingImageView.java b/src/org/thoughtcrime/securesms/components/ZoomingImageView.java index 5d7844a5e8..6733433e4b 100644 --- a/src/org/thoughtcrime/securesms/components/ZoomingImageView.java +++ b/src/org/thoughtcrime/securesms/components/ZoomingImageView.java @@ -35,7 +35,7 @@ import java.io.InputStream; 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 SubsamplingScaleImageView subsamplingImageView; diff --git a/src/org/thoughtcrime/securesms/components/subsampling/AttachmentRegionDecoder.java b/src/org/thoughtcrime/securesms/components/subsampling/AttachmentRegionDecoder.java index 3d2a727f20..f8aa5db6cf 100644 --- a/src/org/thoughtcrime/securesms/components/subsampling/AttachmentRegionDecoder.java +++ b/src/org/thoughtcrime/securesms/components/subsampling/AttachmentRegionDecoder.java @@ -19,7 +19,7 @@ import java.io.InputStream; public class AttachmentRegionDecoder implements ImageRegionDecoder { - private static final String TAG = AttachmentRegionDecoder.class.getName(); + private static final String TAG = AttachmentRegionDecoder.class.getSimpleName(); private SkiaImageRegionDecoder passthrough; diff --git a/src/org/thoughtcrime/securesms/crypto/PreKeyUtil.java b/src/org/thoughtcrime/securesms/crypto/PreKeyUtil.java index fd6ef67a29..4644701b62 100644 --- a/src/org/thoughtcrime/securesms/crypto/PreKeyUtil.java +++ b/src/org/thoughtcrime/securesms/crypto/PreKeyUtil.java @@ -37,7 +37,7 @@ import java.util.List; public class PreKeyUtil { @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; diff --git a/src/org/thoughtcrime/securesms/crypto/UnidentifiedAccessUtil.java b/src/org/thoughtcrime/securesms/crypto/UnidentifiedAccessUtil.java index b352f5b239..4e030f4433 100644 --- a/src/org/thoughtcrime/securesms/crypto/UnidentifiedAccessUtil.java +++ b/src/org/thoughtcrime/securesms/crypto/UnidentifiedAccessUtil.java @@ -54,9 +54,9 @@ public class UnidentifiedAccessUtil { ourUnidentifiedAccessKey = Util.getSecretBytes(16); } - Log.i(TAG, "Their access key present? " + (theirUnidentifiedAccessKey != null)); - Log.i(TAG, "Our access key present? " + (ourUnidentifiedAccessKey != null)); - Log.i(TAG, "Our certificate present? " + (ourUnidentifiedAccessCertificate != null)); + Log.i(TAG, "Their access key present? " + (theirUnidentifiedAccessKey != null) + + " | Our access key present? " + (ourUnidentifiedAccessKey != null) + + " | Our certificate present? " + (ourUnidentifiedAccessCertificate != null)); if (theirUnidentifiedAccessKey != null && ourUnidentifiedAccessKey != null && diff --git a/src/org/thoughtcrime/securesms/database/MmsDatabase.java b/src/org/thoughtcrime/securesms/database/MmsDatabase.java index 961a1316f5..4be3313b7a 100644 --- a/src/org/thoughtcrime/securesms/database/MmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/MmsDatabase.java @@ -1103,7 +1103,6 @@ public class MmsDatabase extends MessagingDatabase { 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); while (cursor != null && cursor.moveToNext()) { diff --git a/src/org/thoughtcrime/securesms/database/MmsSmsDatabase.java b/src/org/thoughtcrime/securesms/database/MmsSmsDatabase.java index 2ce3cd079b..f230bb77f2 100644 --- a/src/org/thoughtcrime/securesms/database/MmsSmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/MmsSmsDatabase.java @@ -374,7 +374,6 @@ public class MmsSmsDatabase extends Database { @SuppressWarnings("deprecation") String query = outerQueryBuilder.buildQuery(projection, null, null, null, null, null, null); - Log.d(TAG, "Executing query: " + query); SQLiteDatabase db = databaseHelper.getReadableDatabase(); return db.rawQuery(query, null); } diff --git a/src/org/thoughtcrime/securesms/giph/net/GiphyLoader.java b/src/org/thoughtcrime/securesms/giph/net/GiphyLoader.java index 49a1933888..d116e159e2 100644 --- a/src/org/thoughtcrime/securesms/giph/net/GiphyLoader.java +++ b/src/org/thoughtcrime/securesms/giph/net/GiphyLoader.java @@ -24,7 +24,7 @@ import okhttp3.Response; public abstract class GiphyLoader extends AsyncLoader> { - private static final String TAG = GiphyLoader.class.getName(); + private static final String TAG = GiphyLoader.class.getSimpleName(); public static int PAGE_SIZE = 100; diff --git a/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java b/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java index 5aeba76521..bd0c334b35 100644 --- a/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java +++ b/src/org/thoughtcrime/securesms/glide/OkHttpStreamFetcher.java @@ -22,7 +22,7 @@ import okhttp3.ResponseBody; */ class OkHttpStreamFetcher implements DataFetcher { - private static final String TAG = OkHttpStreamFetcher.class.getName(); + private static final String TAG = OkHttpStreamFetcher.class.getSimpleName(); private final OkHttpClient client; private final GlideUrl url; diff --git a/src/org/thoughtcrime/securesms/jobmanager/Job.java b/src/org/thoughtcrime/securesms/jobmanager/Job.java index 01590a804b..058cbe5d10 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/Job.java +++ b/src/org/thoughtcrime/securesms/jobmanager/Job.java @@ -129,7 +129,7 @@ public abstract class Job extends Worker implements Serializable { } 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) { ((ContextDependent) this).setContext(context); @@ -257,9 +257,8 @@ public abstract class Job extends Worker implements Serializable { return "[" + id + "] " + getClass().getSimpleName() + " :: " + message; } - private String logSuffix() { + protected String logSuffix() { long timeSinceSubmission = System.currentTimeMillis() - getInputData().getLong(KEY_SUBMIT_TIME, 0); return " (Time since submission: " + timeSinceSubmission + " ms, Run attempt: " + getRunAttemptCount() + ", isStopped: " + isStopped() + ")"; } - } diff --git a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index 4af6a08def..ae77be102e 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -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 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
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); } diff --git a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java index e7f728e646..b6dbda6c75 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushMediaSendJob.java @@ -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); } } diff --git a/src/org/thoughtcrime/securesms/jobs/PushSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushSendJob.java index c4f0ee6ced..9bc4b0a3f5 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushSendJob.java @@ -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 diff --git a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java index 87fe6921a2..7a894f8cfb 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushTextSendJob.java @@ -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 profileKey = getProfileKey(message.getIndividualRecipient()); Optional 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); } } diff --git a/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java b/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java index 0672115e48..9592b08a6e 100644 --- a/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RotateCertificateJob.java @@ -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; diff --git a/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java b/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java index 553952d197..9db70110af 100644 --- a/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RotateSignedPreKeyJob.java @@ -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; diff --git a/src/org/thoughtcrime/securesms/jobs/SendJob.java b/src/org/thoughtcrime/securesms/jobs/SendJob.java index 2cbfa5d591..c295dbf3e4 100644 --- a/src/org/thoughtcrime/securesms/jobs/SendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SendJob.java @@ -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); + } } diff --git a/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java b/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java index 0548cdec26..90fa3dbd12 100644 --- a/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SmsSendJob.java @@ -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 " + censored); } builder.append(out.substring(lastEndingPos)); out = builder.toString(); diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index 78aa430380..048a58ca4b 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -18,6 +18,7 @@ package org.thoughtcrime.securesms.notifications; import android.annotation.SuppressLint; import android.app.AlarmManager; +import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; @@ -288,8 +289,11 @@ public class MessageNotifier { @NonNull NotificationState notificationState, boolean signal, boolean bundled) { + Log.i(TAG, "sendSingleThreadNotification() signal: " + signal + " bundled: " + bundled); + if (notificationState.getNotifications().isEmpty()) { if (!bundled) cancelActiveNotifications(context); + Log.i(TAG, "Empty notification state. Skipping."); return; } @@ -336,13 +340,17 @@ public class MessageNotifier { 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, @NonNull NotificationState notificationState, boolean signal) { + Log.i(TAG, "sendSingleThreadNotification() signal: " + signal); + MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context)); List notifications = notificationState.getNotifications(); @@ -371,7 +379,9 @@ public class MessageNotifier { notifications.get(0).getText()); } + Notification notification = 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) { diff --git a/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java b/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java index a058f8e6f2..befaf11796 100644 --- a/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java +++ b/src/org/thoughtcrime/securesms/push/AccountManagerFactory.java @@ -12,7 +12,7 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager; 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) { return new SignalServiceAccountManager(new SignalServiceNetworkAccess(context).getConfiguration(context), diff --git a/src/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java b/src/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java index 4755ae0faf..ad97b96da9 100644 --- a/src/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java +++ b/src/org/thoughtcrime/securesms/push/SignalServiceNetworkAccess.java @@ -22,7 +22,7 @@ import okhttp3.TlsVersion; public class SignalServiceNetworkAccess { @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_UAE = "+971"; diff --git a/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java b/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java index 9eb532eee2..a845ea7645 100644 --- a/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java +++ b/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java @@ -20,7 +20,7 @@ import org.whispersystems.libsignal.util.guava.Optional; @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 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; diff --git a/src/org/thoughtcrime/securesms/scribbles/ScribbleFragment.java b/src/org/thoughtcrime/securesms/scribbles/ScribbleFragment.java index cbd5666dcc..2699d9c405 100644 --- a/src/org/thoughtcrime/securesms/scribbles/ScribbleFragment.java +++ b/src/org/thoughtcrime/securesms/scribbles/ScribbleFragment.java @@ -48,7 +48,7 @@ import static android.app.Activity.RESULT_OK; @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 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_LOCALE = "locale"; diff --git a/src/org/thoughtcrime/securesms/scribbles/StickerLoader.java b/src/org/thoughtcrime/securesms/scribbles/StickerLoader.java index 664183b0e2..d1dd09c56f 100644 --- a/src/org/thoughtcrime/securesms/scribbles/StickerLoader.java +++ b/src/org/thoughtcrime/securesms/scribbles/StickerLoader.java @@ -27,7 +27,7 @@ import java.io.IOException; class StickerLoader extends AsyncLoader { - private static final String TAG = StickerLoader.class.getName(); + private static final String TAG = StickerLoader.class.getSimpleName(); private final String assetDirectory; diff --git a/src/org/thoughtcrime/securesms/scribbles/StickerSelectActivity.java b/src/org/thoughtcrime/securesms/scribbles/StickerSelectActivity.java index bb37dcfa6c..1f4f8c2412 100644 --- a/src/org/thoughtcrime/securesms/scribbles/StickerSelectActivity.java +++ b/src/org/thoughtcrime/securesms/scribbles/StickerSelectActivity.java @@ -37,7 +37,7 @@ import org.thoughtcrime.securesms.R; 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"; diff --git a/src/org/thoughtcrime/securesms/scribbles/multitouch/RotateGestureDetector.java b/src/org/thoughtcrime/securesms/scribbles/multitouch/RotateGestureDetector.java index 839f7b658b..2032af2e5e 100644 --- a/src/org/thoughtcrime/securesms/scribbles/multitouch/RotateGestureDetector.java +++ b/src/org/thoughtcrime/securesms/scribbles/multitouch/RotateGestureDetector.java @@ -25,7 +25,7 @@ import android.view.MotionEvent; */ 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 boolean mSloppyGesture; diff --git a/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java b/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java index f18cdc5ceb..920aee7bd7 100644 --- a/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java +++ b/src/org/thoughtcrime/securesms/util/StickyHeaderDecoration.java @@ -19,7 +19,7 @@ import java.util.Map; */ 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; diff --git a/src/org/thoughtcrime/securesms/video/VideoPlayer.java b/src/org/thoughtcrime/securesms/video/VideoPlayer.java index bf6b59a7d5..2d532171dd 100644 --- a/src/org/thoughtcrime/securesms/video/VideoPlayer.java +++ b/src/org/thoughtcrime/securesms/video/VideoPlayer.java @@ -66,7 +66,7 @@ import java.io.IOException; 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 PlayerView exoView; diff --git a/src/org/thoughtcrime/securesms/webrtc/IncomingPstnCallReceiver.java b/src/org/thoughtcrime/securesms/webrtc/IncomingPstnCallReceiver.java index c5819f0979..03cfa757be 100644 --- a/src/org/thoughtcrime/securesms/webrtc/IncomingPstnCallReceiver.java +++ b/src/org/thoughtcrime/securesms/webrtc/IncomingPstnCallReceiver.java @@ -22,7 +22,7 @@ import java.lang.reflect.Method; */ public class IncomingPstnCallReceiver extends BroadcastReceiver { - private static final String TAG = IncomingPstnCallReceiver.class.getName(); + private static final String TAG = IncomingPstnCallReceiver.class.getSimpleName(); @Override public void onReceive(Context context, Intent intent) {