Fix cases of inlined & missing log tags.

master
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 -->
<issue id="LogNotSignal" severity="error" />
<issue id="LogNotAppSignal" severity="error" />
<issue id="LogTagInlined" severity="warning" />
<issue id="LogTagInlined" severity="error" />
<issue id="RestrictedApi" severity="error">
<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 {
private static final String TAG = Log.tag(PassphraseChangeActivity.class);
private DynamicTheme dynamicTheme = new DynamicTheme();
private DynamicLanguage dynamicLanguage = new DynamicLanguage();
@ -145,7 +147,7 @@ public class PassphraseChangeActivity extends PassphraseActivity {
return masterSecret;
} catch (InvalidPassphraseException e) {
Log.w(PassphraseChangeActivity.class.getSimpleName(), e);
Log.w(TAG, e);
return null;
}
}

View File

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

View File

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

View File

@ -88,7 +88,7 @@ public class PublicKey {
MessageDigest md = MessageDigest.getInstance("SHA-1");
return md.digest(serialize());
} catch (NoSuchAlgorithmException nsae) {
Log.w("LocalKeyPair", nsae);
Log.w(TAG, "LocalKeyPair", nsae);
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);
while (cursor != null && cursor.moveToNext()) {
Log.i("MmsDatabase", "Trimming: " + cursor.getLong(0));
Log.i(TAG, "Trimming: " + 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) {
Log.i("MessageDatabase", "Updating ID: " + id + " to base type: " + maskOn);
Log.i(TAG, "Updating ID: " + id + " to base type: " + maskOn);
SQLiteDatabase db = databaseHelper.getWritableDatabase();
db.execSQL("UPDATE " + TABLE_NAME +
@ -368,7 +368,7 @@ public class SmsDatabase extends MessagingDatabase {
}
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.put(STATUS, status);
@ -793,7 +793,7 @@ public class SmsDatabase extends MessagingDatabase {
}
public boolean deleteMessage(long messageId) {
Log.i("MessageDatabase", "Deleting: " + messageId);
Log.i(TAG, "Deleting: " + messageId);
SQLiteDatabase db = databaseHelper.getWritableDatabase();
long threadId = getThreadIdForMessage(messageId);
db.delete(TABLE_NAME, ID_WHERE, new String[] {messageId+""});

View File

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

View File

@ -248,19 +248,19 @@ public class ThreadDatabase extends Database {
}
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;
try {
cursor = DatabaseFactory.getMmsSmsDatabase(context).getConversation(threadId);
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);
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.getMmsDatabase(context).deleteMessagesInThreadBeforeDate(threadId, lastTweetDate);

View File

@ -182,10 +182,10 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
Cursor smsCursor = null;
Log.i("DatabaseFactory", "Upgrade count: " + (smsCount + threadCount));
Log.i(TAG, "Upgrade count: " + (smsCount + threadCount));
do {
Log.i("DatabaseFactory", "Looping SMS cursor...");
Log.i(TAG, "Looping SMS cursor...");
if (smsCursor != null)
smsCursor.close();
@ -224,7 +224,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
new String[] {body, type+"", id+""});
}
} catch (InvalidMessageException e) {
Log.w("DatabaseFactory", e);
Log.w(TAG, e);
}
}
@ -237,7 +237,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
skip = 0;
do {
Log.i("DatabaseFactory", "Looping thread cursor...");
Log.i(TAG, "Looping thread cursor...");
if (threadCursor != null)
threadCursor.close();
@ -281,7 +281,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
new String[] {snippet, snippetType+"", id+""});
}
} 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) {
Log.i("DatabaseFactory", "Update MMS bodies...");
Log.i(TAG, "Update MMS bodies...");
MasterCipher masterCipher = new MasterCipher(masterSecret);
Cursor mmsCursor = db.query("mms", new String[] {"_id"},
"msg_box & " + 0x80000000L + " != 0",
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()) {
listener.setProgress(mmsCursor.getPosition(), mmsCursor.getCount());
@ -336,7 +336,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
dataFile.delete();
db.delete("part", "_id = ?", new String[] {partId+""});
} catch (IOException e) {
Log.w("DatabaseFactory", e);
Log.w(TAG, e);
}
} else if (MediaUtil.isAudioType(contentType) ||
MediaUtil.isImageType(contentType) ||
@ -355,7 +355,7 @@ public class ClassicOpenHelper extends SQLiteOpenHelper {
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
void performMigration() throws RetryLaterException {
Log.i("DatabaseUpgradeActivity", "Running background upgrade..");
Log.i(TAG, "Running background upgrade..");
int lastSeenVersion = VersionTracker.getLastSeenVersion(context);
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);

View File

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

View File

@ -73,11 +73,11 @@ public class AndroidAutoReplyReceiver extends BroadcastReceiver {
long expiresIn = recipient.getExpireMessages() * 1000L;
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());
replyThreadId = MessageSender.send(context, reply, threadId, false, null);
} else {
Log.w("AndroidAutoReplyReceiver", "Sending regular message ");
Log.w(TAG, "Sending regular message ");
OutgoingTextMessage reply = new OutgoingTextMessage(recipient, responseText.toString(), expiresIn, subscriptionId);
replyThreadId = MessageSender.send(context, reply, threadId, false, null);
}

View File

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

View File

@ -87,7 +87,7 @@ public class KeyCachingService extends Service {
try {
return MasterSecretUtil.getMasterSecret(context, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
} 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);
setMasterSecret(masterSecret);
} 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 {
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_DELIVERED_ACTION = Telephony.Sms.Intents.SMS_DELIVER_ACTION;
@ -98,12 +100,12 @@ public class SmsListener extends BroadcastReceiver {
@Override
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)) ||
(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");
int subscriptionId = intent.getExtras().getInt("subscription", -1);

View File

@ -504,7 +504,7 @@ public class MessageSender {
expirationManager.scheduleDeletion(messageId, true, message.getExpiresIn());
}
} 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());
}
} 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.
*/
public class UncaughtExceptionHandlerManager implements Thread.UncaughtExceptionHandler {
private static final String TAG = Log.tag(UncaughtExceptionHandlerManager.class);
private final Thread.UncaughtExceptionHandler originalHandler;
private final List<Thread.UncaughtExceptionHandler> handlers = new ArrayList<Thread.UncaughtExceptionHandler>();
@ -35,7 +38,7 @@ public class UncaughtExceptionHandlerManager implements Thread.UncaughtException
try {
handlers.get(i).uncaughtException(thread, throwable);
} catch(Throwable t) {
Log.e("UncaughtExceptionHandlerManager", "Error in uncaught exception handling", t);
Log.e(TAG, "Error in uncaught exception handling", t);
}
}
}