Fix cases of inlined & missing log tags.

This commit is contained in:
Alan Evans 2020-05-11 11:03:42 -03:00 committed by Alex Hart
parent 3db5da1c8d
commit 06ab3cf013
18 changed files with 52 additions and 40 deletions

View File

@ -20,7 +20,7 @@
<!-- Custom lints --> <!-- Custom lints -->
<issue id="LogNotSignal" severity="error" /> <issue id="LogNotSignal" severity="error" />
<issue id="LogNotAppSignal" severity="error" /> <issue id="LogNotAppSignal" severity="error" />
<issue id="LogTagInlined" severity="warning" /> <issue id="LogTagInlined" severity="error" />
<issue id="RestrictedApi" severity="error"> <issue id="RestrictedApi" severity="error">
<ignore path="*/org/thoughtcrime/securesms/mediasend/camerax/VideoCapture.java" /> <ignore path="*/org/thoughtcrime/securesms/mediasend/camerax/VideoCapture.java" />

View File

@ -41,6 +41,8 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
public class PassphraseChangeActivity extends PassphraseActivity { public class PassphraseChangeActivity extends PassphraseActivity {
private static final String TAG = Log.tag(PassphraseChangeActivity.class);
private DynamicTheme dynamicTheme = new DynamicTheme(); private DynamicTheme dynamicTheme = new DynamicTheme();
private DynamicLanguage dynamicLanguage = new DynamicLanguage(); private DynamicLanguage dynamicLanguage = new DynamicLanguage();
@ -145,7 +147,7 @@ public class PassphraseChangeActivity extends PassphraseActivity {
return masterSecret; return masterSecret;
} catch (InvalidPassphraseException e) { } catch (InvalidPassphraseException e) {
Log.w(PassphraseChangeActivity.class.getSimpleName(), e); Log.w(TAG, e);
return null; return null;
} }
} }

View File

@ -119,7 +119,7 @@ public class MasterCipher {
return encryptedAndMacBody; return encryptedAndMacBody;
} catch (GeneralSecurityException ge) { } catch (GeneralSecurityException ge) {
Log.w("bodycipher", ge); Log.w(TAG, "bodycipher", ge);
return null; return null;
} }

View File

@ -56,6 +56,8 @@ import javax.crypto.spec.SecretKeySpec;
public class MasterSecretUtil { public class MasterSecretUtil {
private static final String TAG = Log.tag(MasterSecretUtil.class);
public static final String UNENCRYPTED_PASSPHRASE = "unencrypted"; public static final String UNENCRYPTED_PASSPHRASE = "unencrypted";
public static final String PREFERENCES_NAME = "SecureSMS-Preferences"; public static final String PREFERENCES_NAME = "SecureSMS-Preferences";
@ -115,10 +117,10 @@ public class MasterSecretUtil {
return new MasterSecret(new SecretKeySpec(encryptionSecret, "AES"), return new MasterSecret(new SecretKeySpec(encryptionSecret, "AES"),
new SecretKeySpec(macSecret, "HmacSHA1")); new SecretKeySpec(macSecret, "HmacSHA1"));
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
Log.w("keyutil", e); Log.w(TAG, e);
return null; //XXX return null; //XXX
} catch (IOException e) { } catch (IOException e) {
Log.w("keyutil", e); Log.w(TAG, e);
return null; //XXX return null; //XXX
} }
} }
@ -183,7 +185,7 @@ public class MasterSecretUtil {
return new MasterSecret(new SecretKeySpec(encryptionSecret, "AES"), return new MasterSecret(new SecretKeySpec(encryptionSecret, "AES"),
new SecretKeySpec(macSecret, "HmacSHA1")); new SecretKeySpec(macSecret, "HmacSHA1"));
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
Log.w("keyutil", e); Log.w(TAG, e);
return null; return null;
} }
} }
@ -249,7 +251,7 @@ public class MasterSecretUtil {
SecretKey key = generator.generateKey(); SecretKey key = generator.generateKey();
return key.getEncoded(); return key.getEncoded();
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
Log.w("keyutil", ex); Log.w(TAG, ex);
return null; return null;
} }
} }
@ -259,7 +261,7 @@ public class MasterSecretUtil {
KeyGenerator generator = KeyGenerator.getInstance("HmacSHA1"); KeyGenerator generator = KeyGenerator.getInstance("HmacSHA1");
return generator.generateKey().getEncoded(); return generator.generateKey().getEncoded();
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.w("keyutil", e); Log.w(TAG, e);
return null; return null;
} }
} }
@ -290,10 +292,10 @@ public class MasterSecretUtil {
if (scaledIterationTarget < MINIMUM_ITERATION_COUNT) return MINIMUM_ITERATION_COUNT; if (scaledIterationTarget < MINIMUM_ITERATION_COUNT) return MINIMUM_ITERATION_COUNT;
else return scaledIterationTarget; else return scaledIterationTarget;
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
Log.w("MasterSecretUtil", e); Log.w(TAG, e);
return MINIMUM_ITERATION_COUNT; return MINIMUM_ITERATION_COUNT;
} catch (InvalidKeySpecException e) { } catch (InvalidKeySpecException e) {
Log.w("MasterSecretUtil", e); Log.w(TAG, e);
return MINIMUM_ITERATION_COUNT; return MINIMUM_ITERATION_COUNT;
} }
} }

