Use Timber for all logs

This commit is contained in:
moezbhatti
2019-06-09 23:53:51 -04:00
parent c4a49a73d5
commit e1c26d055c
59 changed files with 505 additions and 858 deletions
@@ -16,7 +16,7 @@
package com.google.android.mms.pdu_alt;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -27,8 +27,6 @@ import java.util.ArrayList;
* Encoded-string-value = Text-string | Value-length Char-set Text-string
*/
public class EncodedStringValue implements Cloneable {
private static final String TAG = "EncodedStringValue";
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
/**
@@ -74,7 +72,7 @@ public class EncodedStringValue implements Cloneable {
mData = data.getBytes(CharacterSets.DEFAULT_CHARSET_NAME);
mCharacterSet = CharacterSets.DEFAULT_CHARSET;
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "Default encoding must be supported.", e);
Timber.e(e, "Default encoding must be supported.");
}
}
@@ -140,7 +138,7 @@ public class EncodedStringValue implements Cloneable {
return new String(mData, name);
} catch (UnsupportedEncodingException e) {
if (LOCAL_LOGV) {
Log.v(TAG, e.getMessage(), e);
Timber.v(e, e.getMessage());
}
try {
return new String(mData, CharacterSets.MIMENAME_ISO_8859_1);
@@ -172,7 +170,7 @@ public class EncodedStringValue implements Cloneable {
newTextString.write(mData);
newTextString.write(textString);
} catch (IOException e) {
Log.e(TAG, "logging error", e);
Timber.e(e, "logging error");
e.printStackTrace();
throw new NullPointerException(
"appendTextString: failed when write a new Text-string");
@@ -196,7 +194,7 @@ public class EncodedStringValue implements Cloneable {
try {
return new EncodedStringValue(mCharacterSet, dstBytes);
} catch (Exception e) {
Log.e(TAG, "logging error", e);
Timber.e(e, "logging error");
e.printStackTrace();
throw new CloneNotSupportedException(e.getMessage());
}
@@ -19,7 +19,7 @@ package com.google.android.mms.pdu_alt;
import android.content.ContentResolver;
import android.content.Context;
import android.text.TextUtils;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
@@ -80,7 +80,6 @@ public class PduComposer {
* Block size when read data from InputStream.
*/
static private final int PDU_COMPOSER_BLOCK_SIZE = 1024;
private static final String TAG = "PduComposer";
/**
* The output message.
@@ -886,7 +885,7 @@ public class PduComposer {
appendTextString(part.getContentType());
}
catch (ArrayIndexOutOfBoundsException e){
Log.e(TAG, "logging error", e);
Timber.e(e, "logging error");
e.printStackTrace();
}
@@ -16,10 +16,9 @@
package com.google.android.mms.pdu_alt;
import com.android.mms.util.ExternalLogger;
import com.google.android.mms.ContentType;
import com.google.android.mms.InvalidHeaderValueException;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -80,8 +79,6 @@ public class PduParser {
/**
* The log tag.
*/
private static final String LOG_TAG = "PduParser";
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
/**
@@ -149,33 +146,33 @@ public class PduParser {
switch (messageType) {
case PduHeaders.MESSAGE_TYPE_SEND_REQ:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_SEND_REQ");
Timber.v("parse: MESSAGE_TYPE_SEND_REQ");
}
SendReq sendReq = new SendReq(mHeaders, mBody);
return sendReq;
case PduHeaders.MESSAGE_TYPE_SEND_CONF:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_SEND_CONF");
Timber.v("parse: MESSAGE_TYPE_SEND_CONF");
}
SendConf sendConf = new SendConf(mHeaders);
return sendConf;
case PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_NOTIFICATION_IND");
Timber.v("parse: MESSAGE_TYPE_NOTIFICATION_IND");
}
NotificationInd notificationInd =
new NotificationInd(mHeaders);
return notificationInd;
case PduHeaders.MESSAGE_TYPE_NOTIFYRESP_IND:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_NOTIFYRESP_IND");
Timber.v("parse: MESSAGE_TYPE_NOTIFYRESP_IND");
}
NotifyRespInd notifyRespInd =
new NotifyRespInd(mHeaders);
return notifyRespInd;
case PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_RETRIEVE_CONF");
Timber.v("parse: MESSAGE_TYPE_RETRIEVE_CONF");
}
RetrieveConf retrieveConf =
new RetrieveConf(mHeaders, mBody);
@@ -203,33 +200,33 @@ public class PduParser {
// multipart/signed
return retrieveConf;
} else {
ExternalLogger.logMessage(LOG_TAG, "Unsupported ContentType: " + ctTypeStr);
Timber.v("Unsupported ContentType: " + ctTypeStr);
}
return null;
case PduHeaders.MESSAGE_TYPE_DELIVERY_IND:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_DELIVERY_IND");
Timber.v("parse: MESSAGE_TYPE_DELIVERY_IND");
}
DeliveryInd deliveryInd =
new DeliveryInd(mHeaders);
return deliveryInd;
case PduHeaders.MESSAGE_TYPE_ACKNOWLEDGE_IND:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_ACKNOWLEDGE_IND");
Timber.v("parse: MESSAGE_TYPE_ACKNOWLEDGE_IND");
}
AcknowledgeInd acknowledgeInd =
new AcknowledgeInd(mHeaders);
return acknowledgeInd;
case PduHeaders.MESSAGE_TYPE_READ_ORIG_IND:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_READ_ORIG_IND");
Timber.v("parse: MESSAGE_TYPE_READ_ORIG_IND");
}
ReadOrigInd readOrigInd =
new ReadOrigInd(mHeaders);
return readOrigInd;
case PduHeaders.MESSAGE_TYPE_READ_REC_IND:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parse: MESSAGE_TYPE_READ_REC_IND");
Timber.v("parse: MESSAGE_TYPE_READ_REC_IND");
}
ReadRecInd readRecInd =
new ReadRecInd(mHeaders);
@@ -261,7 +258,7 @@ public class PduParser {
pduDataStream.reset();
byte [] bVal = parseWapString(pduDataStream, TYPE_TEXT_STRING);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "TextHeader: " + new String(bVal));
Timber.v("TextHeader: " + new String(bVal));
}
/* we should ignore it at the moment */
continue;
@@ -271,7 +268,7 @@ public class PduParser {
{
int messageType = extractByteValue(pduDataStream);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: messageType: " + messageType);
Timber.v("parseHeaders: messageType: " + messageType);
}
switch (messageType) {
// We don't support these kind of messages now.
@@ -335,8 +332,7 @@ public class PduParser {
{
int value = extractByteValue(pduDataStream);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: byte: " + headerField + " value: " +
value);
Timber.v("parseHeaders: byte: " + headerField + " value: " + value);
}
try {
@@ -360,7 +356,7 @@ public class PduParser {
try {
long value = parseLongInteger(pduDataStream);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: longint: " + headerField + " value: " +
Timber.v("parseHeaders: longint: " + headerField + " value: " +
value);
}
headers.setLongInteger(value, headerField);
@@ -379,7 +375,7 @@ public class PduParser {
try {
long value = parseIntegerValue(pduDataStream);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: int: " + headerField + " value: " +
Timber.v("parseHeaders: int: " + headerField + " value: " +
value);
}
headers.setLongInteger(value, headerField);
@@ -415,7 +411,7 @@ public class PduParser {
if (null != value) {
try {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: string: " + headerField + " value: " +
Timber.v("parseHeaders: string: " + headerField + " value: " +
new String(value));
}
headers.setTextString(value, headerField);
@@ -444,7 +440,7 @@ public class PduParser {
if (null != value) {
try {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: encoded string: " + headerField
Timber.v("parseHeaders: encoded string: " + headerField
+ " value: " + value.getString());
}
headers.setEncodedStringValue(value, headerField);
@@ -470,7 +466,7 @@ public class PduParser {
if (null != address) {
String str = new String(address);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: (to/cc/bcc) address: " + headerField
Timber.v("parseHeaders: (to/cc/bcc) address: " + headerField
+ " value: " + str);
}
int endIndex = str.indexOf("/");
@@ -525,7 +521,7 @@ public class PduParser {
try {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: time value: " + headerField
Timber.v("parseHeaders: time value: " + headerField
+ " value: " + timeValue);
}
headers.setLongInteger(timeValue, headerField);
@@ -579,7 +575,7 @@ public class PduParser {
try {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: from address: " + headerField
Timber.v("parseHeaders: from address: " + headerField
+ " value: " + from.getString());
}
headers.setEncodedStringValue(from, PduHeaders.FROM);
@@ -597,7 +593,7 @@ public class PduParser {
pduDataStream.mark(1);
int messageClass = extractByteValue(pduDataStream);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: MESSAGE_CLASS: " + headerField
Timber.v("parseHeaders: MESSAGE_CLASS: " + headerField
+ " value: " + messageClass);
}
@@ -650,7 +646,7 @@ public class PduParser {
try {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: MMS_VERSION: " + headerField
Timber.v("parseHeaders: MMS_VERSION: " + headerField
+ " value: " + version);
}
headers.setOctet(version, PduHeaders.MMS_VERSION);
@@ -685,7 +681,7 @@ public class PduParser {
if (null != previouslySentBy) {
try {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: PREVIOUSLY_SENT_BY: " + headerField
Timber.v("parseHeaders: PREVIOUSLY_SENT_BY: " + headerField
+ " value: " + previouslySentBy.getString());
}
headers.setEncodedStringValue(previouslySentBy,
@@ -718,7 +714,7 @@ public class PduParser {
try {
long perviouslySentDate = parseLongInteger(pduDataStream);
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: PREVIOUSLY_SENT_DATE: " + headerField
Timber.v("parseHeaders: PREVIOUSLY_SENT_DATE: " + headerField
+ " value: " + perviouslySentDate);
}
headers.setLongInteger(perviouslySentDate,
@@ -737,7 +733,7 @@ public class PduParser {
* Encoded-string-value
*/
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: MM_FLAGS: " + headerField
Timber.v("parseHeaders: MM_FLAGS: " + headerField
+ " NOT REALLY SUPPORTED");
}
@@ -761,7 +757,7 @@ public class PduParser {
case PduHeaders.MBOX_QUOTAS:
{
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: MBOX_TOTALS: " + headerField);
Timber.v("parseHeaders: MBOX_TOTALS: " + headerField);
}
/* Value-length */
parseValueLength(pduDataStream);
@@ -784,7 +780,7 @@ public class PduParser {
case PduHeaders.ELEMENT_DESCRIPTOR: {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: ELEMENT_DESCRIPTOR: " + headerField);
Timber.v("parseHeaders: ELEMENT_DESCRIPTOR: " + headerField);
}
parseContentType(pduDataStream, null);
@@ -802,8 +798,7 @@ public class PduParser {
if (null != contentType) {
try {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: CONTENT_TYPE: " + headerField +
contentType.toString());
Timber.v("parseHeaders: CONTENT_TYPE: " + headerField + contentType.toString());
}
headers.setTextString(contentType, PduHeaders.CONTENT_TYPE);
} catch(NullPointerException e) {
@@ -829,7 +824,7 @@ public class PduParser {
case PduHeaders.ATTRIBUTES:
default: {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "parseHeaders: Unknown header: " + headerField);
Timber.v("parseHeaders: Unknown header: " + headerField);
}
log("Unknown header");
}
@@ -961,7 +956,7 @@ public class PduParser {
*/
private static void log(String text) {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, text);
Timber.v(text);
}
}
@@ -1475,7 +1470,7 @@ public class PduParser {
map.put(PduPart.P_CHARSET, charsetInt);
} catch (UnsupportedEncodingException e) {
// Not a well-known charset, use "*".
Log.e(LOG_TAG, Arrays.toString(charsetStr), e);
Timber.e(e, Arrays.toString(charsetStr));
map.put(PduPart.P_CHARSET, CharacterSets.ANY_CHARSET);
}
} else {
@@ -1510,10 +1505,10 @@ public class PduParser {
break;
default:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "Not supported Content-Type parameter");
Timber.v("Not supported Content-Type parameter");
}
if (-1 == skipWapValue(pduDataStream, lastLen)) {
Log.e(LOG_TAG, "Corrupt Content-Type");
Timber.e("Corrupt Content-Type");
} else {
lastLen = 0;
}
@@ -1522,7 +1517,7 @@ public class PduParser {
}
if (0 != lastLen) {
Log.e(LOG_TAG, "Corrupt Content-Type");
Timber.e("Corrupt Content-Type");
}
}
@@ -1572,7 +1567,7 @@ public class PduParser {
contentType = parseWapString(pduDataStream, TYPE_TEXT_STRING);
}
} else {
Log.e(LOG_TAG, "Corrupt content-type");
Timber.e("Corrupt content-type");
return (PduContentTypes.contentTypes[0]).getBytes(); //"*/*"
}
@@ -1583,7 +1578,7 @@ public class PduParser {
}
if (parameterLen < 0) {
Log.e(LOG_TAG, "Corrupt MMS message");
Timber.e("Corrupt MMS message");
return (PduContentTypes.contentTypes[0]).getBytes(); //"*/*"
}
} else if (cur <= TEXT_MAX) {
@@ -1722,10 +1717,10 @@ public class PduParser {
break;
default:
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "Not supported Part headers: " + header);
Timber.v("Not supported Part headers: " + header);
}
if (-1 == skipWapValue(pduDataStream, lastLen)) {
Log.e(LOG_TAG, "Corrupt Part headers");
Timber.e("Corrupt Part headers");
return false;
}
lastLen = 0;
@@ -1746,11 +1741,11 @@ public class PduParser {
lastLen = length - (startPos - tempPos);
} else {
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "Not supported Part headers: " + header);
Timber.v("Not supported Part headers: " + header);
}
// Skip all headers of this part.
if (-1 == skipWapValue(pduDataStream, lastLen)) {
Log.e(LOG_TAG, "Corrupt Part headers");
Timber.e("Corrupt Part headers");
return false;
}
lastLen = 0;
@@ -1758,7 +1753,7 @@ public class PduParser {
}
if (0 != lastLen) {
Log.e(LOG_TAG, "Corrupt Part headers");
Timber.e("Corrupt Part headers");
return false;
}
@@ -118,8 +118,6 @@ public class PduPart {
*/
private byte[] mPartData = null;
private static final String TAG = "PduPart";
/**
* Empty Constructor.
*/
@@ -46,7 +46,7 @@ import com.google.android.mms.util_alt.DrmConvertSession;
import com.google.android.mms.util_alt.PduCache;
import com.google.android.mms.util_alt.PduCacheEntry;
import com.google.android.mms.util_alt.SqliteWrapper;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -65,8 +65,6 @@ import java.util.Set;
* This class is the high-level manager of PDU storage.
*/
public class PduPersister {
private static final String TAG = "PduPersister";
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private static final long DUMMY_THREAD_ID = Long.MAX_VALUE;
@@ -367,7 +365,7 @@ public class PduPersister {
try {
if ((c == null) || (c.getCount() == 0)) {
if (LOCAL_LOGV) {
Log.v(TAG, "loadParts(" + msgId + "): no part to load.");
Timber.v("loadParts(" + msgId + "): no part to load.");
}
return null;
}
@@ -456,7 +454,7 @@ public class PduPersister {
len = is.read(buffer);
}
} catch (IOException e) {
Log.e(TAG, "Failed to load part data", e);
Timber.e(e, "Failed to load part data");
c.close();
throw new MmsException(e);
} finally {
@@ -464,7 +462,7 @@ public class PduPersister {
try {
is.close();
} catch (IOException e) {
Log.e(TAG, "Failed to close stream", e);
Timber.e(e, "Failed to close stream");
} // Ignore
}
}
@@ -508,7 +506,7 @@ public class PduPersister {
addrType);
break;
default:
Log.e(TAG, "Unknown address type: " + addrType);
Timber.e("Unknown address type: " + addrType);
break;
}
}
@@ -535,12 +533,12 @@ public class PduPersister {
synchronized (PDU_CACHE_INSTANCE) {
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
if (LOCAL_LOGV) {
Log.v(TAG, "load: " + uri + " blocked by isUpdating()");
Timber.v("load: " + uri + " blocked by isUpdating()");
}
try {
PDU_CACHE_INSTANCE.wait();
} catch (InterruptedException e) {
Log.e(TAG, "load: ", e);
Timber.e(e, "load: ");
}
cacheEntry = PDU_CACHE_INSTANCE.get(uri);
if (cacheEntry != null) {
@@ -845,12 +843,12 @@ public class PduPersister {
try {
path = convertUriToPath(mContext, uri);
if (LOCAL_LOGV) {
Log.v(TAG, "drm uri: " + uri + " path: " + path);
Timber.v("drm uri: " + uri + " path: " + path);
}
File f = new File(path);
long len = f.length();
if (LOCAL_LOGV) {
Log.v(TAG, "drm path: " + path + " len: " + len);
Timber.v("drm path: " + path + " len: " + len);
}
if (len > 0) {
// we're not going to re-persist and re-encrypt an already
@@ -858,7 +856,7 @@ public class PduPersister {
return;
}
} catch (Exception e) {
Log.e(TAG, "Can't get file info for: " + part.getDataUri(), e);
Timber.e(e, "Can't get file info for: " + part.getDataUri());
}
}
// We haven't converted the file yet, start the conversion
@@ -874,7 +872,7 @@ public class PduPersister {
if (data == null) {
dataUri = part.getDataUri();
if ((dataUri == null) || (dataUri == uri)) {
Log.w(TAG, "Can't find data for this part.");
Timber.w("Can't find data for this part.");
return;
}
// dataUri can look like:
@@ -887,7 +885,7 @@ public class PduPersister {
}
if (LOCAL_LOGV) {
Log.v(TAG, "Saving data to: " + uri);
Timber.v("Saving data to: " + uri);
}
byte[] buffer = new byte[8192];
@@ -905,7 +903,7 @@ public class PduPersister {
}
} else {
if (LOCAL_LOGV) {
Log.v(TAG, "Saving data to: " + uri);
Timber.v("Saving data to: " + uri);
}
if (!isDrm) {
os.write(data);
@@ -921,24 +919,24 @@ public class PduPersister {
}
}
} catch (FileNotFoundException e) {
Log.e(TAG, "Failed to open Input/Output stream.", e);
Timber.e(e, "Failed to open Input/Output stream.");
throw new MmsException(e);
} catch (IOException e) {
Log.e(TAG, "Failed to read/write data.", e);
Timber.e(e, "Failed to read/write data.");
throw new MmsException(e);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
Log.e(TAG, "IOException while closing: " + os, e);
Timber.e(e, "IOException while closing: " + os);
} // Ignore
}
if (is != null) {
try {
is.close();
} catch (IOException e) {
Log.e(TAG, "IOException while closing: " + is, e);
Timber.e(e, "IOException while closing: " + is);
} // Ignore
}
if (drmConvertSession != null) {
@@ -1025,12 +1023,12 @@ public class PduPersister {
// purging it.
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
if (LOCAL_LOGV) {
Log.v(TAG, "updateHeaders: " + uri + " blocked by isUpdating()");
Timber.v("updateHeaders: " + uri + " blocked by isUpdating()");
}
try {
PDU_CACHE_INSTANCE.wait();
} catch (InterruptedException e) {
Log.e(TAG, "updateHeaders: ", e);
Timber.e(e, "updateHeaders: ");
}
}
}
@@ -1193,12 +1191,12 @@ public class PduPersister {
synchronized (PDU_CACHE_INSTANCE) {
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
if (LOCAL_LOGV) {
Log.v(TAG, "updateParts: " + uri + " blocked by isUpdating()");
Timber.v("updateParts: " + uri + " blocked by isUpdating()");
}
try {
PDU_CACHE_INSTANCE.wait();
} catch (InterruptedException e) {
Log.e(TAG, "updateParts: ", e);
Timber.e(e, "updateParts: ");
}
cacheEntry = PDU_CACHE_INSTANCE.get(uri);
if (cacheEntry != null) {
@@ -1301,12 +1299,12 @@ public class PduPersister {
// purging it.
if (PDU_CACHE_INSTANCE.isUpdating(uri)) {
if (LOCAL_LOGV) {
Log.v(TAG, "persist: " + uri + " blocked by isUpdating()");
Timber.v("persist: " + uri + " blocked by isUpdating()");
}
try {
PDU_CACHE_INSTANCE.wait();
} catch (InterruptedException e) {
Log.e(TAG, "persist1: ", e);
Timber.e(e, "persist1: ");
}
}
}
@@ -1552,7 +1550,7 @@ public class PduPersister {
return new String(bytes, CharacterSets.MIMENAME_ISO_8859_1);
} catch (UnsupportedEncodingException e) {
// Impossible to reach here!
Log.e(TAG, "ISO_8859_1 must be supported!", e);
Timber.e(e, "ISO_8859_1 must be supported!");
return "";
}
}
@@ -1565,7 +1563,7 @@ public class PduPersister {
return data.getBytes(CharacterSets.MIMENAME_ISO_8859_1);
} catch (UnsupportedEncodingException e) {
// Impossible to reach here!
Log.e(TAG, "ISO_8859_1 must be supported!", e);
Timber.e(e, "ISO_8859_1 must be supported!");
return new byte[0];
}
}
@@ -1583,7 +1581,7 @@ public class PduPersister {
*/
public Cursor getPendingMessages(long dueTime) {
if (!checkReadSmsPermissions()) {
Log.w(TAG, "No read sms permissions have been granted");
Timber.w("No read sms permissions have been granted");
return null;
}
Uri.Builder uriBuilder = PendingMessages.CONTENT_URI.buildUpon();
@@ -17,10 +17,9 @@
package com.google.android.mms.pdu_alt;
import com.google.android.mms.InvalidHeaderValueException;
import com.klinker.android.logger.Log;
import timber.log.Timber;
public class SendReq extends MultimediaMessagePdu {
private static final String TAG = "SendReq";
public SendReq() {
super();
@@ -35,7 +34,7 @@ public class SendReq extends MultimediaMessagePdu {
setTransactionId(generateTransactionId());
} catch (InvalidHeaderValueException e) {
// Impossible to reach here since all headers we set above are valid.
Log.e(TAG, "Unexpected InvalidHeaderValueException.", e);
Timber.e(e, "Unexpected InvalidHeaderValueException.");
throw new RuntimeException(e);
}
}
@@ -4,12 +4,12 @@ import com.android.mms.dom.smil.SmilDocumentImpl;
import com.google.android.mms.ContentType;
import com.google.android.mms.pdu_alt.PduBody;
import com.google.android.mms.pdu_alt.PduPart;
import com.klinker.android.logger.Log;
import org.w3c.dom.smil.SMILDocument;
import org.w3c.dom.smil.SMILElement;
import org.w3c.dom.smil.SMILLayoutElement;
import org.w3c.dom.smil.SMILMediaElement;
import org.w3c.dom.smil.SMILParElement;
import timber.log.Timber;
public class SmilHelper {
@@ -88,7 +88,7 @@ public class SmilHelper {
par.appendChild(textElement);
hasMedia = true;
} else {
Log.e("creating_smil_document", "unknown mimetype");
Timber.e("creating_smil_document", "unknown mimetype");
}
}
@@ -16,12 +16,11 @@
package com.google.android.mms.util_alt;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.util.HashMap;
public abstract class AbstractCache<K, V> {
private static final String TAG = "AbstractCache";
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
@@ -35,14 +34,14 @@ public abstract class AbstractCache<K, V> {
public boolean put(K key, V value) {
if (LOCAL_LOGV) {
Log.v(TAG, "Trying to put " + key + " into cache.");
Timber.v("Trying to put " + key + " into cache.");
}
if (mCacheMap.size() >= MAX_CACHED_ITEMS) {
// TODO Should remove the oldest or least hit cached entry
// and then cache the new one.
if (LOCAL_LOGV) {
Log.v(TAG, "Failed! size limitation reached.");
Timber.v("Failed! size limitation reached.");
}
return false;
}
@@ -53,7 +52,7 @@ public abstract class AbstractCache<K, V> {
mCacheMap.put(key, cacheEntry);
if (LOCAL_LOGV) {
Log.v(TAG, key + " cached, " + mCacheMap.size() + " items total.");
Timber.v(key + " cached, " + mCacheMap.size() + " items total.");
}
return true;
}
@@ -62,7 +61,7 @@ public abstract class AbstractCache<K, V> {
public V get(K key) {
if (LOCAL_LOGV) {
Log.v(TAG, "Trying to get " + key + " from cache.");
Timber.v("Trying to get " + key + " from cache.");
}
if (key != null) {
@@ -70,7 +69,7 @@ public abstract class AbstractCache<K, V> {
if (cacheEntry != null) {
cacheEntry.hit++;
if (LOCAL_LOGV) {
Log.v(TAG, key + " hit " + cacheEntry.hit + " times.");
Timber.v(key + " hit " + cacheEntry.hit + " times.");
}
return cacheEntry.value;
}
@@ -80,13 +79,13 @@ public abstract class AbstractCache<K, V> {
public V purge(K key) {
if (LOCAL_LOGV) {
Log.v(TAG, "Trying to purge " + key);
Timber.v("Trying to purge " + key);
}
CacheEntry<V> v = mCacheMap.remove(key);
if (LOCAL_LOGV) {
Log.v(TAG, mCacheMap.size() + " items cached.");
Timber.v(mCacheMap.size() + " items cached.");
}
return v != null ? v.value : null;
@@ -94,8 +93,7 @@ public abstract class AbstractCache<K, V> {
public void purgeAll() {
if (LOCAL_LOGV) {
Log.v(TAG, "Purging cache, " + mCacheMap.size()
+ " items dropped.");
Timber.v("Purging cache, " + mCacheMap.size() + " items dropped.");
}
mCacheMap.clear();
}
@@ -18,10 +18,10 @@ package com.google.android.mms.util_alt;
import android.content.Context;
import android.drm.DrmManagerClient;
import com.klinker.android.logger.Log;
import timber.log.Timber;
public class DownloadDrmHelper {
private static final String TAG = "DownloadDrmHelper";
/** The MIME type of special DRM files */
public static final String MIMETYPE_DRM_MESSAGE = "application/vnd.oma.drm.message";
@@ -46,10 +46,9 @@ public class DownloadDrmHelper {
result = drmClient.canHandle("", mimetype);
}
} catch (IllegalArgumentException e) {
Log.w(TAG,
"DrmManagerClient instance could not be created, context is Illegal.");
Timber.w("DrmManagerClient instance could not be created, context is Illegal.");
} catch (IllegalStateException e) {
Log.w(TAG, "DrmManagerClient didn't initialize properly.");
Timber.w("DrmManagerClient didn't initialize properly.");
}
}
return result;
@@ -99,10 +98,9 @@ public class DownloadDrmHelper {
result = drmClient.getOriginalMimeType(path);
}
} catch (IllegalArgumentException ex) {
Log.w(TAG,
"Can't get original mime type since path is null or empty string.");
Timber.w("Can't get original mime type since path is null or empty string.");
} catch (IllegalStateException ex) {
Log.w(TAG, "DrmManagerClient didn't initialize properly.");
Timber.w("DrmManagerClient didn't initialize properly.");
}
return result;
}
@@ -18,7 +18,7 @@ package com.google.android.mms.util_alt;
import android.content.Context;
import android.drm.DrmConvertedStatus;
import android.drm.DrmManagerClient;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -28,7 +28,6 @@ import java.io.RandomAccessFile;
public class DrmConvertSession {
private DrmManagerClient mDrmClient;
private int mConvertSessionId;
private static final String TAG = "DrmConvertSession";
private static final int STATUS_UNKNOWN_ERROR = 491;
private static final int STATUS_NOT_ACCEPTABLE = 406;
@@ -56,16 +55,15 @@ public class DrmConvertSession {
try {
convertSessionId = drmClient.openConvertSession(mimeType);
} catch (IllegalArgumentException e) {
Log.w(TAG, "Conversion of Mimetype: " + mimeType
Timber.w("Conversion of Mimetype: " + mimeType
+ " is not supported.", e);
} catch (IllegalStateException e) {
Log.w(TAG, "Could not access Open DrmFramework.", e);
Timber.w(e, "Could not access Open DrmFramework.");
}
} catch (IllegalArgumentException e) {
Log.w(TAG,
"DrmManagerClient instance could not be created, context is Illegal.");
Timber.w("DrmManagerClient instance could not be created, context is Illegal.");
} catch (IllegalStateException e) {
Log.w(TAG, "DrmManagerClient didn't initialize properly.");
Timber.w("DrmManagerClient didn't initialize properly.");
}
}
@@ -102,10 +100,10 @@ public class DrmConvertSession {
result = convertedStatus.convertedData;
}
} catch (IllegalArgumentException e) {
Log.w(TAG, "Buffer with data to convert is illegal. Convertsession: "
Timber.w("Buffer with data to convert is illegal. Convertsession: "
+ mConvertSessionId, e);
} catch (IllegalStateException e) {
Log.w(TAG, "Could not convert data. Convertsession: " +
Timber.w("Could not convert data. Convertsession: " +
mConvertSessionId, e);
}
} else {
@@ -143,15 +141,15 @@ public class DrmConvertSession {
result = STATUS_SUCCESS;
} catch (FileNotFoundException e) {
result = STATUS_FILE_ERROR;
Log.w(TAG, "File: " + filename + " could not be found.", e);
Timber.w(e, "File: " + filename + " could not be found.");
} catch (IOException e) {
result = STATUS_FILE_ERROR;
Log.w(TAG, "Could not access File: " + filename + " .", e);
Timber.w(e, "Could not access File: " + filename + " .");
} catch (IllegalArgumentException e) {
result = STATUS_FILE_ERROR;
Log.w(TAG, "Could not open file in mode: rw", e);
Timber.w(e, "Could not open file in mode: rw");
} catch (SecurityException e) {
Log.w(TAG, "Access to File: " + filename +
Timber.w("Access to File: " + filename +
" was denied denied by SecurityManager.", e);
} finally {
if (rndAccessFile != null) {
@@ -159,14 +157,14 @@ public class DrmConvertSession {
rndAccessFile.close();
} catch (IOException e) {
result = STATUS_FILE_ERROR;
Log.w(TAG, "Failed to close File:" + filename
Timber.w("Failed to close File:" + filename
+ ".", e);
}
}
}
}
} catch (IllegalStateException e) {
Log.w(TAG, "Could not close convertsession. Convertsession: " +
Timber.w("Could not close convertsession. Convertsession: " +
mConvertSessionId, e);
}
}
@@ -20,13 +20,13 @@ import android.content.ContentUris;
import android.content.UriMatcher;
import android.net.Uri;
import android.provider.Telephony.Mms;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.util.HashMap;
import java.util.HashSet;
public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
private static final String TAG = "PduCache";
private static final boolean LOCAL_LOGV = false;
private static final int MMS_ALL = 0;
@@ -82,7 +82,7 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
synchronized public static final PduCache getInstance() {
if (sInstance == null) {
if (LOCAL_LOGV) {
Log.v(TAG, "Constructing new PduCache instance.");
Timber.v("Constructing new PduCache instance.");
}
sInstance = new PduCache();
}
@@ -202,14 +202,14 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
}
if (LOCAL_LOGV) {
Log.v(TAG, uri + " -> " + normalizedKey);
Timber.v(uri + " -> " + normalizedKey);
}
return normalizedKey;
}
private void purgeByMessageBox(Integer msgBoxId) {
if (LOCAL_LOGV) {
Log.v(TAG, "Purge cache in message box: " + msgBoxId);
Timber.v("Purge cache in message box: " + msgBoxId);
}
if (msgBoxId != null) {
@@ -235,7 +235,7 @@ public final class PduCache extends AbstractCache<Uri, PduCacheEntry> {
private void purgeByThreadId(long threadId) {
if (LOCAL_LOGV) {
Log.v(TAG, "Purge cache in thread: " + threadId);
Timber.v("Purge cache in thread: " + threadId);
}
HashSet<Uri> thread = mThreads.remove(threadId);
@@ -24,10 +24,9 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.widget.Toast;
import com.klinker.android.logger.Log;
import timber.log.Timber;
public final class SqliteWrapper {
private static final String TAG = "SqliteWrapper";
private static final String SQLITE_EXCEPTION_DETAIL_MESSAGE
= "unable to open database file";
@@ -69,7 +68,7 @@ public final class SqliteWrapper {
try {
return resolver.query(uri, projection, selection, selectionArgs, sortOrder);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when query: ", e);
Timber.e(e, "Catch a SQLiteException when query: ");
checkSQLiteException(context, e);
return null;
}
@@ -79,7 +78,7 @@ public final class SqliteWrapper {
try {
return cursor.requery();
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when requery: ", e);
Timber.e(e, "Catch a SQLiteException when requery: ");
checkSQLiteException(context, e);
return false;
}
@@ -89,7 +88,7 @@ public final class SqliteWrapper {
try {
return resolver.update(uri, values, where, selectionArgs);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when update: ", e);
Timber.e(e, "Catch a SQLiteException when update: ");
checkSQLiteException(context, e);
return -1;
}
@@ -100,7 +99,7 @@ public final class SqliteWrapper {
try {
return resolver.delete(uri, where, selectionArgs);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when delete: ", e);
Timber.e(e, "Catch a SQLiteException when delete: ");
checkSQLiteException(context, e);
return -1;
}
@@ -111,7 +110,7 @@ public final class SqliteWrapper {
try {
return resolver.insert(uri, values);
} catch (SQLiteException e) {
Log.e(TAG, "Catch a SQLiteException when insert: ", e);
Timber.e(e, "Catch a SQLiteException when insert: ");
checkSQLiteException(context, e);
return null;
}