View File

@ -88,7 +88,7 @@ public class PublicKey {
MessageDigest md = MessageDigest.getInstance("SHA-1"); MessageDigest md = MessageDigest.getInstance("SHA-1");
return md.digest(serialize()); return md.digest(serialize());
} catch (NoSuchAlgorithmException nsae) { } catch (NoSuchAlgorithmException nsae) {
Log.w("LocalKeyPair", nsae); Log.w(TAG, "LocalKeyPair", nsae);
throw new IllegalArgumentException("SHA-1 isn't supported!"); throw new IllegalArgumentException("SHA-1 isn't supported!");
} }
} }

View File

@ -1360,7 +1360,7 @@ public class MmsDatabase extends MessagingDatabase {
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()) {
Log.i("MmsDatabase", "Trimming: " + cursor.getLong(0)); Log.i(TAG, "Trimming: " + cursor.getLong(0));
delete(cursor.getLong(0)); delete(cursor.getLong(0));
} }

View File

@ -153,7 +153,7 @@ public class SmsDatabase extends MessagingDatabase {
} }
private void updateTypeBitmask(long id, long maskOff, long maskOn) { private void updateTypeBitmask(long id, long maskOff, long maskOn) {
Log.i("MessageDatabase", "Updating ID: " + id + " to base type: " + maskOn); Log.i(TAG, "Updating ID: " + id + " to base type: " + maskOn);
SQLiteDatabase db = databaseHelper.getWritableDatabase(); SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_NAME + db.execSQL("UPDATE " + TABLE_NAME +
@ -368,7 +368,7 @@ public class SmsDatabase extends MessagingDatabase {
} }
public void markStatus(long id, int status) { public void markStatus(long id, int status) {
Log.i("MessageDatabase", "Updating ID: " + id + " to status: " + status); Log.i(TAG, "Updating ID: " + id + " to status: " + status);
ContentValues contentValues = new ContentValues(); ContentValues contentValues = new ContentValues();
contentValues.put(STATUS, status); contentValues.put(STATUS, status);
@ -793,7 +793,7 @@ public class SmsDatabase extends MessagingDatabase {
} }
public boolean deleteMessage(long messageId) { public boolean deleteMessage(long messageId) {
Log.i("MessageDatabase", "Deleting: " + messageId); Log.i(TAG, "Deleting: " + messageId);
SQLiteDatabase db = databaseHelper.getWritableDatabase(); SQLiteDatabase db = databaseHelper.getWritableDatabase();
long threadId = getThreadIdForMessage(messageId); long threadId = getThreadIdForMessage(messageId);
db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""}); db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""});

View File

@ -135,7 +135,7 @@ public class SmsMigrator {
return null; return null;
} }
} catch (IllegalStateException iae) { } catch (IllegalStateException iae) {
Log.w("SmsMigrator", iae); Log.w(TAG, iae);
return null; return null;
} finally { } finally {
if (cursor != null) if (cursor != null)

View File

@ -248,19 +248,19 @@ public class ThreadDatabase extends Database {
} }
public void trimThread(long threadId, int length) { public void trimThread(long threadId, int length) {
Log.i("ThreadDatabase", "Trimming thread: " + threadId + " to: " + length); Log.i(TAG, "Trimming thread: " + threadId + " to: " + length);
Cursor cursor = null; Cursor cursor = null;
try { try {
cursor = DatabaseFactory.getMmsSmsDatabase(context).getConversation(threadId); cursor = DatabaseFactory.getMmsSmsDatabase(context).getConversation(threadId);
if (cursor != null && length > 0 && cursor.getCount() > length) { if (cursor != null && length > 0 && cursor.getCount() > length) {
Log.w("ThreadDatabase", "Cursor count is greater than length!"); Log.w(TAG, "Cursor count is greater than length!");
cursor.moveToPosition(length - 1); cursor.moveToPosition(length - 1);
long lastTweetDate = cursor.getLong(cursor.getColumnIndexOrThrow(MmsSmsColumns.NORMALIZED_DATE_RECEIVED)); long lastTweetDate = cursor.getLong(cursor.getColumnIndexOrThrow(MmsSmsColumns.NORMALIZED_DATE_RECEIVED));
Log.i("ThreadDatabase", "Cut off tweet date: " + lastTweetDate); Log.i(TAG, "Cut off tweet date: " + lastTweetDate);
DatabaseFactory.getSmsDatabase(context).deleteMessagesInThreadBeforeDate(threadId, lastTweetDate); DatabaseFactory.getSmsDatabase(context).deleteMessagesInThreadBeforeDate(threadId, lastTweetDate);
DatabaseFactory.getMmsDatabase(context).deleteMessagesInThreadBeforeDate(threadId, lastTweetDate); DatabaseFactory.getMmsDatabase(context).deleteMessagesInThreadBeforeDate(threadId, lastTweetDate);

View File

@ -182,10 +182,10 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
Cursor smsCursor = null; Cursor smsCursor = null;
Log.i("DatabaseFactory", "Upgrade count: " + (smsCount + threadCount)); Log.i(TAG, "Upgrade count: " + (smsCount + threadCount));
do { do {
Log.i("DatabaseFactory", "Looping SMS cursor..."); Log.i(TAG, "Looping SMS cursor...");
if (smsCursor != null) if (smsCursor != null)
smsCursor.close(); smsCursor.close();
@ -224,7 +224,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
new String[] {body, type+"", id+""}); new String[] {body, type+"", id+""});
} }
} catch (InvalidMessageException e) { } catch (InvalidMessageException e) {
Log.w("DatabaseFactory", e); Log.w(TAG, e);
} }
} }
@ -237,7 +237,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
skip = 0; skip = 0;
do { do {
Log.i("DatabaseFactory", "Looping thread cursor..."); Log.i(TAG, "Looping thread cursor...");
if (threadCursor != null) if (threadCursor != null)
threadCursor.close(); threadCursor.close();
@ -281,7 +281,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
new String[] {snippet, snippetType+"", id+""}); new String[] {snippet, snippetType+"", id+""});
} }
} catch (InvalidMessageException e) { } catch (InvalidMessageException e) {
Log.w("DatabaseFactory", e); Log.w(TAG, e);
} }
} }
@ -296,13 +296,13 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
} }
if (fromVersion < LegacyMigrationJob.MMS_BODY_VERSION) { if (fromVersion < LegacyMigrationJob.MMS_BODY_VERSION) {
Log.i("DatabaseFactory", "Update MMS bodies..."); Log.i(TAG, "Update MMS bodies...");
MasterCipher masterCipher = new MasterCipher(masterSecret); MasterCipher masterCipher = new MasterCipher(masterSecret);
Cursor mmsCursor = db.query("mms", new String[] {"_id"}, Cursor mmsCursor = db.query("mms", new String[] {"_id"},
"msg_box & " + 0x80000000L + " != 0", "msg_box & " + 0x80000000L + " != 0",
null, null, null, null); null, null, null, null);
Log.i("DatabaseFactory", "Got MMS rows: " + (mmsCursor == null ? "null" : mmsCursor.getCount())); Log.i(TAG, "Got MMS rows: " + (mmsCursor == null ? "null" : mmsCursor.getCount()));
while (mmsCursor != null && mmsCursor.moveToNext()) { while (mmsCursor != null && mmsCursor.moveToNext()) {
listener.setProgress(mmsCursor.getPosition(), mmsCursor.getCount()); listener.setProgress(mmsCursor.getPosition(), mmsCursor.getCount());
@ -336,7 +336,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
dataFile.delete(); dataFile.delete();
db.delete("part", "_id = ?", new String[] {partId+""}); db.delete("part", "_id = ?", new String[] {partId+""});
} catch (IOException e) { } catch (IOException e) {
Log.w("DatabaseFactory", e); Log.w(TAG, e);
} }
} else if (MediaUtil.isAudioType(contentType) || } else if (MediaUtil.isAudioType(contentType) ||
MediaUtil.isImageType(contentType) || MediaUtil.isImageType(contentType) ||
@ -355,7 +355,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
new String[] {partCount+"", mmsId+""}); new String[] {partCount+"", mmsId+""});
} }
Log.i("DatabaseFactory", "Updated body: " + body + " and part_count: " + partCount); Log.i(TAG, "Updated body: " + body + " and part_count: " + partCount);
} }
} }

View File

@ -102,7 +102,7 @@ public class LegacyMigrationJob extends MigrationJob {
@Override @Override
void performMigration() throws RetryLaterException { void performMigration() throws RetryLaterException {
Log.i("DatabaseUpgradeActivity", "Running background upgrade.."); Log.i(TAG, "Running background upgrade..");
int lastSeenVersion = VersionTracker.getLastSeenVersion(context); int lastSeenVersion = VersionTracker.getLastSeenVersion(context);
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context); MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);

View File

@ -12,6 +12,9 @@ import java.io.UnsupportedEncodingException;
public class PartParser { public class PartParser {
private static final String TAG = Log.tag(PartParser.class);
public static String getMessageText(PduBody body) { public static String getMessageText(PduBody body) {
String bodyText = null; String bodyText = null;
@ -31,7 +34,7 @@ public class PartParser {
partText = ""; partText = "";
} }
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
Log.w("PartParser", e); Log.w(TAG, e);
partText = "Unsupported Encoding!"; partText = "Unsupported Encoding!";
} }

View File

@ -73,11 +73,11 @@ public class AndroidAutoReplyReceiver extends BroadcastReceiver {
long expiresIn = recipient.getExpireMessages() * 1000L; long expiresIn = recipient.getExpireMessages() * 1000L;
if (recipient.resolve().isGroup()) { if (recipient.resolve().isGroup()) {
Log.w("AndroidAutoReplyReceiver", "GroupRecipient, Sending media message"); Log.w(TAG, "GroupRecipient, Sending media message");
OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<>(), System.currentTimeMillis(), subscriptionId, expiresIn, false, 0, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList()); OutgoingMediaMessage reply = new OutgoingMediaMessage(recipient, responseText.toString(), new LinkedList<>(), System.currentTimeMillis(), subscriptionId, expiresIn, false, 0, null, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
replyThreadId = MessageSender.send(context, reply, threadId, false, null); replyThreadId = MessageSender.send(context, reply, threadId, false, null);
} else { } else {
Log.w("AndroidAutoReplyReceiver", "Sending regular message "); Log.w(TAG, "Sending regular message ");
OutgoingTextMessage reply = new OutgoingTextMessage(recipient, responseText.toString(), expiresIn, subscriptionId); OutgoingTextMessage reply = new OutgoingTextMessage(recipient, responseText.toString(), expiresIn, subscriptionId);
replyThreadId = MessageSender.send(context, reply, threadId, false, null); replyThreadId = MessageSender.send(context, reply, threadId, false, null);
} }

View File

@ -639,7 +639,7 @@ public class MessageNotifier {
} catch (Throwable t) { } catch (Throwable t) {
// NOTE :: I don't totally trust this thing, so I'm catching // NOTE :: I don't totally trust this thing, so I'm catching
// everything. // everything.
Log.w("MessageNotifier", t); Log.w(TAG, t);
} }
} }

View File

@ -87,7 +87,7 @@ public class KeyCachingService extends Service {
try { try {
return MasterSecretUtil.getMasterSecret(context, MasterSecretUtil.UNENCRYPTED_PASSPHRASE); return MasterSecretUtil.getMasterSecret(context, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
} catch (InvalidPassphraseException e) { } catch (InvalidPassphraseException e) {
Log.w("KeyCachingService", e); Log.w(TAG, e);
} }
} }
@ -151,7 +151,7 @@ public class KeyCachingService extends Service {
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, MasterSecretUtil.UNENCRYPTED_PASSPHRASE); MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
setMasterSecret(masterSecret); setMasterSecret(masterSecret);
} catch (InvalidPassphraseException e) { } catch (InvalidPassphraseException e) {
Log.w("KeyCachingService", e); Log.w(TAG, e);
} }
} }
} }

View File

@ -32,6 +32,8 @@ import org.thoughtcrime.securesms.util.Util;
public class SmsListener extends BroadcastReceiver { public class SmsListener extends BroadcastReceiver {
private static final String TAG = Log.tag(SmsListener.class);
private static final String SMS_RECEIVED_ACTION = Telephony.Sms.Intents.SMS_RECEIVED_ACTION; private static final String SMS_RECEIVED_ACTION = Telephony.Sms.Intents.SMS_RECEIVED_ACTION;
private static final String SMS_DELIVERED_ACTION = Telephony.Sms.Intents.SMS_DELIVER_ACTION; private static final String SMS_DELIVERED_ACTION = Telephony.Sms.Intents.SMS_DELIVER_ACTION;
@ -98,12 +100,12 @@ public class SmsListener extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.i("SMSListener", "Got SMS broadcast..."); Log.i(TAG, "Got SMS broadcast...");
if ((intent.getAction().equals(SMS_DELIVERED_ACTION)) || if ((intent.getAction().equals(SMS_DELIVERED_ACTION)) ||
(intent.getAction().equals(SMS_RECEIVED_ACTION)) && isRelevant(context, intent)) (intent.getAction().equals(SMS_RECEIVED_ACTION)) && isRelevant(context, intent))
{ {
Log.i("SmsListener", "Constructing SmsReceiveJob..."); Log.i(TAG, "Constructing SmsReceiveJob...");
Object[] pdus = (Object[]) intent.getExtras().get("pdus"); Object[] pdus = (Object[]) intent.getExtras().get("pdus");
int subscriptionId = intent.getExtras().getInt("subscription", -1); int subscriptionId = intent.getExtras().getInt("subscription", -1);

View File

@ -504,7 +504,7 @@ public class MessageSender {
expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn()); expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
} }
} catch (NoSuchMessageException | MmsException e) { } catch (NoSuchMessageException | MmsException e) {
Log.w("Failed to update self-sent message.", e); Log.w(TAG, "Failed to update self-sent message.", e);
} }
} }
@ -527,7 +527,7 @@ public class MessageSender {
expirationManager.scheduleDeletion(message.getId(), message.isMms(), message.getExpiresIn()); expirationManager.scheduleDeletion(message.getId(), message.isMms(), message.getExpiresIn());
} }
} catch (NoSuchMessageException e) { } catch (NoSuchMessageException e) {
Log.w("Failed to update self-sent message.", e); Log.w(TAG, "Failed to update self-sent message.", e);
} }
} }

View File

@ -12,6 +12,9 @@ import java.util.List;
* Errors in one handler do not prevent subsequent handlers from being called. * Errors in one handler do not prevent subsequent handlers from being called.
*/ */
public class UncaughtExceptionHandlerManager implements Thread.UncaughtExceptionHandler { public class UncaughtExceptionHandlerManager implements Thread.UncaughtExceptionHandler {
private static final String TAG = Log.tag(UncaughtExceptionHandlerManager.class);
private final Thread.UncaughtExceptionHandler originalHandler; private final Thread.UncaughtExceptionHandler originalHandler;
private final List<Thread.UncaughtExceptionHandler> handlers = new ArrayList<Thread.UncaughtExceptionHandler>(); private final List<Thread.UncaughtExceptionHandler> handlers = new ArrayList<Thread.UncaughtExceptionHandler>();
@ -35,7 +38,7 @@ public class UncaughtExceptionHandlerManager implements Thread.UncaughtException
try { try {
handlers.get(i).uncaughtException(thread, throwable); handlers.get(i).uncaughtException(thread, throwable);
} catch(Throwable t) { } catch(Throwable t) {
Log.e("UncaughtExceptionHandlerManager", "Error in uncaught exception handling", t); Log.e(TAG, "Error in uncaught exception handling", t);
} }
} }
} }