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
@@ -23,15 +23,14 @@ import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.widget.Toast;
import com.klinker.android.logger.Log;
import org.jetbrains.annotations.Nullable;
import timber.log.Timber;
/**
* @hide
*/
public final class SqliteWrapper {
private static final String TAG = "SqliteWrapper";
private static final String SQLITE_EXCEPTION_DETAIL_MESSAGE
= "unable to open database file";
@@ -59,7 +58,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;
}
@@ -70,7 +69,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;
}
@@ -81,7 +80,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;
}
@@ -92,7 +91,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;
}
@@ -17,7 +17,7 @@
package android.net;
import android.text.TextUtils;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.net.Inet4Address;
import java.net.InetAddress;
@@ -32,7 +32,6 @@ import java.util.Collections;
* @hide
*/
public class DhcpInfoInternal {
private final static String TAG = "DhcpInfoInternal";
public String ipAddress;
public int prefixLength;
@@ -96,7 +95,7 @@ public class DhcpInfoInternal {
public LinkAddress makeLinkAddress() {
if (TextUtils.isEmpty(ipAddress)) {
Log.e(TAG, "makeLinkAddress with empty ipAddress");
Timber.e("makeLinkAddress with empty ipAddress");
return null;
}
return new LinkAddress(NetworkUtilsHelper.numericToInetAddress(ipAddress), prefixLength);
@@ -112,12 +111,12 @@ public class DhcpInfoInternal {
if (TextUtils.isEmpty(dns1) == false) {
p.addDns(NetworkUtilsHelper.numericToInetAddress(dns1));
} else {
Log.d(TAG, "makeLinkProperties with empty dns1!");
Timber.d("makeLinkProperties with empty dns1!");
}
if (TextUtils.isEmpty(dns2) == false) {
p.addDns(NetworkUtilsHelper.numericToInetAddress(dns2));
} else {
Log.d(TAG, "makeLinkProperties with empty dns2!");
Timber.d("makeLinkProperties with empty dns2!");
}
return p;
}
@@ -18,7 +18,7 @@ package android.net;
import android.os.Parcel;
import android.os.Parcelable;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.util.Collection;
import java.util.HashMap;
@@ -32,7 +32,6 @@ import java.util.Set;
* @hide
*/
public class LinkCapabilities implements Parcelable {
private static final String TAG = "LinkCapabilities";
private static final boolean DBG = false;
/**
@@ -388,6 +387,6 @@ public class LinkCapabilities implements Parcelable {
* Debug logging
*/
protected static void log(String s) {
Log.d(TAG, s);
Timber.d(s);
}
}
@@ -16,7 +16,7 @@
package android.net;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.net.Inet4Address;
import java.net.Inet6Address;
@@ -31,8 +31,6 @@ import java.util.Collection;
*/
public class NetworkUtilsHelper {
private static final String TAG = "NetworkUtils";
/**
* Bring the named network interface up.
*/
@@ -255,7 +253,7 @@ public class NetworkUtilsHelper {
addrHexString.substring(16, 20), addrHexString.substring(20, 24),
addrHexString.substring(24, 28), addrHexString.substring(28, 32)));
} catch (Exception e) {
Log.e("NetworkUtils", "error in hexToInet6Address(" + addrHexString + "): " + e);
Timber.e("error in hexToInet6Address(" + addrHexString + "): " + e);
throw new IllegalArgumentException(e);
}
}
@@ -18,7 +18,7 @@ package android.net;
import android.os.Parcel;
import android.os.Parcelable;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.net.Inet4Address;
import java.net.Inet6Address;
@@ -32,7 +32,6 @@ import java.util.Collection;
* @hide
*/
public class RouteInfo implements Parcelable {
private static final String TAG = "RouteInfo";
/**
* The IP destination address for this route.
*/
@@ -54,14 +53,14 @@ public class RouteInfo implements Parcelable {
destination = new LinkAddress(Inet4Address.getLocalHost(), 0);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
}
} else {
try {
destination = new LinkAddress(Inet6Address.getLocalHost(), 0);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
}
}
} else {
@@ -75,14 +74,14 @@ public class RouteInfo implements Parcelable {
gateway = Inet4Address.getLocalHost();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
}
} else {
try {
gateway = Inet6Address.getLocalHost();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
}
}
}
@@ -18,15 +18,14 @@ package com.android.mms;
import android.content.Context;
import android.content.res.XmlResourceParser;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.R;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import timber.log.Timber;
import java.io.IOException;
public class MmsConfig {
private static final String TAG = "MmsConfig";
private static final boolean DEBUG = true;
private static final boolean LOCAL_LOGV = false;
@@ -107,7 +106,7 @@ public class MmsConfig {
public static void init(Context context) {
if (LOCAL_LOGV) {
Log.v(TAG, "MmsConfig.init()");
Timber.v("MmsConfig.init()");
}
// Always put the mnc/mcc in the log so we can tell which mms_config.xml was loaded.
@@ -120,7 +119,7 @@ public class MmsConfig {
public static int getMaxMessageSize() {
if (LOCAL_LOGV) {
Log.v(TAG, "MmsConfig.getMaxMessageSize(): " + mMaxMessageSize);
Timber.v("MmsConfig.getMaxMessageSize(): " + mMaxMessageSize);
}
return mMaxMessageSize;
}
@@ -209,7 +208,7 @@ public class MmsConfig {
}
if (DEBUG) {
Log.v(TAG, "tag: " + tag + " value: " + value + " - " +
Timber.v("tag: " + tag + " value: " + value + " - " +
text);
}
if ("name".equalsIgnoreCase(name)) {
@@ -297,11 +296,11 @@ public class MmsConfig {
}
}
} catch (XmlPullParserException e) {
Log.e(TAG, "loadMmsSettings caught ", e);
Timber.e(e, "loadMmsSettings caught ");
} catch (NumberFormatException e) {
Log.e(TAG, "loadMmsSettings caught ", e);
Timber.e(e, "loadMmsSettings caught ");
} catch (IOException e) {
Log.e(TAG, "loadMmsSettings caught ", e);
Timber.e(e, "loadMmsSettings caught ");
} finally {
parser.close();
}
@@ -316,7 +315,7 @@ public class MmsConfig {
String err =
String.format("MmsConfig.loadMmsSettings mms_config.xml missing %s setting",
errorStr);
Log.e(TAG, err);
Timber.e(err);
}
}
@@ -16,17 +16,15 @@
package com.android.mms.dom.events;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventException;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import timber.log.Timber;
import java.util.ArrayList;
public class EventTargetImpl implements EventTarget {
private static final String TAG = LogTag.TAG;
private ArrayList<EventListenerEntry> mListenerEntries;
private EventTarget mNodeTarget;
@@ -98,7 +96,7 @@ public class EventTargetImpl implements EventTarget {
catch (Exception e) {
// Any exceptions thrown inside an EventListener will
// not stop propagation of the event
Log.w(TAG, "Catched EventListener exception", e);
Timber.w(e, "Catched EventListener exception");
}
}
}
@@ -16,18 +16,16 @@
package com.android.mms.dom.smil;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import org.w3c.dom.DOMException;
import org.w3c.dom.smil.ElementTime;
import org.w3c.dom.smil.SMILElement;
import org.w3c.dom.smil.Time;
import org.w3c.dom.smil.TimeList;
import timber.log.Timber;
import java.util.ArrayList;
public abstract class ElementTimeImpl implements ElementTime {
private static final String TAG = LogTag.TAG;
private static final String FILL_REMOVE_ATTRIBUTE = "remove";
private static final String FILL_FREEZE_ATTRIBUTE = "freeze";
@@ -131,7 +129,7 @@ public abstract class ElementTimeImpl implements ElementTime {
getEndConstraints()));
} catch (IllegalArgumentException e) {
// Ignore badly formatted times
Log.e(TAG, "Malformed time value.", e);
Timber.e(e, "Malformed time value.");
}
}
}
@@ -17,23 +17,19 @@
package com.android.mms.dom.smil;
import com.android.mms.dom.events.EventImpl;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import org.w3c.dom.DOMException;
import org.w3c.dom.events.DocumentEvent;
import org.w3c.dom.events.Event;
import org.w3c.dom.smil.ElementTime;
import org.w3c.dom.smil.SMILMediaElement;
import org.w3c.dom.smil.TimeList;
import timber.log.Timber;
public class SmilMediaElementImpl extends SmilElementImpl implements
SMILMediaElement {
public class SmilMediaElementImpl extends SmilElementImpl implements SMILMediaElement {
public final static String SMIL_MEDIA_START_EVENT = "SmilMediaStart";
public final static String SMIL_MEDIA_END_EVENT = "SmilMediaEnd";
public final static String SMIL_MEDIA_PAUSE_EVENT = "SmilMediaPause";
public final static String SMIL_MEDIA_SEEK_EVENT = "SmilMediaSeek";
private final static String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
ElementTime mElementTime = new ElementTimeImpl(this) {
@@ -43,7 +39,7 @@ public class SmilMediaElementImpl extends SmilElementImpl implements
Event event = doc.createEvent("Event");
event.initEvent(eventType, false, false);
if (LOCAL_LOGV) {
Log.v(TAG, "Dispatching 'begin' event to "
Timber.v("Dispatching 'begin' event to "
+ SmilMediaElementImpl.this.getTagName() + " "
+ SmilMediaElementImpl.this.getSrc() + " at "
+ System.currentTimeMillis());
@@ -57,7 +53,7 @@ public class SmilMediaElementImpl extends SmilElementImpl implements
EventImpl event = (EventImpl) doc.createEvent("Event");
event.initEvent(eventType, false, false, seekTo);
if (LOCAL_LOGV) {
Log.v(TAG, "Dispatching 'begin' event to "
Timber.v("Dispatching 'begin' event to "
+ SmilMediaElementImpl.this.getTagName() + " "
+ SmilMediaElementImpl.this.getSrc() + " at "
+ System.currentTimeMillis());
@@ -106,7 +102,7 @@ public class SmilMediaElementImpl extends SmilElementImpl implements
// Discrete media
dur = 0;
} else {
Log.w(TAG, "Unknown media type");
Timber.w("Unknown media type");
}
}
return dur;
@@ -16,11 +16,10 @@
package com.android.mms.dom.smil;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import org.w3c.dom.DOMException;
import org.w3c.dom.smil.SMILDocument;
import org.w3c.dom.smil.SMILRegionElement;
import timber.log.Timber;
public class SmilRegionElementImpl extends SmilElementImpl implements
SMILRegionElement {
@@ -45,8 +44,6 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
private static final String RIGHT_ATTRIBUTE_NAME = "right";
private static final String BOTTOM_ATTRIBUTE_NAME = "bottom";
private static final String FIT_ATTRIBUTE_NAME = "fit";
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
SmilRegionElementImpl(SmilDocumentImpl owner, String tagName) {
@@ -77,7 +74,7 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
return parseRegionLength(getAttribute(LEFT_ATTRIBUTE_NAME), true);
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Left attribute is not set or incorrect.");
Timber.v("Left attribute is not set or incorrect.");
}
}
try {
@@ -87,7 +84,7 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
return bbw - right - width;
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Right or width attribute is not set or incorrect.");
Timber.v("Right or width attribute is not set or incorrect.");
}
}
return 0;
@@ -98,7 +95,7 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
return parseRegionLength(getAttribute(TOP_ATTRIBUTE_NAME), false);
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Top attribute is not set or incorrect.");
Timber.v("Top attribute is not set or incorrect.");
}
}
try {
@@ -108,7 +105,7 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
return bbh - bottom - height;
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Bottom or height attribute is not set or incorrect.");
Timber.v("Bottom or height attribute is not set or incorrect.");
}
}
return 0;
@@ -161,7 +158,7 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
height;
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Height attribute is not set or incorrect.");
Timber.v("Height attribute is not set or incorrect.");
}
}
int bbh = ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getHeight();
@@ -169,14 +166,14 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
bbh -= parseRegionLength(getAttribute(TOP_ATTRIBUTE_NAME), false);
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Top attribute is not set or incorrect.");
Timber.v("Top attribute is not set or incorrect.");
}
}
try {
bbh -= parseRegionLength(getAttribute(BOTTOM_ATTRIBUTE_NAME), false);
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Bottom attribute is not set or incorrect.");
Timber.v("Bottom attribute is not set or incorrect.");
}
}
return bbh;
@@ -194,7 +191,7 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
width;
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Width attribute is not set or incorrect.");
Timber.v("Width attribute is not set or incorrect.");
}
}
int bbw = ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getWidth();
@@ -202,14 +199,14 @@ public class SmilRegionElementImpl extends SmilElementImpl implements
bbw -= parseRegionLength(getAttribute(LEFT_ATTRIBUTE_NAME), true);
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Left attribute is not set or incorrect.");
Timber.v("Left attribute is not set or incorrect.");
}
}
try {
bbw -= parseRegionLength(getAttribute(RIGHT_ATTRIBUTE_NAME), true);
} catch (NumberFormatException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Right attribute is not set or incorrect.");
Timber.v("Right attribute is not set or incorrect.");
}
}
return bbw;
@@ -16,12 +16,12 @@
package com.android.mms.dom.smil.parser;
import com.klinker.android.logger.Log;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.smil.SMILDocument;
import org.w3c.dom.smil.SMILElement;
import timber.log.Timber;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -31,7 +31,6 @@ import java.io.UnsupportedEncodingException;
import java.io.Writer;
public class SmilXmlSerializer {
private static final String TAG = "SmilXmlSerializer";
public static void serialize(SMILDocument smilDoc, OutputStream out) {
try {
@@ -40,9 +39,9 @@ public class SmilXmlSerializer {
writeElement(writer, smilDoc.getDocumentElement());
writer.flush();
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
} catch (IOException e) {
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
}
}
@@ -17,12 +17,9 @@
package com.android.mms.layout;
import android.content.Context;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import timber.log.Timber;
public class HVGALayoutParameters implements LayoutParameters {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private int mType = -1;
@@ -41,7 +38,7 @@ public class HVGALayoutParameters implements LayoutParameters {
}
if (LOCAL_LOGV) {
Log.v(TAG, "HVGALayoutParameters.<init>(" + type + ").");
Timber.v("HVGALayoutParameters.<init>(" + type + ").");
}
mType = type;
@@ -56,7 +53,7 @@ public class HVGALayoutParameters implements LayoutParameters {
mTextHeightPortrait = (int) (mMaxWidth * .10f);
if (LOCAL_LOGV) {
Log.v(TAG, "HVGALayoutParameters mMaxWidth: " + mMaxWidth +
Timber.v("HVGALayoutParameters mMaxWidth: " + mMaxWidth +
" mMaxHeight: " + mMaxHeight +
" mImageHeightLandscape: " + mImageHeightLandscape +
" mTextHeightLandscape: " + mTextHeightLandscape +
@@ -18,14 +18,12 @@ package com.android.mms.layout;
import android.content.Context;
import android.content.res.Configuration;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import timber.log.Timber;
/**
* MMS presentation layout management.
*/
public class LayoutManager {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
@@ -46,7 +44,7 @@ public class LayoutManager {
: LayoutParameters.HVGA_LANDSCAPE);
if (LOCAL_LOGV) {
Log.v(TAG, "LayoutParameters: " + mLayoutParams.getTypeDescription()
Timber.v("LayoutParameters: " + mLayoutParams.getTypeDescription()
+ ": " + mLayoutParams.getWidth() + "x" + mLayoutParams.getHeight());
}
}
@@ -65,11 +63,11 @@ public class LayoutManager {
public static void init(Context context) {
if (LOCAL_LOGV) {
Log.v(TAG, "DefaultLayoutManager.init()");
Timber.v("DefaultLayoutManager.init()");
}
if (sInstance != null) {
Log.w(TAG, "Already initialized.");
Timber.w("Already initialized.");
}
sInstance = new LayoutManager(context);
}
@@ -83,7 +81,7 @@ public class LayoutManager {
public void onConfigurationChanged(Configuration newConfig) {
if (LOCAL_LOGV) {
Log.v(TAG, "-> LayoutManager.onConfigurationChanged().");
Timber.v("-> LayoutManager.onConfigurationChanged().");
}
initLayoutParameters(newConfig);
}
@@ -1,23 +0,0 @@
/*
* Copyright 2014 Jacob Klinker
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.mms.logs;
public class LogTag {
public static final String TAG = "Mms";
public static final String TRANSACTION = TAG;
}
@@ -26,7 +26,7 @@ import android.preference.PreferenceManager;
import android.provider.Telephony;
import android.text.TextUtils;
import com.android.mms.service_alt.exception.ApnException;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.net.URI;
import java.net.URISyntaxException;
@@ -35,7 +35,6 @@ import java.net.URISyntaxException;
* APN settings used for MMS transactions
*/
public class ApnSettings {
private static final String TAG = "ApnSettings";
// MMSC URL
private final String mServiceCenter;
@@ -100,7 +99,7 @@ public class ApnSettings {
return new ApnSettings(mmsc, mmsProxy, parsePort(mmsPort), "Default from settings");
}
Log.v(TAG, "ApnSettings: apnName " + apnName);
Timber.v("ApnSettings: apnName " + apnName);
// TODO: CURRENT semantics is currently broken in telephony. Revive this when it is fixed.
//String selection = Telephony.Carriers.CURRENT + " IS NOT NULL";
String selection = null;
@@ -148,7 +147,7 @@ public class ApnSettings {
try {
proxyPort = Integer.parseInt(portString);
} catch (NumberFormatException e) {
Log.e(TAG, "Invalid port " + portString);
Timber.e("Invalid port " + portString);
throw new ApnException("Invalid port " + portString);
}
}
@@ -27,7 +27,6 @@ import android.os.Binder;
import android.os.Bundle;
import android.provider.Telephony;
import android.text.TextUtils;
import android.util.Log;
import com.android.mms.service_alt.exception.MmsHttpException;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu_alt.GenericPdu;
@@ -38,12 +37,12 @@ import com.google.android.mms.pdu_alt.RetrieveConf;
import com.google.android.mms.util_alt.SqliteWrapper;
import com.klinker.android.send_message.BroadcastUtils;
import com.klinker.android.send_message.Transaction;
import timber.log.Timber;
/**
* Request to download an MMS
*/
public class DownloadRequest extends MmsRequest {
private static final String TAG = "DownloadRequest";
private static final String LOCATION_SELECTION =
Telephony.Mms.MESSAGE_TYPE + "=? AND " + Telephony.Mms.CONTENT_LOCATION + " =?";
@@ -79,7 +78,7 @@ public class DownloadRequest extends MmsRequest {
throws MmsHttpException {
final MmsHttpClient mmsHttpClient = netMgr.getOrCreateHttpClient();
if (mmsHttpClient == null) {
Log.e(TAG, "MMS network is not ready!");
Timber.e("MMS network is not ready!");
throw new MmsHttpException(0/*statusCode*/, "MMS network is not ready");
}
return mmsHttpClient.execute(
@@ -117,9 +116,9 @@ public class DownloadRequest extends MmsRequest {
// Let any mms apps running as secondary user know that a new mms has been downloaded.
notifyOfDownload(context);
Log.d(TAG, "DownloadRequest.persistIfRequired");
Timber.d("DownloadRequest.persistIfRequired");
if (response == null || response.length < 1) {
Log.e(TAG, "DownloadRequest.persistIfRequired: empty response");
Timber.e("DownloadRequest.persistIfRequired: empty response");
// Update the retrieve status of the NotificationInd
final ContentValues values = new ContentValues(1);
values.put(Telephony.Mms.RETRIEVE_STATUS, PduHeaders.RETRIEVE_STATUS_ERROR_END);
@@ -140,7 +139,7 @@ public class DownloadRequest extends MmsRequest {
final GenericPdu pdu =
(new PduParser(response, mmsConfig.getSupportMmsContentDisposition())).parse();
if (pdu == null || !(pdu instanceof RetrieveConf)) {
Log.e(TAG, "DownloadRequest.persistIfRequired: invalid parsed PDU");
Timber.e("DownloadRequest.persistIfRequired: invalid parsed PDU");
// Update the error type of the NotificationInd
setErrorType(context, locationUrl, Telephony.MmsSms.ERR_TYPE_MMS_PROTO_PERMANENT);
@@ -149,7 +148,7 @@ public class DownloadRequest extends MmsRequest {
final RetrieveConf retrieveConf = (RetrieveConf) pdu;
final int status = retrieveConf.getRetrieveStatus();
// if (status != PduHeaders.RETRIEVE_STATUS_OK) {
// Log.e(TAG, "DownloadRequest.persistIfRequired: retrieve failed "
// Timber.e("DownloadRequest.persistIfRequired: retrieve failed "
// + status);
// // Update the retrieve status of the NotificationInd
// final ContentValues values = new ContentValues(1);
@@ -175,7 +174,7 @@ public class DownloadRequest extends MmsRequest {
true/*groupMmsEnabled*/,
null/*preOpenedFiles*/);
if (messageUri == null) {
Log.e(TAG, "DownloadRequest.persistIfRequired: can not persist message");
Timber.e("DownloadRequest.persistIfRequired: can not persist message");
return null;
}
// Update some of the properties of the message
@@ -198,7 +197,7 @@ public class DownloadRequest extends MmsRequest {
values,
null/*where*/,
null/*selectionArg*/) != 1) {
Log.e(TAG, "DownloadRequest.persistIfRequired: can not update message");
Timber.e("DownloadRequest.persistIfRequired: can not update message");
}
// Delete the corresponding NotificationInd
SqliteWrapper.delete(context,
@@ -212,11 +211,11 @@ public class DownloadRequest extends MmsRequest {
return messageUri;
} catch (MmsException e) {
Log.e(TAG, "DownloadRequest.persistIfRequired: can not persist message", e);
Timber.e(e, "DownloadRequest.persistIfRequired: can not persist message");
} catch (SQLiteException e) {
Log.e(TAG, "DownloadRequest.persistIfRequired: can not update message", e);
Timber.e(e, "DownloadRequest.persistIfRequired: can not update message");
} catch (RuntimeException e) {
Log.e(TAG, "DownloadRequest.persistIfRequired: can not parse response", e);
Timber.e(e, "DownloadRequest.persistIfRequired: can not parse response");
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -24,8 +24,8 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.R;
import timber.log.Timber;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
@@ -44,7 +44,6 @@ import java.util.concurrent.ConcurrentHashMap;
* 4. Add key/value for relevant mms_config.xml of a specific carrier (mcc/mnc)
*/
public class MmsConfig {
private static final String TAG = "MmsConfig";
private static final String DEFAULT_HTTP_KEY_X_WAP_PROFILE = "x-wap-profile";
@@ -198,10 +197,10 @@ public class MmsConfig {
mKeyValues.putAll(DEFAULTS);
// Load User-Agent and UA profile URL settings
loadDeviceUaSettings(context);
Log.v(TAG, "MmsConfig: mUserAgent=" + mUserAgent + ", mUaProfUrl=" + mUaProfUrl);
Timber.v("MmsConfig: mUserAgent=" + mUserAgent + ", mUaProfUrl=" + mUaProfUrl);
// Load mms_config.xml resource overlays
loadFromResources(context);
Log.v(TAG, "MmsConfig: all settings -- " + mKeyValues);
Timber.v("MmsConfig: all settings -- " + mKeyValues);
}
/**
@@ -218,10 +217,10 @@ public class MmsConfig {
mKeyValues.putAll(DEFAULTS);
// Load User-Agent and UA profile URL settings
loadDeviceUaSettings(context);
Log.v(TAG, "MmsConfig: mUserAgent=" + mUserAgent + ", mUaProfUrl=" + mUaProfUrl);
Timber.v("MmsConfig: mUserAgent=" + mUserAgent + ", mUaProfUrl=" + mUaProfUrl);
// Load mms_config.xml resource overlays
loadFromResources(context);
Log.v(TAG, "MmsConfig: all settings -- " + mKeyValues);
Timber.v("MmsConfig: all settings -- " + mKeyValues);
}
/**
@@ -328,7 +327,7 @@ public class MmsConfig {
mKeyValues.put(key, value);
}
} catch (NumberFormatException e) {
Log.e(TAG, "MmsConfig.update: invalid " + key + "," + value + "," + type);
Timber.e("MmsConfig.update: invalid " + key + "," + value + "," + type);
}
}
@@ -345,7 +344,7 @@ public class MmsConfig {
}
private void loadFromResources(Context context) {
Log.d(TAG, "MmsConfig.loadFromResources");
Timber.d("MmsConfig.loadFromResources");
final XmlResourceParser parser = context.getResources().getXml(R.xml.mms_config);
final MmsConfigXmlProcessor processor = MmsConfigXmlProcessor.get(parser);
processor.setMmsConfigHandler(new MmsConfigXmlProcessor.MmsConfigHandler() {
@@ -594,9 +593,7 @@ public class MmsConfig {
}
}
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "MmsConfig.getNai: nai=" + nai);
}
Timber.v("MmsConfig.getNai: nai=" + nai);
if (!TextUtils.isEmpty(nai)) {
String naiSuffix = getNaiSuffix();
@@ -25,7 +25,7 @@ import android.os.Build;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.util.ArrayMap;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.util.List;
import java.util.Map;
@@ -37,7 +37,6 @@ import java.util.Map;
*
*/
public class MmsConfigManager {
private static final String TAG = "MmsConfigManager";
private static volatile MmsConfigManager sInstance = new MmsConfigManager();
@@ -63,7 +62,7 @@ public class MmsConfigManager {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i(TAG, "mReceiver action: " + action);
Timber.i("mReceiver action: " + action);
if (action.equals("LOADED")) {
loadInBackground();
}
@@ -116,7 +115,7 @@ public class MmsConfigManager {
Configuration configuration = mContext.getResources().getConfiguration();
// Always put the mnc/mcc in the log so we can tell which mms_config.xml
// was loaded.
Log.i(TAG, "MmsConfigManager.loadInBackground(): mcc/mnc: " +
Timber.i("MmsConfigManager.loadInBackground(): mcc/mnc: " +
configuration.mcc + "/" + configuration.mnc);
load(mContext);
}
@@ -137,7 +136,7 @@ public class MmsConfigManager {
synchronized(mSubIdConfigMap) {
mmsConfig = mSubIdConfigMap.get(subId);
}
Log.i(TAG, "getMmsConfigBySubId -- for sub: " + subId + " mmsConfig: " + mmsConfig);
Timber.i("getMmsConfigBySubId -- for sub: " + subId + " mmsConfig: " + mmsConfig);
return mmsConfig;
}
@@ -155,7 +154,7 @@ public class MmsConfigManager {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
List<SubscriptionInfo> subs = mSubscriptionManager.getActiveSubscriptionInfoList();
if (subs == null || subs.size() < 1) {
Log.e(TAG, "MmsConfigManager.load -- empty getActiveSubInfoList");
Timber.e("MmsConfigManager.load -- empty getActiveSubInfoList");
return;
}
// Load all the mms_config.xml files in a separate map and then swap with the
@@ -167,11 +166,11 @@ public class MmsConfigManager {
Configuration config = mContext.getResources().getConfiguration();
configuration.mcc = config.mcc;
configuration.mnc = config.mnc;
Log.i(TAG, "MmsConfigManager.load -- no mcc/mnc for sub: " + sub +
Timber.i("MmsConfigManager.load -- no mcc/mnc for sub: " + sub +
" using mcc/mnc from main context: " + configuration.mcc + "/" +
configuration.mnc);
} else {
Log.i(TAG, "MmsConfigManager.load -- mcc/mnc for sub: " + sub);
Timber.i("MmsConfigManager.load -- mcc/mnc for sub: " + sub);
configuration.mcc = sub.getMcc();
configuration.mnc = sub.getMnc();
@@ -17,9 +17,9 @@
package com.android.mms.service_alt;
import android.content.ContentValues;
import com.klinker.android.logger.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import timber.log.Timber;
import java.io.IOException;
@@ -27,7 +27,6 @@ import java.io.IOException;
* XML processor for mms_config.xml
*/
public class MmsConfigXmlProcessor {
private static final String TAG = "MmsConfigXmlProcessor";
public interface MmsConfigHandler {
public void process(String key, String value, String type);
@@ -92,9 +91,9 @@ public class MmsConfigXmlProcessor {
processMmsConfig();
}
} catch (IOException e) {
Log.e(TAG, "MmsConfigXmlProcessor: I/O failure " + e, e);
Timber.e(e, "MmsConfigXmlProcessor: I/O failure " + e);
} catch (XmlPullParserException e) {
Log.e(TAG, "MmsConfigXmlProcessor: parsing failure " + e, e);
Timber.e(e, "MmsConfigXmlProcessor: parsing failure " + e);
}
}
@@ -132,7 +131,7 @@ public class MmsConfigXmlProcessor {
}
return mLogStringBuilder.toString();
} catch (XmlPullParserException e) {
Log.e(TAG, "xmlParserDebugContext: " + e, e);
Timber.e(e, "xmlParserDebugContext: " + e);
}
}
return "Unknown";
@@ -190,7 +189,7 @@ public class MmsConfigXmlProcessor {
mMmsConfigHandler.process(key, value, type);
}
} else {
Log.w(TAG, "MmsConfig: invalid key=" + key + " or type=" + type);
Timber.w("MmsConfig: invalid key=" + key + " or type=" + type);
}
}
}
@@ -18,7 +18,6 @@ package com.android.mms.service_alt;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.android.mms.service_alt.exception.MmsHttpException;
import com.squareup.okhttp.ConnectionPool;
import com.squareup.okhttp.ConnectionSpec;
@@ -29,6 +28,7 @@ import com.squareup.okhttp.Response;
import com.squareup.okhttp.internal.Internal;
import com.squareup.okhttp.internal.huc.HttpURLConnectionImpl;
import com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl;
import timber.log.Timber;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
@@ -60,7 +60,6 @@ import java.util.regex.Pattern;
* MMS HTTP client for sending and downloading MMS messages
*/
public class MmsHttpClient {
private static final String TAG = "MmsHttpClient";
public static final String METHOD_POST = "POST";
public static final String METHOD_GET = "GET";
@@ -117,7 +116,7 @@ public class MmsHttpClient {
public byte[] execute(String urlString, byte[] pdu, String method, boolean isProxySet,
String proxyHost, int proxyPort, MmsConfig.Overridden mmsConfig)
throws MmsHttpException {
Log.d(TAG, "HTTP: " + method + " " + redactUrlForNonVerbose(urlString)
Timber.d("HTTP: " + method + " " + urlString
+ (isProxySet ? (", proxy=" + proxyHost + ":" + proxyPort) : "")
+ ", PDU size=" + (pdu != null ? pdu.length : 0));
checkMethod(method);
@@ -140,13 +139,13 @@ public class MmsHttpClient {
HEADER_ACCEPT_LANGUAGE, getCurrentAcceptLanguage(Locale.getDefault()));
// Header: User-Agent
final String userAgent = mmsConfig.getUserAgent();
Log.i(TAG, "HTTP: User-Agent=" + userAgent);
Timber.i("HTTP: User-Agent=" + userAgent);
connection.setRequestProperty(HEADER_USER_AGENT, userAgent);
// Header: x-wap-profile
final String uaProfUrlTagName = mmsConfig.getUaProfTagName();
final String uaProfUrl = mmsConfig.getUaProfUrl();
if (uaProfUrl != null) {
Log.i(TAG, "HTTP: UaProfUrl=" + uaProfUrl);
Timber.i("HTTP: UaProfUrl=" + uaProfUrl);
connection.setRequestProperty(uaProfUrlTagName, uaProfUrl);
}
// Add extra headers specified by mms_config.xml's httpparams
@@ -154,7 +153,7 @@ public class MmsHttpClient {
// Different stuff for GET and POST
if (METHOD_POST.equals(method)) {
if (pdu == null || pdu.length < 1) {
Log.e(TAG, "HTTP: empty pdu");
Timber.e("HTTP: empty pdu");
throw new MmsHttpException(0/*statusCode*/, "Sending empty PDU");
}
connection.setDoOutput(true);
@@ -166,29 +165,22 @@ public class MmsHttpClient {
connection.setRequestProperty(HEADER_CONTENT_TYPE,
HEADER_VALUE_CONTENT_TYPE_WITHOUT_CHARSET);
}
if (Log.isLoggable(TAG, Log.VERBOSE)) {
logHttpHeaders(connection.getRequestProperties());
}
logHttpHeaders(connection.getRequestProperties());
connection.setFixedLengthStreamingMode(pdu.length);
// Sending request body
final OutputStream out =
new BufferedOutputStream(connection.getOutputStream());
final OutputStream out = new BufferedOutputStream(connection.getOutputStream());
out.write(pdu);
out.flush();
out.close();
} else if (METHOD_GET.equals(method)) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
logHttpHeaders(connection.getRequestProperties());
}
logHttpHeaders(connection.getRequestProperties());
connection.setRequestMethod(METHOD_GET);
}
// Get response
final int responseCode = connection.getResponseCode();
final String responseMessage = connection.getResponseMessage();
Log.d(TAG, "HTTP: " + responseCode + " " + responseMessage);
if (Log.isLoggable(TAG, Log.VERBOSE)) {
logHttpHeaders(connection.getHeaderFields());
}
Timber.d("HTTP: " + responseCode + " " + responseMessage);
logHttpHeaders(connection.getHeaderFields());
if (responseCode / 100 != 2) {
throw new MmsHttpException(responseCode, responseMessage);
}
@@ -201,19 +193,17 @@ public class MmsHttpClient {
}
in.close();
final byte[] responseBody = byteOut.toByteArray();
Log.d(TAG, "HTTP: response size="
Timber.d("HTTP: response size="
+ (responseBody != null ? responseBody.length : 0));
return responseBody;
} catch (MalformedURLException e) {
final String redactedUrl = redactUrlForNonVerbose(urlString);
Log.e(TAG, "HTTP: invalid URL " + redactedUrl, e);
throw new MmsHttpException(0/*statusCode*/, "Invalid URL " + redactedUrl, e);
Timber.e(e, "HTTP: invalid URL " + urlString);
throw new MmsHttpException(0/*statusCode*/, "Invalid URL " + urlString, e);
} catch (ProtocolException e) {
final String redactedUrl = redactUrlForNonVerbose(urlString);
Log.e(TAG, "HTTP: invalid URL protocol " + redactedUrl, e);
throw new MmsHttpException(0/*statusCode*/, "Invalid URL protocol " + redactedUrl, e);
Timber.e(e, "HTTP: invalid URL protocol " + urlString);
throw new MmsHttpException(0/*statusCode*/, "Invalid URL protocol " + urlString, e);
} catch (IOException e) {
Log.e(TAG, "HTTP: IO failure", e);
Timber.e(e, "HTTP: IO failure");
throw new MmsHttpException(0/*statusCode*/, e);
} finally {
if (connection != null) {
@@ -328,7 +318,7 @@ public class MmsHttpClient {
}
}
}
Log.v(TAG, "HTTP: headers\n" + sb.toString());
Timber.v("HTTP: headers\n" + sb.toString());
}
}
@@ -423,7 +413,7 @@ public class MmsHttpClient {
if (macroValue != null) {
replaced.append(macroValue);
} else {
Log.w(TAG, "HTTP: invalid macro " + macro);
Timber.w("HTTP: invalid macro " + macro);
}
nextStart = matcher.end();
}
@@ -459,35 +449,4 @@ public class MmsHttpClient {
}
}
}
/**
* Redact the URL for non-VERBOSE logging. Replace url with only the host part and the length
* of the input URL string.
*
* @param urlString
* @return
*/
public static String redactUrlForNonVerbose(String urlString) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
// Don't redact for VERBOSE level logging
return urlString;
}
if (TextUtils.isEmpty(urlString)) {
return urlString;
}
String protocol = "http";
String host = "";
try {
final URL url = new URL(urlString);
protocol = url.getProtocol();
host = url.getHost();
} catch (MalformedURLException e) {
// Ignore
}
// Print "http://host[length]"
final StringBuilder sb = new StringBuilder();
sb.append(protocol).append("://").append(host)
.append("[").append(urlString.length()).append("]");
return sb.toString();
}
}
@@ -26,14 +26,14 @@ import android.net.SSLCertificateSocketFactory;
import android.os.Build;
import android.os.SystemClock;
import com.android.mms.service_alt.exception.MmsNetworkException;
import com.klinker.android.logger.Log;
import com.squareup.okhttp.ConnectionPool;
import timber.log.Timber;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
private static final String TAG = "MmsNetworkManager";
// Timeout used to call ConnectivityManager.requestNetwork
private static final int NETWORK_REQUEST_TIMEOUT_MILLIS = 60 * 1000;
// Wait timeout for this class, a little bit longer than the above timeout
@@ -118,10 +118,10 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
mMmsRequestCount += 1;
if (mNetwork != null) {
// Already available
Log.d(TAG, "MmsNetworkManager: already available");
Timber.d("MmsNetworkManager: already available");
return mNetwork;
}
Log.d(TAG, "MmsNetworkManager: start new network request");
Timber.d("MmsNetworkManager: start new network request");
// Not available, so start a new request
newRequest();
final long shouldEnd = SystemClock.elapsedRealtime() + NETWORK_ACQUIRE_TIMEOUT_MILLIS;
@@ -130,7 +130,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
try {
this.wait(waitTime);
} catch (InterruptedException e) {
Log.w(TAG, "MmsNetworkManager: acquire network wait interrupted");
Timber.w("MmsNetworkManager: acquire network wait interrupted");
}
if (mNetwork != null || permissionError) {
// Success
@@ -140,7 +140,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
waitTime = shouldEnd - SystemClock.elapsedRealtime();
}
// Timed out, so release the request and fail
Log.d(TAG, "MmsNetworkManager: timed out");
Timber.d("MmsNetworkManager: timed out");
releaseRequestLocked(mNetworkCallback);
throw new MmsNetworkException("Acquiring network timed out");
}
@@ -153,7 +153,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
synchronized (this) {
if (mMmsRequestCount > 0) {
mMmsRequestCount -= 1;
Log.d(TAG, "MmsNetworkManager: release, count=" + mMmsRequestCount);
Timber.d("MmsNetworkManager: release, count=" + mMmsRequestCount);
if (mMmsRequestCount < 1) {
releaseRequestLocked(mNetworkCallback);
}
@@ -171,7 +171,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
Log.d(TAG, "NetworkCallbackListener.onAvailable: network=" + network);
Timber.d("NetworkCallbackListener.onAvailable: network=" + network);
synchronized (MmsNetworkManager.this) {
mNetwork = network;
MmsNetworkManager.this.notifyAll();
@@ -181,7 +181,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
@Override
public void onLost(Network network) {
super.onLost(network);
Log.d(TAG, "NetworkCallbackListener.onLost: network=" + network);
Timber.d("NetworkCallbackListener.onLost: network=" + network);
synchronized (MmsNetworkManager.this) {
releaseRequestLocked(this);
MmsNetworkManager.this.notifyAll();
@@ -191,7 +191,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
// @Override
// public void onUnavailable() {
// super.onUnavailable();
// Log.d(TAG, "NetworkCallbackListener.onUnavailable");
// Timber.d("NetworkCallbackListener.onUnavailable");
// synchronized (MmsNetworkManager.this) {
// releaseRequestLocked(this);
// MmsNetworkManager.this.notifyAll();
@@ -203,7 +203,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
connectivityManager.requestNetwork(
mNetworkRequest, mNetworkCallback);
} catch (SecurityException e) {
Log.e(TAG, "permission exception... skipping it for testing purposes", e);
Timber.e(e, "permission exception... skipping it for testing purposes");
permissionError = true;
}
}
@@ -220,7 +220,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
try {
connectivityManager.unregisterNetworkCallback(callback);
} catch (Exception e) {
Log.e(TAG, "couldn't unregister", e);
Timber.e(e, "couldn't unregister");
}
}
resetLocked();
@@ -306,7 +306,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
Network network = null;
synchronized (this) {
if (mNetwork == null) {
Log.d(TAG, "MmsNetworkManager: getApnName: network not available");
Timber.d("MmsNetworkManager: getApnName: network not available");
mNetworkRequest = new NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.build();
@@ -320,7 +320,7 @@ public class MmsNetworkManager implements com.squareup.okhttp.internal.Network {
if (mmsNetworkInfo != null) {
apnName = mmsNetworkInfo.getExtraInfo();
}
Log.d(TAG, "MmsNetworkManager: getApnName: " + apnName);
Timber.d("MmsNetworkManager: getApnName: " + apnName);
return apnName;
}
@@ -32,14 +32,13 @@ import android.telephony.SmsManager;
import android.telephony.TelephonyManager;
import com.android.mms.service_alt.exception.ApnException;
import com.android.mms.service_alt.exception.MmsHttpException;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.Utils;
import timber.log.Timber;
/**
* Base class for MMS requests. This has the common logic of sending/downloading MMS.
*/
public abstract class MmsRequest {
private static final String TAG = "MmsRequest";
private static final int RETRY_TIMES = 3;
@@ -153,21 +152,21 @@ public abstract class MmsRequest {
}
mobileDataEnabled = Utils.isMobileDataEnabled(context);
Log.v(TAG, "mobile data enabled: " + mobileDataEnabled);
Timber.v("mobile data enabled: " + mobileDataEnabled);
if (!mobileDataEnabled && !useWifi(context)) {
Log.v(TAG, "mobile data not enabled, so forcing it to enable");
Timber.v("mobile data not enabled, so forcing it to enable");
Utils.setMobileDataEnabled(context, true);
}
if (!ensureMmsConfigLoaded()) { // Check mms config
Log.e(TAG, "MmsRequest: mms config is not loaded yet");
Timber.e("MmsRequest: mms config is not loaded yet");
result = SmsManager.MMS_ERROR_CONFIGURATION_ERROR;
} else if (!prepareForHttpRequest()) { // Prepare request, like reading pdu data from user
Log.e(TAG, "MmsRequest: failed to prepare for request");
Timber.e("MmsRequest: failed to prepare for request");
result = SmsManager.MMS_ERROR_IO_ERROR;
} else if (!isDataNetworkAvailable(context, mSubId)) {
Log.e(TAG, "MmsRequest: in airplane mode or mobile data disabled");
Timber.e("MmsRequest: in airplane mode or mobile data disabled");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
result = SmsManager.MMS_ERROR_NO_DATA_NETWORK;
} else {
@@ -181,7 +180,7 @@ public abstract class MmsRequest {
try {
networkManager.acquireNetwork();
} catch (Exception e) {
Log.e(TAG, "error acquiring network", e);
Timber.e(e, "error acquiring network");
}
final String apnName = networkManager.getApnName();
@@ -195,11 +194,11 @@ public abstract class MmsRequest {
// If the APN name was already null then don't need to retry
throw (e);
}
Log.i(TAG, "MmsRequest: No match with APN name:"
Timber.i("MmsRequest: No match with APN name:"
+ apnName + ", try with no name");
apn = ApnSettings.load(context, null, mSubId);
}
Log.i(TAG, "MmsRequest: using " + apn.toString());
Timber.i("MmsRequest: using " + apn.toString());
response = doHttp(context, networkManager, apn);
result = Activity.RESULT_OK;
// Success
@@ -208,20 +207,20 @@ public abstract class MmsRequest {
networkManager.releaseNetwork();
}
} catch (ApnException e) {
Log.e(TAG, "MmsRequest: APN failure", e);
Timber.e(e, "MmsRequest: APN failure");
result = SmsManager.MMS_ERROR_INVALID_APN;
break;
// } catch (MmsNetworkException e) {
// Log.e(TAG, "MmsRequest: MMS network acquiring failure", e);
// Timber.e(e, "MmsRequest: MMS network acquiring failure");
// result = SmsManager.MMS_ERROR_UNABLE_CONNECT_MMS;
// // Retry
} catch (MmsHttpException e) {
Log.e(TAG, "MmsRequest: HTTP or network I/O failure", e);
Timber.e(e, "MmsRequest: HTTP or network I/O failure");
result = SmsManager.MMS_ERROR_HTTP_FAILURE;
httpStatusCode = e.getStatusCode();
// Retry
} catch (Exception e) {
Log.e(TAG, "MmsRequest: unexpected failure", e);
Timber.e(e, "MmsRequest: unexpected failure");
result = SmsManager.MMS_ERROR_UNSPECIFIED;
break;
}
@@ -234,7 +233,7 @@ public abstract class MmsRequest {
}
if (!mobileDataEnabled) {
Log.v(TAG, "setting mobile data back to disabled");
Timber.v("setting mobile data back to disabled");
Utils.setMobileDataEnabled(context, false);
}
@@ -281,7 +280,7 @@ public abstract class MmsRequest {
}
pendingIntent.send(context, result, fillIn);
} catch (PendingIntent.CanceledException e) {
Log.e(TAG, "MmsRequest: sending pending intent canceled", e);
Timber.e(e, "MmsRequest: sending pending intent canceled");
}
}
@@ -313,7 +312,7 @@ public abstract class MmsRequest {
== CarrierMessagingService.SEND_STATUS_RETRY_ON_CARRIER_NETWORK
|| carrierMessagingAppResult
== CarrierMessagingService.DOWNLOAD_STATUS_RETRY_ON_CARRIER_NETWORK) {
Log.d(TAG, "Sending/downloading MMS by IP failed.");
Timber.d("Sending/downloading MMS by IP failed.");
mRequestManager.addSimRequest(MmsRequest.this);
return true;
} else {
@@ -18,10 +18,10 @@ package com.android.mms.service_alt;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import com.android.i18n.phonenumbers.NumberParseException;
import com.android.i18n.phonenumbers.PhoneNumberUtil;
import com.android.i18n.phonenumbers.Phonenumber;
import timber.log.Timber;
import java.lang.reflect.Method;
import java.util.Locale;
@@ -31,8 +31,6 @@ import java.util.Locale;
*/
public class PhoneUtils {
private static final String TAG = "PhoneUtils";
/**
* Get a canonical national format phone number. If parsing fails, just return the
* original number.
@@ -63,12 +61,12 @@ public class PhoneUtils {
if (phoneNumberUtil.isValidNumber(phoneNumber)) {
return phoneNumber;
} else {
Log.e(TAG, "getParsedNumber: not a valid phone number"
Timber.e("getParsedNumber: not a valid phone number"
+ " for country " + country);
return null;
}
} catch (final NumberParseException e) {
Log.e(TAG, "getParsedNumber: Not able to parse phone number");
Timber.e("getParsedNumber: Not able to parse phone number");
return null;
}
}
@@ -6,11 +6,10 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.os.Build;
import android.provider.Telephony;
import android.util.Log;
import com.google.android.mms.util_alt.SqliteWrapper;
import timber.log.Timber;
class SubscriptionIdChecker {
private static final String TAG = "SubscriptionIdChecker";
private static SubscriptionIdChecker sInstance;
private boolean mCanUseSubscriptionId = false;
@@ -27,7 +26,7 @@ class SubscriptionIdChecker {
mCanUseSubscriptionId = true;
}
} catch (SQLiteException e) {
Log.e(TAG, "SubscriptionIdChecker.check() fail");
Timber.e("SubscriptionIdChecker.check() fail");
} finally {
if (c != null) {
c.close();
@@ -18,14 +18,12 @@ package com.android.mms.transaction;
import android.content.Context;
import android.util.Config;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import timber.log.Timber;
/**
* Default retry scheme, based on specs.
*/
public class DefaultRetryScheme extends AbstractRetryScheme {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV;
@@ -50,7 +48,7 @@ public class DefaultRetryScheme extends AbstractRetryScheme {
@Override
public long getWaitingInterval() {
if (LOCAL_LOGV) {
Log.v(TAG, "Next int: " + sDefaultRetryScheme[mRetriedTimes]);
Timber.v("Next int: " + sDefaultRetryScheme[mRetriedTimes]);
}
return sDefaultRetryScheme[mRetriedTimes];
}
@@ -16,9 +16,9 @@ import android.provider.Telephony;
import android.telephony.SmsManager;
import android.text.TextUtils;
import com.android.mms.MmsConfig;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.BroadcastUtils;
import com.klinker.android.send_message.MmsReceivedReceiver;
import timber.log.Timber;
import java.io.File;
import java.util.Random;
@@ -30,7 +30,6 @@ import java.util.concurrent.ConcurrentHashMap;
* We should manage to call SMSManager.downloadMultimediaMessage().
*/
public class DownloadManager {
private static final String TAG = "DownloadManager";
private static DownloadManager ourInstance = new DownloadManager();
private static final ConcurrentHashMap<String, MmsDownloadReceiver> mMap = new ConcurrentHashMap<>();
@@ -58,7 +57,7 @@ public class DownloadManager {
// Use unique action in order to avoid cancellation of notifying download result.
context.getApplicationContext().registerReceiver(receiver, new IntentFilter(receiver.mAction));
Log.v(TAG, "receiving with system method");
Timber.v("receiving with system method");
final String fileName = "download." + String.valueOf(Math.abs(new Random().nextLong())) + ".dat";
File mDownloadFile = new File(context.getCacheDir(), fileName);
Uri contentUri = (new Uri.Builder())
@@ -22,8 +22,6 @@ import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Config;
import com.android.mms.MmsConfig;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -35,6 +33,7 @@ import org.apache.http.conn.params.ConnRouteParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import timber.log.Timber;
import java.io.DataInputStream;
import java.io.IOException;
@@ -44,7 +43,6 @@ import java.net.URISyntaxException;
import java.util.Locale;
public class HttpUtils {
private static final String TAG = LogTag.TRANSACTION;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = DEBUG ? Config.LOGD : Config.LOGV;
@@ -95,19 +93,16 @@ public class HttpUtils {
throw new IllegalArgumentException("URL must not be null.");
}
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "httpConnection: params list");
Log.v(TAG, "\ttoken\t\t= " + token);
Log.v(TAG, "\turl\t\t= " + url);
Log.v(TAG, "\tmethod\t\t= "
+ ((method == HTTP_POST_METHOD) ? "POST"
: ((method == HTTP_GET_METHOD) ? "GET" : "UNKNOWN")));
Log.v(TAG, "\tisProxySet\t= " + isProxySet);
Log.v(TAG, "\tproxyHost\t= " + proxyHost);
Log.v(TAG, "\tproxyPort\t= " + proxyPort);
// TODO Print out binary data more readable.
//Log.v(TAG, "\tpdu\t\t= " + Arrays.toString(pdu));
}
Timber.v("httpConnection: params list");
Timber.v("\ttoken\t\t= " + token);
Timber.v("\turl\t\t= " + url);
Timber.v("\tmethod\t\t= " + ((method == HTTP_POST_METHOD) ? "POST"
: ((method == HTTP_GET_METHOD) ? "GET" : "UNKNOWN")));
Timber.v("\tisProxySet\t= " + isProxySet);
Timber.v("\tproxyHost\t= " + proxyHost);
Timber.v("\tproxyPort\t= " + proxyPort);
// TODO Print out binary data more readable.
//Timber.v("\tpdu\t\t= " + Arrays.toString(pdu));
AndroidHttpClient client = null;
@@ -135,7 +130,7 @@ public class HttpUtils {
req = new HttpGet(url);
break;
default:
Log.e(TAG, "Unknown HTTP method: " + method
Timber.e("Unknown HTTP method: " + method
+ ". Must be one of POST[" + HTTP_POST_METHOD
+ "] or GET[" + HTTP_GET_METHOD + "].");
return null;
@@ -155,10 +150,7 @@ public class HttpUtils {
String xWapProfileTagName = MmsConfig.getUaProfTagName();
String xWapProfileUrl = MmsConfig.getUaProfUrl();
if (xWapProfileUrl != null) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.d(LogTag.TRANSACTION,
"[HttpUtils] httpConn: xWapProfUrl=" + xWapProfileUrl);
}
Timber.d("[HttpUtils] httpConn: xWapProfUrl=" + xWapProfileUrl);
req.addHeader(xWapProfileTagName, xWapProfileUrl);
}
}
@@ -214,12 +206,12 @@ public class HttpUtils {
try {
dis.close();
} catch (IOException e) {
Log.e(TAG, "Error closing input stream: " + e.getMessage());
Timber.e("Error closing input stream: " + e.getMessage());
}
}
}
if (entity.isChunked()) {
Log.v(TAG, "httpConnection: transfer encoding is chunked");
Timber.v("httpConnection: transfer encoding is chunked");
int bytesTobeRead = MmsConfig.getMaxMessageSize();
byte[] tempBody = new byte[bytesTobeRead];
DataInputStream dis = new DataInputStream(entity.getContent());
@@ -232,8 +224,7 @@ public class HttpUtils {
bytesRead = dis.read(tempBody, offset, bytesTobeRead);
} catch (IOException e) {
readError = true;
Log.e(TAG, "httpConnection: error reading input stream"
+ e.getMessage());
Timber.e("httpConnection: error reading input stream" + e.getMessage());
break;
}
if (bytesRead > 0) {
@@ -246,16 +237,15 @@ public class HttpUtils {
// bytesRead will be -1 if the data was read till the eof
body = new byte[offset];
System.arraycopy(tempBody, 0, body, 0, offset);
Log.v(TAG, "httpConnection: Chunked response length ["
+ Integer.toString(offset) + "]");
Timber.v("httpConnection: Chunked response length [" + Integer.toString(offset) + "]");
} else {
Log.e(TAG, "httpConnection: Response entity too large or empty");
Timber.e("httpConnection: Response entity too large or empty");
}
} finally {
try {
dis.close();
} catch (IOException e) {
Log.e(TAG, "Error closing input stream: " + e.getMessage());
Timber.e("Error closing input stream: " + e.getMessage());
}
}
}
@@ -288,7 +278,7 @@ public class HttpUtils {
private static void handleHttpConnectionException(Exception exception, String url)
throws IOException {
// Inner exception should be logged to make life easier.
Log.e(TAG, "Url: " + url + "\n" + exception.getMessage());
Timber.e("Url: " + url + "\n" + exception.getMessage());
IOException e = new IOException(exception.getMessage());
e.initCause(exception);
throw e;
@@ -303,10 +293,7 @@ public class HttpUtils {
// set the socket timeout
int soTimeout = MmsConfig.getHttpSocketTimeout();
if (Log.isLoggable(LogTag.TRANSACTION, Log.DEBUG)) {
Log.d(TAG, "[HttpUtils] createHttpClient w/ socket timeout " + soTimeout + " ms, "
+ ", UA=" + userAgent);
}
Timber.d("[HttpUtils] createHttpClient w/ socket timeout " + soTimeout + " ms, " + ", UA=" + userAgent);
HttpConnectionParams.setSoTimeout(params, soTimeout);
return client;
}
@@ -27,8 +27,7 @@ import android.net.Uri;
import android.provider.Telephony.Sms;
import android.provider.Telephony.Sms.Inbox;
import android.telephony.SmsMessage;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import timber.log.Timber;
/**
* Service that gets started by the MessageStatusReceiver when a message status report is
@@ -36,7 +35,6 @@ import com.klinker.android.logger.Log;
*/
public class MessageStatusService extends IntentService {
private static final String[] ID_PROJECTION = new String[] { Sms._ID };
private static final String LOG_TAG = LogTag.TAG;
private static final Uri STATUS_URI = Uri.parse("content://sms/status");
public MessageStatusService() {
@@ -88,10 +86,8 @@ public class MessageStatusService extends IntentService {
boolean isStatusReport = message.isStatusReportMessage();
ContentValues contentValues = new ContentValues(2);
if (Log.isLoggable(LogTag.TAG, Log.DEBUG)) {
log("updateMessageStatus: msgUrl=" + messageUri + ", status=" + status +
", isStatusReport=" + isStatusReport);
}
log("updateMessageStatus: msgUrl=" + messageUri + ", status=" + status
+ ", isStatusReport=" + isStatusReport);
contentValues.put(Sms.STATUS, status);
contentValues.put(Inbox.DATE_SENT, System.currentTimeMillis());
@@ -107,10 +103,10 @@ public class MessageStatusService extends IntentService {
}
private void error(String message) {
Log.e(LOG_TAG, "[MessageStatusReceiver] " + message);
Timber.e("[MessageStatusReceiver] " + message);
}
private void log(String message) {
Log.d(LOG_TAG, "[MessageStatusReceiver] " + message);
Timber.d("[MessageStatusReceiver] " + message);
}
}
@@ -18,8 +18,7 @@ package com.android.mms.transaction;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import timber.log.Timber;
/**
* MmsPushOutboxMessages listens for MMS_SEND_OUTBOX_MSG intent .
@@ -30,16 +29,13 @@ import com.klinker.android.logger.Log;
*/
public class MmsPushOutboxMessages extends BroadcastReceiver {
private static final String INTENT_MMS_SEND_OUTBOX_MSG = "android.intent.action.MMS_SEND_OUTBOX_MSG";
private static final String TAG = LogTag.TAG;
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Received the MMS_SEND_OUTBOX_MSG intent: " + intent);
}
Timber.v("Received the MMS_SEND_OUTBOX_MSG intent: " + intent);
String action = intent.getAction();
if(action.equalsIgnoreCase(INTENT_MMS_SEND_OUTBOX_MSG)){
Log.d(TAG,"Now waking up the MMS service");
Timber.d("Now waking up the MMS service");
context.startService(new Intent(context, TransactionService.class));
}
}
@@ -23,9 +23,8 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.provider.Telephony.Mms;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.Utils;
import timber.log.Timber;
/**
* MmsSystemEventReceiver receives the
@@ -37,7 +36,6 @@ import com.klinker.android.send_message.Utils;
* </ul>
*/
public class MmsSystemEventReceiver extends BroadcastReceiver {
private static final String TAG = LogTag.TAG;
private static ConnectivityManager mConnMgr = null;
public static void wakeUpService(Context context) {
@@ -45,12 +43,10 @@ public class MmsSystemEventReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Intent received: " + intent);
}
Timber.v("Intent received: " + intent);
if (!Utils.isDefaultSmsApp(context)) {
Log.v(TAG, "not default sms app, cancelling");
Timber.v("not default sms app, cancelling");
return;
}
@@ -66,28 +62,24 @@ public class MmsSystemEventReceiver extends BroadcastReceiver {
if (Utils.isMmsOverWifiEnabled(context)) {
NetworkInfo niWF = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if ((niWF != null) && (niWF.isConnected())) {
Log.v(TAG, "TYPE_WIFI connected");
Timber.v("TYPE_WIFI connected");
wakeUpService(context);
}
} else {
boolean mobileDataEnabled = Utils.isMobileDataEnabled(context);
if (!mobileDataEnabled) {
Log.v(TAG, "mobile data turned off, bailing");
Timber.v("mobile data turned off, bailing");
//Utils.setMobileDataEnabled(context, true);
return;
}
NetworkInfo mmsNetworkInfo = mConnMgr
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS);
NetworkInfo mmsNetworkInfo = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS);
if (mmsNetworkInfo == null) {
return;
}
boolean available = mmsNetworkInfo.isAvailable();
boolean isConnected = mmsNetworkInfo.isConnected();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "TYPE_MOBILE_MMS available = " + available +
", isConnected = " + isConnected);
}
Timber.v("TYPE_MOBILE_MMS available = " + available + ", isConnected = " + isConnected);
// Wake up transact service when MMS data is available and isn't connected.
if (available && !isConnected) {
@@ -29,7 +29,6 @@ import android.provider.Telephony.Mms.Inbox;
import android.provider.Telephony.Threads;
import android.telephony.TelephonyManager;
import com.android.mms.MmsConfig;
import com.android.mms.logs.LogTag;
import com.android.mms.util.DownloadManager;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu_alt.GenericPdu;
@@ -39,18 +38,13 @@ import com.google.android.mms.pdu_alt.PduComposer;
import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.BroadcastUtils;
import timber.log.Timber;
import java.io.IOException;
import static com.android.mms.transaction.TransactionState.FAILED;
import static com.android.mms.transaction.TransactionState.INITIALIZED;
import static com.android.mms.transaction.TransactionState.SUCCESS;
import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF;
import static com.google.android.mms.pdu_alt.PduHeaders.STATUS_DEFERRED;
import static com.google.android.mms.pdu_alt.PduHeaders.STATUS_RETRIEVED;
import static com.google.android.mms.pdu_alt.PduHeaders.STATUS_UNRECOGNIZED;
import static com.android.mms.transaction.TransactionState.*;
import static com.google.android.mms.pdu_alt.PduHeaders.*;
/**
* The NotificationTransaction is responsible for handling multimedia
@@ -69,8 +63,6 @@ import static com.google.android.mms.pdu_alt.PduHeaders.STATUS_UNRECOGNIZED;
* in case the client is in immediate retrieve mode.
*/
public class NotificationTransaction extends Transaction implements Runnable {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private Uri mUri;
@@ -88,7 +80,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
mNotificationInd = (NotificationInd)
PduPersister.getPduPersister(context).load(mUri);
} catch (MmsException e) {
Log.e(TAG, "Failed to load NotificationInd from: " + uriString, e);
Timber.e(e, "Failed to load NotificationInd from: " + uriString);
throw new IllegalArgumentException();
}
@@ -114,7 +106,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
ind, Inbox.CONTENT_URI, !allowAutoDownload(mContext),
true, null);
} catch (MmsException e) {
Log.e(TAG, "Failed to save NotificationInd in constructor.", e);
Timber.e(e, "Failed to save NotificationInd in constructor.");
throw new IllegalArgumentException();
}
@@ -146,7 +138,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
boolean autoDownload = allowAutoDownload(mContext);
try {
if (LOCAL_LOGV) {
Log.v(TAG, "Notification transaction launched: " + this);
Timber.v("Notification transaction launched: " + this);
}
// By default, we set status to STATUS_DEFERRED because we
@@ -163,7 +155,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
downloadManager.markState(mUri, DownloadManager.STATE_DOWNLOADING);
if (LOCAL_LOGV) {
Log.v(TAG, "Content-Location: " + mContentLocation);
Timber.v("Content-Location: " + mContentLocation);
}
byte[] retrieveConfData = null;
@@ -178,7 +170,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
if (retrieveConfData != null) {
GenericPdu pdu = new PduParser(retrieveConfData).parse();
if ((pdu == null) || (pdu.getMessageType() != MESSAGE_TYPE_RETRIEVE_CONF)) {
Log.e(TAG, "Invalid M-RETRIEVE.CONF PDU. " +
Timber.e("Invalid M-RETRIEVE.CONF PDU. " +
(pdu != null ? "message type: " + pdu.getMessageType() : "null pdu"));
mTransactionState.setState(FAILED);
status = STATUS_UNRECOGNIZED;
@@ -198,7 +190,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
// M-NotifyResp.ind from Inbox.
SqliteWrapper.delete(mContext, mContext.getContentResolver(),
mUri, null, null);
Log.v(TAG, "NotificationTransaction received new mms message: " + uri);
Timber.v("NotificationTransaction received new mms message: " + uri);
// Delete obsolete threads
SqliteWrapper.delete(mContext, mContext.getContentResolver(),
Threads.OBSOLETE_THREADS_URI, null, null);
@@ -214,7 +206,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
}
if (LOCAL_LOGV) {
Log.v(TAG, "status=0x" + Integer.toHexString(status));
Timber.v("status=0x" + Integer.toHexString(status));
}
// Check the status and update the result state of this Transaction.
@@ -232,7 +224,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
sendNotifyRespInd(status);
} catch (Throwable t) {
Log.e(TAG, "error", t);
Timber.e(t, "error");
} finally {
mTransactionState.setContentUri(mUri);
if (!autoDownload) {
@@ -242,7 +234,7 @@ public class NotificationTransaction extends Transaction implements Runnable {
}
if (mTransactionState.getState() != SUCCESS) {
mTransactionState.setState(FAILED);
Log.e(TAG, "NotificationTransaction failed.");
Timber.e("NotificationTransaction failed.");
}
notifyObservers();
}
@@ -29,7 +29,6 @@ import android.os.AsyncTask;
import android.provider.Telephony.Mms;
import android.provider.Telephony.Mms.Inbox;
import com.android.mms.MmsConfig;
import com.android.mms.logs.LogTag;
import com.google.android.mms.ContentType;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu_alt.DeliveryInd;
@@ -39,7 +38,7 @@ import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.ReadOrigInd;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.util.HashSet;
import java.util.Set;
@@ -48,16 +47,13 @@ import java.util.concurrent.Executors;
import static android.provider.Telephony.Sms.Intents.WAP_PUSH_DELIVER_ACTION;
import static android.provider.Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION;
import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_DELIVERY_IND;
import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;
import static com.google.android.mms.pdu_alt.PduHeaders.MESSAGE_TYPE_READ_ORIG_IND;
import static com.google.android.mms.pdu_alt.PduHeaders.*;
/**
* Receives Intent.WAP_PUSH_RECEIVED_ACTION intents and starts the
* TransactionService by passing the push-data to it.
*/
public class PushReceiver extends BroadcastReceiver {
private static final String TAG = LogTag.TAG;
static final String[] PROJECTION = new String[]{Mms.CONTENT_LOCATION, Mms.LOCKED};
@@ -77,7 +73,7 @@ public class PushReceiver extends BroadcastReceiver {
@Override
protected Void doInBackground(Intent... intents) {
Log.v(TAG, "receiving a new mms message");
Timber.v("receiving a new mms message");
Intent intent = intents[0];
// Get raw PDU push-data from the message and parse it
@@ -86,7 +82,7 @@ public class PushReceiver extends BroadcastReceiver {
GenericPdu pdu = parser.parse();
if (pdu == null) {
Log.e(TAG, "Invalid PUSH data");
Timber.e("Invalid PUSH data");
return null;
}
@@ -142,30 +138,28 @@ public class PushReceiver extends BroadcastReceiver {
String location = getContentLocation(mContext, uri);
if (downloadedUrls.contains(location)) {
Log.v(TAG, "already added this download, don't download again");
Timber.v("already added this download, don't download again");
return null;
} else {
downloadedUrls.add(location);
}
Log.v(TAG, "receiving on a lollipop+ device");
DownloadManager.getInstance().downloadMultimediaMessage(mContext, location, uri, true);
} else {
Log.v(TAG, "Skip downloading duplicate message: " + new String(nInd.getContentLocation()));
Timber.v("Skip downloading duplicate message: " + new String(nInd.getContentLocation()));
}
break;
}
default:
Log.e(TAG, "Received unrecognized PDU.");
Timber.e("Received unrecognized PDU.");
}
} catch (MmsException e) {
Log.e(TAG, "Failed to save the data from PUSH: type=" + type, e);
Timber.e(e, "Failed to save the data from PUSH: type=" + type);
} catch (RuntimeException e) {
Log.e(TAG, "Unexpected RuntimeException.", e);
Timber.e(e, "Unexpected RuntimeException.");
}
Log.v(TAG, "PUSH Intent processed.");
Timber.v("PUSH Intent processed.");
return null;
}
@@ -178,15 +172,15 @@ public class PushReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG, intent.getAction() + " " + intent.getType());
Timber.v(intent.getAction() + " " + intent.getType());
if ((intent.getAction().equals(WAP_PUSH_DELIVER_ACTION) || intent.getAction().equals(WAP_PUSH_RECEIVED_ACTION))
&& ContentType.MMS_MESSAGE.equals(intent.getType())) {
Log.v(TAG, "Received PUSH Intent: " + intent);
Timber.v("Received PUSH Intent: " + intent);
MmsConfig.init(context);
new ReceivePushTask(context, goAsync()).executeOnExecutor(PUSH_RECEIVER_EXECUTOR, intent);
Log.v("mms_receiver", context.getPackageName() + " received and aborted");
Timber.v(context.getPackageName() + " received and aborted");
}
}
@@ -19,14 +19,13 @@ package com.android.mms.transaction;
import android.content.Context;
import android.net.Uri;
import android.provider.Telephony.Mms.Sent;
import com.android.mms.logs.LogTag;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu_alt.EncodedStringValue;
import com.google.android.mms.pdu_alt.PduComposer;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.ReadRecInd;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.Utils;
import timber.log.Timber;
import java.io.IOException;
@@ -42,8 +41,6 @@ import java.io.IOException;
* </ul>
*/
public class ReadRecTransaction extends Transaction implements Runnable{
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private Thread mThread;
@@ -91,15 +88,15 @@ public class ReadRecTransaction extends Transaction implements Runnable{
mTransactionState.setContentUri(uri);
} catch (IOException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Failed to send M-Read-Rec.Ind.", e);
Timber.v(e, "Failed to send M-Read-Rec.Ind.");
}
} catch (MmsException e) {
if (LOCAL_LOGV) {
Log.v(TAG, "Failed to load message from Outbox.", e);
Timber.v(e, "Failed to load message from Outbox.");
}
} catch (RuntimeException e) {
if (LOCAL_LOGV) {
Log.e(TAG, "Unexpected RuntimeException.", e);
Timber.e(e, "Unexpected RuntimeException.");
}
} finally {
if (mTransactionState.getState() != TransactionState.SUCCESS) {
@@ -25,7 +25,6 @@ import android.provider.Telephony.Mms;
import android.provider.Telephony.Mms.Inbox;
import android.text.TextUtils;
import com.android.mms.MmsConfig;
import com.android.mms.logs.LogTag;
import com.android.mms.util.DownloadManager;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu_alt.AcknowledgeInd;
@@ -35,8 +34,8 @@ import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.RetrieveConf;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.Utils;
import timber.log.Timber;
import java.io.IOException;
@@ -54,8 +53,6 @@ import java.io.IOException;
* </ul>
*/
public class RetrieveTransaction extends Transaction implements Runnable {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private final Uri mUri;
@@ -80,7 +77,7 @@ public class RetrieveTransaction extends Transaction implements Runnable {
mUri = Uri.parse(uri); // The Uri of the M-Notification.ind
mId = mContentLocation = getContentLocation(context, mUri);
if (LOCAL_LOGV) {
Log.v(TAG, "X-Mms-Content-Location: " + mContentLocation);
Timber.v("X-Mms-Content-Location: " + mContentLocation);
}
} else {
throw new IllegalArgumentException(
@@ -183,7 +180,7 @@ public class RetrieveTransaction extends Transaction implements Runnable {
// Don't mark the transaction as failed if we failed to send it.
sendAcknowledgeInd(retrieveConf);
} catch (Throwable t) {
Log.e(TAG, "error", t);
Timber.e(t, "error");
if ("HTTP error: Not Found".equals(t.getMessage())) {
// Delete the expired M-Notification.ind.
SqliteWrapper.delete(mContext, mContext.getContentResolver(),
@@ -193,7 +190,7 @@ public class RetrieveTransaction extends Transaction implements Runnable {
if (mTransactionState.getState() != TransactionState.SUCCESS) {
mTransactionState.setState(TransactionState.FAILED);
mTransactionState.setContentUri(mUri);
Log.e(TAG, "Retrieval failed.");
Timber.e("Retrieval failed.");
}
notifyObservers();
}
@@ -31,17 +31,14 @@ import android.net.Uri;
import android.provider.Telephony.Mms;
import android.provider.Telephony.MmsSms;
import android.provider.Telephony.MmsSms.PendingMessages;
import com.android.mms.logs.LogTag;
import com.android.mms.util.DownloadManager;
import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduPersister;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.BroadcastUtils;
import com.klinker.android.send_message.R;
import timber.log.Timber;
public class RetryScheduler implements Observer {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private final Context mContext;
@@ -71,9 +68,7 @@ public class RetryScheduler implements Observer {
try {
Transaction t = (Transaction) observable;
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "[RetryScheduler] update " + observable);
}
Timber.v("[RetryScheduler] update " + observable);
// We are only supposed to handle M-Notification.ind, M-Send.req
// and M-ReadRec.ind.
@@ -172,10 +167,8 @@ public class RetryScheduler implements Observer {
if ((retryIndex < scheme.getRetryLimit()) && retry) {
long retryAt = current + scheme.getWaitingInterval();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "scheduleRetry: retry for " + uri + " is scheduled at "
+ (retryAt - System.currentTimeMillis()) + "ms from now");
}
Timber.v("scheduleRetry: retry for " + uri + " is scheduled at "
+ (retryAt - System.currentTimeMillis()) + "ms from now");
values.put(PendingMessages.DUE_TIME, retryAt);
@@ -231,7 +224,7 @@ public class RetryScheduler implements Observer {
PendingMessages.CONTENT_URI,
values, PendingMessages._ID + "=" + id, null);
} else if (LOCAL_LOGV) {
Log.v(TAG, "Cannot found correct pending status for: " + msgId);
Timber.v("Cannot found correct pending status for: " + msgId);
}
} finally {
cursor.close();
@@ -279,7 +272,7 @@ public class RetryScheduler implements Observer {
cursor.close();
}
if (respStatus != 0) {
Log.e(TAG, "Response status is: " + respStatus);
Timber.e("Response status is: " + respStatus);
}
return respStatus;
}
@@ -298,9 +291,7 @@ public class RetryScheduler implements Observer {
cursor.close();
}
if (retrieveStatus != 0) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Retrieve status is: " + retrieveStatus);
}
Timber.v("Retrieve status is: " + retrieveStatus);
}
return retrieveStatus;
}
@@ -323,10 +314,7 @@ public class RetryScheduler implements Observer {
Context.ALARM_SERVICE);
am.set(AlarmManager.RTC, retryAt, operation);
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Next retry is scheduled at"
+ (retryAt - System.currentTimeMillis()) + "ms from now");
}
Timber.v("Next retry is scheduled at" + (retryAt - System.currentTimeMillis()) + "ms from now");
}
} finally {
cursor.close();
@@ -25,7 +25,6 @@ import android.net.Uri;
import android.provider.Telephony.Mms;
import android.provider.Telephony.Mms.Sent;
import android.text.TextUtils;
import com.android.mms.logs.LogTag;
import com.android.mms.util.RateController;
import com.android.mms.util.SendingProgressTokenManager;
import com.google.android.mms.pdu_alt.EncodedStringValue;
@@ -35,9 +34,9 @@ import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.SendConf;
import com.google.android.mms.pdu_alt.SendReq;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.BroadcastUtils;
import com.klinker.android.send_message.Utils;
import timber.log.Timber;
import java.util.Arrays;
@@ -55,8 +54,6 @@ import java.util.Arrays;
* </ul>
*/
public class SendTransaction extends Transaction implements Runnable {
private static final String TAG = LogTag.TAG;
private Thread mThread;
public final Uri mSendReqURI;
@@ -86,7 +83,7 @@ public class SendTransaction extends Transaction implements Runnable {
RateController.init(mContext);
RateController rateCtlr = RateController.getInstance();
if (rateCtlr.isLimitSurpassed() && !rateCtlr.isAllowedByUser()) {
Log.e(TAG, "Sending rate limit surpassed.");
Timber.e("Sending rate limit surpassed.");
return;
}
@@ -116,15 +113,13 @@ public class SendTransaction extends Transaction implements Runnable {
new PduComposer(mContext, sendReq).make());
SendingProgressTokenManager.remove(tokenKey);
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
String respStr = new String(response);
builder.append("[SendTransaction] run: send mms msg (" + mId + "), resp=" + respStr);
Log.d(TAG, "[SendTransaction] run: send mms msg (" + mId + "), resp=" + respStr);
}
String respStr = new String(response);
builder.append("[SendTransaction] run: send mms msg (" + mId + "), resp=" + respStr);
Timber.d("[SendTransaction] run: send mms msg (" + mId + "), resp=" + respStr);
SendConf conf = (SendConf) new PduParser(response).parse();
if (conf == null) {
Log.e(TAG, "No M-Send.conf received.");
Timber.e("No M-Send.conf received.");
builder.append("No M-Send.conf received.\n");
}
@@ -133,7 +128,7 @@ public class SendTransaction extends Transaction implements Runnable {
byte[] reqId = sendReq.getTransactionId();
byte[] confId = conf.getTransactionId();
if (!Arrays.equals(reqId, confId)) {
Log.e(TAG, "Inconsistent Transaction-ID: req="
Timber.e("Inconsistent Transaction-ID: req="
+ new String(reqId) + ", conf=" + new String(confId));
builder.append("Inconsistent Transaction-ID: req="
+ new String(reqId) + ", conf=" + new String(confId) + "\n");
@@ -150,7 +145,7 @@ public class SendTransaction extends Transaction implements Runnable {
if (respStatus != PduHeaders.RESPONSE_STATUS_OK) {
SqliteWrapper.update(mContext, mContext.getContentResolver(),
mSendReqURI, values, null, null);
Log.e(TAG, "Server returned an error code: " + respStatus);
Timber.e("Server returned an error code: " + respStatus);
builder.append("Server returned an error code: " + respStatus + "\n");
return;
}
@@ -166,12 +161,12 @@ public class SendTransaction extends Transaction implements Runnable {
mTransactionState.setState(TransactionState.SUCCESS);
mTransactionState.setContentUri(uri);
} catch (Throwable t) {
Log.e(TAG, "error", t);
Timber.e(t, "error");
} finally {
if (mTransactionState.getState() != TransactionState.SUCCESS) {
mTransactionState.setState(TransactionState.FAILED);
mTransactionState.setContentUri(mSendReqURI);
Log.e(TAG, "Delivery failed.");
Timber.e("Delivery failed.");
builder.append("Delivery failed\n");
Intent intent = new Intent(com.klinker.android.send_message.Transaction.MMS_ERROR);
@@ -40,7 +40,6 @@ import android.provider.Telephony.MmsSms;
import android.provider.Telephony.MmsSms.PendingMessages;
import android.text.TextUtils;
import android.widget.Toast;
import com.android.mms.logs.LogTag;
import com.android.mms.util.RateController;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu_alt.GenericPdu;
@@ -48,10 +47,10 @@ import com.google.android.mms.pdu_alt.NotificationInd;
import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.BroadcastUtils;
import com.klinker.android.send_message.R;
import com.klinker.android.send_message.Utils;
import timber.log.Timber;
import java.io.IOException;
import java.util.ArrayList;
@@ -84,7 +83,6 @@ import java.util.ArrayList;
* </ul>
*/
public class TransactionService extends Service implements Observer {
private static final String TAG = LogTag.TAG;
/**
* Used to identify notification intents broadcasted by the
@@ -169,12 +167,10 @@ public class TransactionService extends Service implements Observer {
@Override
public void onCreate() {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Creating TransactionService");
}
Timber.v("Creating TransactionService");
if (!Utils.isDefaultSmsApp(this)) {
Log.v(TAG, "not default app, so exiting");
Timber.v("not default app, so exiting");
stopSelf();
return;
}
@@ -206,19 +202,19 @@ public class TransactionService extends Service implements Observer {
// new Thread(new Runnable() {
// @Override
// public void run() {
// Log.v(TAG, "starting receiving with new lollipop method");
// Timber.v("starting receiving with new lollipop method");
// try { Thread.sleep(60000); } catch (Exception e) { }
// Log.v(TAG, "done sleeping, lets try and grab the message");
// Timber.v("done sleeping, lets try and grab the message");
// Uri contentUri = Uri.parse(intent.getStringExtra(TransactionBundle.URI));
// String downloadLocation = null;
// Cursor locationQuery = getContentResolver().query(contentUri, new String[]{Telephony.Mms.CONTENT_LOCATION, Telephony.Mms._ID}, null, null, "date desc");
//
// if (locationQuery != null && locationQuery.moveToFirst()) {
// Log.v(TAG, "grabbing content location url");
// Timber.v("grabbing content location url");
// downloadLocation = locationQuery.getString(locationQuery.getColumnIndex(Telephony.Mms.CONTENT_LOCATION));
// }
//
// Log.v(TAG, "creating request with url: " + downloadLocation);
// Timber.v("creating request with url: " + downloadLocation);
// DownloadRequest request = new DownloadRequest(downloadLocation, contentUri, null, null, null);
// MmsNetworkManager manager = new MmsNetworkManager(TransactionService.this);
// request.execute(TransactionService.this, manager);
@@ -270,11 +266,8 @@ public class TransactionService extends Service implements Observer {
boolean noNetwork = !isNetworkAvailable();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "onNewIntent: serviceId: " + serviceId + ": " + intent.getExtras() +
" intent=" + intent);
Log.v(TAG, " networkAvailable=" + !noNetwork);
}
Timber.v("onNewIntent: serviceId: " + serviceId + ": " + intent.getExtras() + " intent=" + intent);
Timber.v(" networkAvailable=" + !noNetwork);
String action = intent.getAction();
if (ACTION_ONALARM.equals(action) || ACTION_ENABLE_AUTO_RETRIEVE.equals(action) ||
@@ -286,14 +279,10 @@ public class TransactionService extends Service implements Observer {
try {
int count = cursor.getCount();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "onNewIntent: cursor.count=" + count + " action=" + action);
}
Timber.v("onNewIntent: cursor.count=" + count + " action=" + action);
if (count == 0) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "onNewIntent: no pending messages. Stopping service.");
}
Timber.v("onNewIntent: no pending messages. Stopping service.");
RetryScheduler.setRetryAlarm(this);
stopSelfIfIdle(serviceId);
return;
@@ -323,16 +312,12 @@ public class TransactionService extends Service implements Observer {
cursor.close();
}
} else {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "onNewIntent: no pending messages. Stopping service.");
}
Timber.v("onNewIntent: no pending messages. Stopping service.");
RetryScheduler.setRetryAlarm(this);
stopSelfIfIdle(serviceId);
}
} else {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "onNewIntent: launch transaction...");
}
Timber.v("onNewIntent: launch transaction...");
// For launching NotificationTransaction and test purpose.
TransactionBundle args = new TransactionBundle(intent.getExtras());
launchTransaction(serviceId, args, noNetwork);
@@ -342,9 +327,7 @@ public class TransactionService extends Service implements Observer {
private void stopSelfIfIdle(int startId) {
synchronized (mProcessing) {
if (mProcessing.isEmpty() && mPending.isEmpty()) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "stopSelfIfIdle: STOP!");
}
Timber.v("stopSelfIfIdle: STOP!");
stopSelf(startId);
}
@@ -364,14 +347,14 @@ public class TransactionService extends Service implements Observer {
case PduHeaders.MESSAGE_TYPE_SEND_REQ:
return Transaction.SEND_TRANSACTION;
default:
Log.w(TAG, "Unrecognized MESSAGE_TYPE: " + msgType);
Timber.w("Unrecognized MESSAGE_TYPE: " + msgType);
return -1;
}
}
private void launchTransaction(int serviceId, TransactionBundle txnBundle, boolean noNetwork) {
if (noNetwork) {
Log.w(TAG, "launchTransaction: no network error!");
Timber.w("launchTransaction: no network error!");
onNetworkUnavailable(serviceId, txnBundle.getTransactionType());
return;
}
@@ -379,16 +362,12 @@ public class TransactionService extends Service implements Observer {
msg.arg1 = serviceId;
msg.obj = txnBundle;
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "launchTransaction: sending message " + msg);
}
Timber.v("launchTransaction: sending message " + msg);
mServiceHandler.sendMessage(msg);
}
private void onNetworkUnavailable(int serviceId, int transactionType) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "onNetworkUnavailable: sid=" + serviceId + ", type=" + transactionType);
}
Timber.v("onNetworkUnavailable: sid=" + serviceId + ", type=" + transactionType);
int toastType = TOAST_NONE;
if (transactionType == Transaction.RETRIEVE_TRANSACTION) {
@@ -404,11 +383,9 @@ public class TransactionService extends Service implements Observer {
@Override
public void onDestroy() {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Destroying TransactionService");
}
Timber.v("Destroying TransactionService");
if (!mPending.isEmpty()) {
Log.w(TAG, "TransactionService exiting with transaction still pending");
Timber.w("TransactionService exiting with transaction still pending");
}
releaseWakeLock();
@@ -421,7 +398,7 @@ public class TransactionService extends Service implements Observer {
mServiceHandler.sendEmptyMessage(EVENT_QUIT);
if (!mobileDataEnabled && !lollipopReceiving) {
Log.v(TAG, "disabling mobile data");
Timber.v("disabling mobile data");
Utils.setMobileDataEnabled(TransactionService.this, false);
}
}
@@ -438,31 +415,23 @@ public class TransactionService extends Service implements Observer {
Transaction transaction = (Transaction) observable;
int serviceId = transaction.getServiceId();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "update transaction " + serviceId);
}
Timber.v("update transaction " + serviceId);
try {
synchronized (mProcessing) {
mProcessing.remove(transaction);
if (mPending.size() > 0) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "update: handle next pending transaction...");
}
Timber.v("update: handle next pending transaction...");
Message msg = mServiceHandler.obtainMessage(
EVENT_HANDLE_NEXT_PENDING_TRANSACTION,
transaction.getConnectionSettings());
mServiceHandler.sendMessage(msg);
}
else if (mProcessing.isEmpty()) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "update: endMmsConnectivity");
}
Timber.v("update: endMmsConnectivity");
endMmsConnectivity();
} else {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "update: mProcessing is not empty");
}
Timber.v("update: mProcessing is not empty");
}
}
@@ -473,9 +442,7 @@ public class TransactionService extends Service implements Observer {
switch (result) {
case TransactionState.SUCCESS:
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Transaction complete: " + serviceId);
}
Timber.v("Transaction complete: " + serviceId);
intent.putExtra(STATE_URI, state.getContentUri());
@@ -499,21 +466,14 @@ public class TransactionService extends Service implements Observer {
}
break;
case TransactionState.FAILED:
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Transaction failed: " + serviceId);
}
Timber.v("Transaction failed: " + serviceId);
break;
default:
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Transaction state unknown: " +
serviceId + " " + result);
}
Timber.v("Transaction state unknown: " + serviceId + " " + result);
break;
}
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "update: broadcast transaction result " + result);
}
Timber.v("update: broadcast transaction result " + result);
// Broadcast the result of the transaction.
BroadcastUtils.sendExplicitBroadcast(this, intent, TRANSACTION_COMPLETED_ACTION);
} finally {
@@ -534,39 +494,34 @@ public class TransactionService extends Service implements Observer {
private void acquireWakeLock() {
// It's okay to double-acquire this because we are not using it
// in reference-counted mode.
Log.v(TAG, "mms acquireWakeLock");
Timber.v("mms acquireWakeLock");
mWakeLock.acquire();
}
private void releaseWakeLock() {
// Don't release the wake lock if it hasn't been created and acquired.
if (mWakeLock != null && mWakeLock.isHeld()) {
Log.v(TAG, "mms releaseWakeLock");
Timber.v("mms releaseWakeLock");
mWakeLock.release();
}
}
protected int beginMmsConnectivity() throws IOException {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "beginMmsConnectivity");
}
Timber.v("beginMmsConnectivity");
// Take a wake lock so we don't fall asleep before the message is downloaded.
createWakeLock();
if (Utils.isMmsOverWifiEnabled(this)) {
NetworkInfo niWF = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if ((niWF != null) && (niWF.isConnected())) {
Log.v(TAG, "beginMmsConnectivity: Wifi active");
Timber.v("beginMmsConnectivity: Wifi active");
return 0;
}
}
int result = mConnMgr.startUsingNetworkFeature(
ConnectivityManager.TYPE_MOBILE, "enableMMS");
int result = mConnMgr.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "enableMMS");
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "beginMmsConnectivity: result=" + result);
}
Timber.v("beginMmsConnectivity: result=" + result);
switch (result) {
case 0:
@@ -580,9 +535,7 @@ public class TransactionService extends Service implements Observer {
protected void endMmsConnectivity() {
try {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "endMmsConnectivity");
}
Timber.v("endMmsConnectivity");
// cancel timer for renewal of lease
mServiceHandler.removeMessages(EVENT_CONTINUE_MMS_CONNECTIVITY);
@@ -636,9 +589,7 @@ public class TransactionService extends Service implements Observer {
*/
@Override
public void handleMessage(Message msg) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Handling incoming message: " + msg + " = " + decodeMessage(msg));
}
Timber.v("Handling incoming message: " + msg + " = " + decodeMessage(msg));
Transaction transaction = null;
@@ -658,21 +609,19 @@ public class TransactionService extends Service implements Observer {
}
}
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "handle EVENT_CONTINUE_MMS_CONNECTIVITY event...");
}
Timber.v("handle EVENT_CONTINUE_MMS_CONNECTIVITY event...");
try {
int result = beginMmsConnectivity();
if (result != 0) {
Log.v(TAG, "Extending MMS connectivity returned " + result +
Timber.v("Extending MMS connectivity returned " + result +
" instead of APN_ALREADY_ACTIVE");
// Just wait for connectivity startup without
// any new request of APN switch.
return;
}
} catch (IOException e) {
Log.w(TAG, "Attempt to extend use of MMS connectivity failed");
Timber.w("Attempt to extend use of MMS connectivity failed");
return;
}
@@ -686,10 +635,8 @@ public class TransactionService extends Service implements Observer {
TransactionBundle args = (TransactionBundle) msg.obj;
TransactionSettings transactionSettings;
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "EVENT_TRANSACTION_REQUEST MmscUrl=" +
args.getMmscUrl() + " proxy port: " + args.getProxyAddress());
}
Timber.v("EVENT_TRANSACTION_REQUEST MmscUrl=" +
args.getMmscUrl() + " proxy port: " + args.getProxyAddress());
// Set the connection settings for this transaction.
// If these have not been set in args, load the default settings.
@@ -704,10 +651,8 @@ public class TransactionService extends Service implements Observer {
int transactionType = args.getTransactionType();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "handle EVENT_TRANSACTION_REQUEST: transactionType=" +
transactionType + " " + decodeTransactionType(transactionType));
}
Timber.v("handle EVENT_TRANSACTION_REQUEST: transactionType=" +
transactionType + " " + decodeTransactionType(transactionType));
// Create appropriate transaction
switch (transactionType) {
@@ -729,7 +674,7 @@ public class TransactionService extends Service implements Observer {
TransactionService.this, serviceId,
transactionSettings, (NotificationInd) ind);
} else {
Log.e(TAG, "Invalid PUSH data.");
Timber.e("Invalid PUSH data.");
transaction = null;
return;
}
@@ -754,11 +699,9 @@ public class TransactionService extends Service implements Observer {
return;
}
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Started processing of incoming message: " + msg);
}
Timber.v("Started processing of incoming message: " + msg);
} catch (Exception ex) {
Log.w(TAG, "Exception occurred while handling message: " + msg, ex);
Timber.w(ex, "Exception occurred while handling message: " + msg);
if (transaction != null) {
try {
@@ -769,7 +712,7 @@ public class TransactionService extends Service implements Observer {
}
}
} catch (Throwable t) {
Log.e(TAG, "Unexpected Throwable.", t);
Timber.e(t, "Unexpected Throwable.");
} finally {
// Set transaction to null to allow stopping the
// transaction service.
@@ -778,9 +721,7 @@ public class TransactionService extends Service implements Observer {
}
} finally {
if (transaction == null) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Transaction was null. Stopping self: " + serviceId);
}
Timber.v("Transaction was null. Stopping self: " + serviceId);
endMmsConnectivity();
stopSelf(serviceId);
}
@@ -790,7 +731,7 @@ public class TransactionService extends Service implements Observer {
processPendingTransaction(transaction, (TransactionSettings) msg.obj);
return;
default:
Log.w(TAG, "what=" + msg.what);
Timber.w("what=" + msg.what);
return;
}
}
@@ -819,9 +760,7 @@ public class TransactionService extends Service implements Observer {
public void processPendingTransaction(Transaction transaction,
TransactionSettings settings) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "processPendingTxn: transaction=" + transaction);
}
Timber.v("processPendingTxn: transaction=" + transaction);
int numProcessTransaction = 0;
synchronized (mProcessing) {
@@ -842,27 +781,20 @@ public class TransactionService extends Service implements Observer {
try {
int serviceId = transaction.getServiceId();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "processPendingTxn: process " + serviceId);
}
Timber.v("processPendingTxn: process " + serviceId);
if (processTransaction(transaction)) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Started deferred processing of transaction "
+ transaction);
}
Timber.v("Started deferred processing of transaction " + transaction);
} else {
transaction = null;
stopSelf(serviceId);
}
} catch (IOException e) {
Log.w(TAG, e.getMessage(), e);
Timber.w(e, e.getMessage());
}
} else {
if (numProcessTransaction == 0) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "processPendingTxn: no more transaction, endMmsConnectivity");
}
Timber.v("processPendingTxn: no more transaction, endMmsConnectivity");
endMmsConnectivity();
}
}
@@ -881,18 +813,13 @@ public class TransactionService extends Service implements Observer {
synchronized (mProcessing) {
for (Transaction t : mPending) {
if (t.isEquivalent(transaction)) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Transaction already pending: " +
transaction.getServiceId());
}
Timber.v("Transaction already pending: " + transaction.getServiceId());
return true;
}
}
for (Transaction t : mProcessing) {
if (t.isEquivalent(transaction)) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Duplicated transaction: " + transaction.getServiceId());
}
Timber.v("Duplicated transaction: " + transaction.getServiceId());
return true;
}
}
@@ -903,16 +830,12 @@ public class TransactionService extends Service implements Observer {
* to defer processing the transaction until
* connectivity is established.
*/
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "processTransaction: call beginMmsConnectivity...");
}
Timber.v("processTransaction: call beginMmsConnectivity...");
int connectivityResult = beginMmsConnectivity();
if (connectivityResult == 1) {
mPending.add(transaction);
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "processTransaction: connResult=APN_REQUEST_STARTED, " +
"defer transaction pending MMS connectivity");
}
Timber.v("processTransaction: connResult=APN_REQUEST_STARTED, " +
"defer transaction pending MMS connectivity");
return true;
}
// If there is already a transaction in processing list, because of the previous
@@ -921,26 +844,19 @@ public class TransactionService extends Service implements Observer {
// to the Processing list. But Processing list is never traversed to
// resend, resulting in transaction not completed/sent.
if (mProcessing.size() > 0) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Adding transaction to 'mPending' list: " + transaction);
}
Timber.v("Adding transaction to 'mPending' list: " + transaction);
mPending.add(transaction);
return true;
} else {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Adding transaction to 'mProcessing' list: " + transaction);
}
Timber.v("Adding transaction to 'mProcessing' list: " + transaction);
mProcessing.add(transaction);
}
}
// Set a timer to keep renewing our "lease" on the MMS connection
sendMessageDelayed(obtainMessage(EVENT_CONTINUE_MMS_CONNECTIVITY),
APN_EXTENSION_WAIT);
sendMessageDelayed(obtainMessage(EVENT_CONTINUE_MMS_CONNECTIVITY), APN_EXTENSION_WAIT);
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "processTransaction: starting transaction " + transaction);
}
Timber.v("processTransaction: starting transaction " + transaction);
// Attach to transaction and process it
transaction.attach(TransactionService.this);
@@ -960,9 +876,7 @@ public class TransactionService extends Service implements Observer {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.w(TAG, "ConnectivityBroadcastReceiver.onReceive() action: " + action);
}
Timber.w("ConnectivityBroadcastReceiver.onReceive() action: " + action);
if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
return;
@@ -973,9 +887,7 @@ public class TransactionService extends Service implements Observer {
if (mConnMgr != null && Utils.isMobileDataEnabled(context)) {
mmsNetworkInfo = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS);
} else {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "mConnMgr is null, bail");
}
Timber.v("mConnMgr is null, bail");
}
/*
@@ -984,24 +896,17 @@ public class TransactionService extends Service implements Observer {
* transaction, if any.
*/
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "Handle ConnectivityBroadcastReceiver.onReceive(): " + mmsNetworkInfo);
}
Timber.v("Handle ConnectivityBroadcastReceiver.onReceive(): " + mmsNetworkInfo);
// Check availability of the mobile network.
if (mmsNetworkInfo == null) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "mms type is null or mobile data is turned off, bail");
}
Timber.v("mms type is null or mobile data is turned off, bail");
} else {
// This is a very specific fix to handle the case where the phone receives an
// incoming call during the time we're trying to setup the mms connection.
// When the call ends, restart the process of mms connectivity.
if ("2GVoiceCallEnded".equals(mmsNetworkInfo.getReason())) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, " reason is " + "2GVoiceCallEnded" +
", retrying mms connectivity");
}
Timber.v(" reason is " + "2GVoiceCallEnded" + ", retrying mms connectivity");
renewMmsConnectivity();
return;
}
@@ -1011,7 +916,7 @@ public class TransactionService extends Service implements Observer {
TransactionService.this, mmsNetworkInfo.getExtraInfo());
// If this APN doesn't have an MMSC, mark everything as failed and bail.
if (TextUtils.isEmpty(settings.getMmscUrl())) {
Log.v(TAG, " empty MMSC url, bail");
Timber.v(" empty MMSC url, bail");
BroadcastUtils.sendExplicitBroadcast(
TransactionService.this,
new Intent(),
@@ -1023,15 +928,11 @@ public class TransactionService extends Service implements Observer {
}
mServiceHandler.processPendingTransaction(null, settings);
} else {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, " TYPE_MOBILE_MMS not connected, bail");
}
Timber.v(" TYPE_MOBILE_MMS not connected, bail");
// Retry mms connectivity once it's possible to connect
if (mmsNetworkInfo.isAvailable()) {
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, " retrying mms connectivity for it's available");
}
Timber.v(" retrying mms connectivity for it's available");
renewMmsConnectivity();
}
}
@@ -21,10 +21,9 @@ import android.net.NetworkUtilsHelper;
import android.provider.Telephony;
import android.text.TextUtils;
import com.android.mms.MmsConfig;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.Transaction;
import com.klinker.android.send_message.Utils;
import timber.log.Timber;
/**
* Container of transaction settings. Instances of this class are contained
@@ -32,10 +31,6 @@ import com.klinker.android.send_message.Utils;
* settings or of the MMS Client.
*/
public class TransactionSettings {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = true;
private static final boolean LOCAL_LOGV = false;
private String mServiceCenter;
private String mProxyAddress;
private int mProxyPort = -1;
@@ -57,7 +52,7 @@ public class TransactionSettings {
* @param context The context of the MMS Client
*/
public TransactionSettings(Context context, String apnName) {
Log.v(TAG, "TransactionSettings: apnName: " + apnName);
Timber.v("TransactionSettings: apnName: " + apnName);
// String selection = "current" + " IS NOT NULL";
// String[] selectionArgs = null;
// if (!TextUtils.isEmpty(apnName)) {
@@ -72,15 +67,15 @@ public class TransactionSettings {
// Telephony.Carriers.CONTENT_URI,
// APN_PROJECTION, selection, selectionArgs, null);
//
// Log.v(TAG, "TransactionSettings looking for apn: " + selection + " returned: " +
// Timber.v("TransactionSettings looking for apn: " + selection + " returned: " +
// (cursor == null ? "null cursor" : (cursor.getCount() + " hits")));
// } catch (SecurityException e) {
// Log.e(TAG, "exception thrown", e);
// Timber.e(e, "exception thrown");
// cursor = null;
// }
//
// if (cursor == null) {
// Log.e(TAG, "Apn is not found in Database!");
// Timber.e("Apn is not found in Database!");
if (Transaction.Companion.getSettings() == null) {
Transaction.Companion.setSettings(Utils.getDefaultSendSettings(context));
}
@@ -92,26 +87,26 @@ public class TransactionSettings {
String agent = Transaction.Companion.getSettings().getAgent();
if (agent != null && !agent.trim().equals("")) {
MmsConfig.setUserAgent(agent);
Log.v(TAG, "set user agent");
Timber.v("set user agent");
}
String uaProfUrl = Transaction.Companion.getSettings().getUserProfileUrl();
if (uaProfUrl != null && !uaProfUrl.trim().equals("")) {
MmsConfig.setUaProfUrl(uaProfUrl);
Log.v(TAG, "set user agent profile url");
Timber.v("set user agent profile url");
}
String uaProfTagName = Transaction.Companion.getSettings().getUaProfTagName();
if (uaProfTagName != null && !uaProfTagName.trim().equals("")) {
MmsConfig.setUaProfTagName(uaProfTagName);
Log.v(TAG, "set user agent profile tag name");
Timber.v("set user agent profile tag name");
}
if (isProxySet()) {
try {
mProxyPort = Integer.parseInt(Transaction.Companion.getSettings().getPort());
} catch (NumberFormatException e) {
Log.e(TAG, "could not get proxy: " + Transaction.Companion.getSettings().getPort(), e);
Timber.e(e, "could not get proxy: " + Transaction.Companion.getSettings().getPort());
}
}
// }
@@ -137,9 +132,9 @@ public class TransactionSettings {
// mProxyPort = Integer.parseInt(portString);
// } catch (NumberFormatException e) {
// if (TextUtils.isEmpty(portString)) {
// Log.w(TAG, "mms port not set!");
// Timber.w("mms port not set!");
// } else {
// Log.e(TAG, "Bad port number format: " + portString, e);
// Timber.e(e, "Bad port number format: " + portString);
// }
// }
// }
@@ -149,10 +144,10 @@ public class TransactionSettings {
// cursor.close();
// }
//
// Log.v(TAG, "APN setting: MMSC: " + mServiceCenter + " looked for: " + selection);
// Timber.v("APN setting: MMSC: " + mServiceCenter + " looked for: " + selection);
//
// if (sawValidApn && TextUtils.isEmpty(mServiceCenter)) {
// Log.e(TAG, "Invalid APN setting: MMSC is empty");
// Timber.e("Invalid APN setting: MMSC is empty");
// }
}
@@ -170,11 +165,9 @@ public class TransactionSettings {
mProxyAddress = proxyAddr;
mProxyPort = proxyPort;
if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
Log.v(TAG, "TransactionSettings: " + mServiceCenter +
" proxyAddress: " + mProxyAddress +
" proxyPort: " + mProxyPort);
}
Timber.v("TransactionSettings: " + mServiceCenter
+ " proxyAddress: " + mProxyAddress
+ " proxyPort: " + mProxyPort);
}
public String getMmscUrl() {
@@ -28,18 +28,15 @@ import android.preference.PreferenceManager;
import android.provider.Telephony.Mms;
import android.widget.Toast;
import com.android.internal.telephony.TelephonyProperties;
import com.android.mms.logs.LogTag;
import com.android.mms.service_alt.SystemPropertiesProxy;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu_alt.EncodedStringValue;
import com.google.android.mms.pdu_alt.NotificationInd;
import com.google.android.mms.pdu_alt.PduPersister;
import com.klinker.android.logger.Log;
import com.klinker.android.send_message.R;
import timber.log.Timber;
public class DownloadManager {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
public static final int DEFERRED_MASK = 0x04;
@@ -67,7 +64,7 @@ public class DownloadManager {
mAutoDownload = getAutoDownloadState(context, mPreferences);
if (LOCAL_LOGV) {
Log.v(TAG, "mAutoDownload ------> " + mAutoDownload);
Timber.v("mAutoDownload ------> " + mAutoDownload);
}
}
@@ -77,11 +74,11 @@ public class DownloadManager {
public static void init(Context context) {
if (LOCAL_LOGV) {
Log.v(TAG, "DownloadManager.init()");
Timber.v("DownloadManager.init()");
}
if (sInstance != null) {
Log.w(TAG, "Already initialized.");
Timber.w("Already initialized.");
}
sInstance = new DownloadManager(context);
}
@@ -101,14 +98,14 @@ public class DownloadManager {
boolean autoDownload = prefs.getBoolean("auto_download_mms", true);
if (LOCAL_LOGV) {
Log.v(TAG, "auto download without roaming -> " + autoDownload);
Timber.v("auto download without roaming -> " + autoDownload);
}
if (autoDownload) {
boolean alwaysAuto = true;
if (LOCAL_LOGV) {
Log.v(TAG, "auto download during roaming -> " + alwaysAuto);
Timber.v("auto download during roaming -> " + alwaysAuto);
}
if (!roaming || alwaysAuto) {
@@ -123,7 +120,7 @@ public class DownloadManager {
String roaming = SystemPropertiesProxy.get(context,
TelephonyProperties.PROPERTY_OPERATOR_ISROAMING, null);
if (LOCAL_LOGV) {
Log.v(TAG, "roaming ------> " + roaming);
Timber.v("roaming ------> " + roaming);
}
return "true".equals(roaming);
}
@@ -145,7 +142,7 @@ public class DownloadManager {
return;
}
} catch(MmsException e) {
Log.e(TAG, e.getMessage(), e);
Timber.e(e, e.getMessage());
return;
}
@@ -157,7 +154,7 @@ public class DownloadManager {
Toast.makeText(mContext, getMessage(uri),
Toast.LENGTH_LONG).show();
} catch (MmsException e) {
Log.e(TAG, e.getMessage(), e);
Timber.e(e, e.getMessage());
}
}
});
@@ -180,7 +177,7 @@ public class DownloadManager {
try {
Toast.makeText(mContext, errStr, Toast.LENGTH_LONG).show();
} catch (Exception e) {
Log.e(TAG,"Caught an exception in showErrorCodeToast");
Timber.e("Caught an exception in showErrorCodeToast");
}
}
});
@@ -1,36 +0,0 @@
package com.android.mms.util;
import java.util.concurrent.CopyOnWriteArrayList;
public class ExternalLogger {
private static final CopyOnWriteArrayList<LoggingListener> sListener = new CopyOnWriteArrayList<LoggingListener>();
public interface LoggingListener {
void onLogException(String tag, Throwable e);
void onLogMessage(String tag, String message);
}
private ExternalLogger(){}
public static void addListener(LoggingListener listener) {
sListener.add(listener);
}
public static void removeListener(LoggingListener listener) {
sListener.remove(listener);
}
public static void logException(String tag, Throwable e) {
for (LoggingListener listener: sListener) {
listener.onLogException(tag, e);
}
}
public static void logMessage(String tag, String message) {
for (LoggingListener listener: sListener) {
listener.onLogMessage(tag, message);
}
}
}
@@ -24,12 +24,9 @@ import android.content.IntentFilter;
import android.database.Cursor;
import android.database.sqlite.SqliteWrapper;
import android.provider.Telephony.Mms.Rate;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import timber.log.Timber;
public class RateController {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private static final int RATE_LIMIT = 100;
@@ -55,7 +52,7 @@ public class RateController {
@Override
public void onReceive(Context context, Intent intent) {
if (LOCAL_LOGV) {
Log.v(TAG, "Intent received: " + intent);
Timber.v("Intent received: " + intent);
}
if (RATE_LIMIT_CONFIRMED_ACTION.equals(intent.getAction())) {
@@ -74,11 +71,11 @@ public class RateController {
public static void init(Context context) {
if (LOCAL_LOGV) {
Log.v(TAG, "RateController.init()");
Timber.v("RateController.init()");
}
if (sInstance != null) {
Log.w(TAG, "Already initialized.");
Timber.w("Already initialized.");
return;
}
sInstance = new RateController(context);
@@ -149,7 +146,7 @@ public class RateController {
for (int t = 0; (mAnswer == NO_ANSWER) && (t < ANSWER_TIMEOUT); t += 1000) {
try {
if (LOCAL_LOGV) {
Log.v(TAG, "Waiting for answer..." + t / 1000);
Timber.v("Waiting for answer..." + t / 1000);
}
wait(1000L);
} catch (InterruptedException e) {
@@ -16,14 +16,11 @@
package com.android.mms.util;
import com.android.mms.logs.LogTag;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.util.HashMap;
public class SendingProgressTokenManager {
private static final String TAG = LogTag.TAG;
private static final boolean DEBUG = false;
private static final boolean LOCAL_LOGV = false;
private static final HashMap<Object, Long> TOKEN_POOL;
@@ -36,21 +33,21 @@ public class SendingProgressTokenManager {
synchronized public static long get(Object key) {
Long token = TOKEN_POOL.get(key);
if (LOCAL_LOGV) {
Log.v(TAG, "TokenManager.get(" + key + ") -> " + token);
Timber.v("TokenManager.get(" + key + ") -> " + token);
}
return token != null ? token : NO_TOKEN;
}
synchronized public static void put(Object key, long token) {
if (LOCAL_LOGV) {
Log.v(TAG, "TokenManager.put(" + key + ", " + token + ")");
Timber.v("TokenManager.put(" + key + ", " + token + ")");
}
TOKEN_POOL.put(key, token);
}
synchronized public static void remove(Object key) {
if (LOCAL_LOGV) {
Log.v(TAG, "TokenManager.remove(" + key + ")");
Timber.v("TokenManager.remove(" + key + ")");
}
TOKEN_POOL.remove(key);
}
@@ -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;
}
@@ -23,7 +23,6 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.provider.Telephony;
import android.telephony.SmsManager;
import android.util.Log;
import com.android.mms.service_alt.DownloadRequest;
import com.android.mms.service_alt.MmsConfig;
import com.android.mms.transaction.DownloadManager;
@@ -41,6 +40,7 @@ import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.RetrieveConf;
import com.google.android.mms.util_alt.SqliteWrapper;
import timber.log.Timber;
import java.io.File;
import java.io.FileInputStream;
@@ -54,8 +54,6 @@ import java.util.concurrent.Executors;
import static com.google.android.mms.pdu_alt.PduHeaders.STATUS_RETRIEVED;
public class MmsReceivedReceiver extends BroadcastReceiver {
private static final String TAG = "MmsReceivedReceiver";
public static final String MMS_RECEIVED = "com.klinker.android.messaging.MMS_RECEIVED";
public static final String EXTRA_FILE_PATH = "file_path";
public static final String EXTRA_LOCATION_URL = "location_url";
@@ -79,10 +77,10 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.v(TAG, "MMS has finished downloading, persisting it to the database");
Timber.v("MMS has finished downloading, persisting it to the database");
String path = intent.getStringExtra(EXTRA_FILE_PATH);
Log.v(TAG, path);
Timber.v(path);
FileInputStream reader = null;
Uri messageUri = null;
@@ -102,28 +100,28 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
intent.getStringExtra(EXTRA_LOCATION_URL),
Utils.getDefaultSubscriptionId(), null);
Log.v(TAG, "response saved successfully");
Log.v(TAG, "response length: " + response.length);
Timber.v("response saved successfully");
Timber.v("response length: " + response.length);
mDownloadFile.delete();
if (tasks != null) {
Log.v(TAG, "running the common async notifier for download");
Timber.v("running the common async notifier for download");
for (CommonAsyncTask task : tasks)
task.executeOnExecutor(RECEIVE_NOTIFICATION_EXECUTOR);
}
} catch (FileNotFoundException e) {
errorMessage = "MMS received, file not found exception";
Log.e(TAG, errorMessage, e);
Timber.e(e, errorMessage);
} catch (IOException e) {
errorMessage = "MMS received, io exception";
Log.e(TAG, errorMessage, e);
Timber.e(e, errorMessage);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
errorMessage = "MMS received, io exception";
Log.e(TAG, "MMS received, io exception", e);
Timber.e(e, "MMS received, io exception");
}
}
}
@@ -275,7 +273,7 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
sendPdu(new PduComposer(mContext, notifyRespInd).make());
}
} catch (MmsException | IOException e) {
Log.e(TAG, "error", e);
Timber.e(e, "error");
}
return null;
}
@@ -296,7 +294,7 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
// the MMS proxy-relay doesn't require an ACK.
byte[] tranId = mRetrieveConf.getTransactionId();
if (tranId != null) {
Log.v(TAG, "sending ACK to MMSC: " + mTransactionSettings.getMmscUrl());
Timber.v("sending ACK to MMSC: " + mTransactionSettings.getMmscUrl());
// Create M-Acknowledge.ind
com.google.android.mms.pdu_alt.AcknowledgeInd acknowledgeInd;
@@ -315,7 +313,7 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
sendPdu(new PduComposer(mContext, acknowledgeInd).make());
}
} catch (IOException | MmsException e) {
Log.e(TAG, "error", e);
Timber.e(e, "error");
}
}
return null;
@@ -324,12 +322,12 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
private List<CommonAsyncTask> getNotificationTask(Context context, Intent intent, byte[] response) {
if (response.length == 0) {
Log.v(TAG, "MmsReceivedReceiver.sendNotification blank response");
Timber.v("MmsReceivedReceiver.sendNotification blank response");
return null;
}
if (getMmscInfoForReceptionAck() == null) {
Log.v(TAG, "No MMSC information set, so no notification tasks will be able to complete");
Timber.v("No MMSC information set, so no notification tasks will be able to complete");
return null;
}
@@ -337,7 +335,7 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
(new PduParser(response, new MmsConfig.Overridden(new MmsConfig(context), null).
getSupportMmsContentDisposition())).parse();
if (pdu == null || !(pdu instanceof RetrieveConf)) {
android.util.Log.e(TAG, "MmsReceivedReceiver.sendNotification failed to parse pdu");
Timber.e("MmsReceivedReceiver.sendNotification failed to parse pdu");
return null;
}
@@ -352,7 +350,7 @@ public class MmsReceivedReceiver extends BroadcastReceiver {
return responseTasks;
} catch (MmsException e) {
Log.e(TAG, "error", e);
Timber.e(e, "error");
return null;
}
}
@@ -25,7 +25,7 @@ import com.google.android.mms.pdu_alt.PduParser;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.RetrieveConf;
import com.google.android.mms.util_alt.SqliteWrapper;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.io.File;
import java.io.FileInputStream;
@@ -33,14 +33,9 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import static com.google.android.mms.pdu_alt.PduHeaders.STATUS_RETRIEVED;
import static com.klinker.android.send_message.MmsReceivedReceiver.EXTRA_FILE_PATH;
import static com.klinker.android.send_message.MmsReceivedReceiver.EXTRA_LOCATION_URL;
import static com.klinker.android.send_message.MmsReceivedReceiver.EXTRA_TRIGGER_PUSH;
import static com.klinker.android.send_message.MmsReceivedReceiver.EXTRA_URI;
import static com.klinker.android.send_message.MmsReceivedReceiver.*;
public class MmsReceivedService extends IntentService {
private static final String TAG = "MmsReceivedService";
private static final String LOCATION_SELECTION =
Telephony.Mms.MESSAGE_TYPE + "=? AND " + Telephony.Mms.CONTENT_LOCATION + " =?";
@@ -54,10 +49,10 @@ public class MmsReceivedService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
Log.v(TAG, "MMS has finished downloading, persisting it to the database");
Timber.v("MMS has finished downloading, persisting it to the database");
String path = intent.getStringExtra(EXTRA_FILE_PATH);
Log.v(TAG, path);
Timber.v(path);
FileInputStream reader = null;
try {
@@ -75,19 +70,19 @@ public class MmsReceivedService extends IntentService {
intent.getStringExtra(EXTRA_LOCATION_URL),
Utils.getDefaultSubscriptionId(), null);
Log.v(TAG, "response saved successfully");
Log.v(TAG, "response length: " + response.length);
Timber.v("response saved successfully");
Timber.v("response length: " + response.length);
mDownloadFile.delete();
} catch (FileNotFoundException e) {
Log.e(TAG, "MMS received, file not found exception", e);
Timber.e(e, "MMS received, file not found exception");
} catch (IOException e) {
Log.e(TAG, "MMS received, io exception", e);
Timber.e(e, "MMS received, io exception");
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
Log.e(TAG, "MMS received, io exception", e);
Timber.e(e, "MMS received, io exception");
}
}
@@ -228,7 +223,7 @@ public class MmsReceivedService extends IntentService {
sendPdu(new PduComposer(mContext, notifyRespInd).make());
}
} catch (MmsException e) {
Log.e(TAG, "error", e);
Timber.e(e, "error");
}
}
}
@@ -265,9 +260,9 @@ public class MmsReceivedService extends IntentService {
sendPdu(new PduComposer(mContext, acknowledgeInd).make());
}
} catch (InvalidHeaderValueException e) {
Log.e(TAG, "error", e);
Timber.e(e, "error");
} catch (MmsException e) {
Log.e(TAG, "error", e);
Timber.e(e, "error");
}
}
}
@@ -278,15 +273,14 @@ public class MmsReceivedService extends IntentService {
return null;
}
final GenericPdu pdu =
(new PduParser(response, new MmsConfig.Overridden(new MmsConfig(context), null).
getSupportMmsContentDisposition())).parse();
if (pdu == null || !(pdu instanceof RetrieveConf)) {
android.util.Log.e(TAG, "MmsReceivedReceiver.sendNotification failed to parse pdu");
final GenericPdu pdu = (new PduParser(response, new MmsConfig.Overridden(new MmsConfig(context), null).
getSupportMmsContentDisposition())).parse();
if (!(pdu instanceof RetrieveConf)) {
Timber.e("MmsReceivedReceiver.sendNotification failed to parse pdu");
return null;
}
try {
try {Ω
NotificationInd ind = getNotificationInd(context, intent);
TransactionSettings transactionSettings = new TransactionSettings(context, null);
if (intent.getBooleanExtra(EXTRA_TRIGGER_PUSH, false)) {
@@ -295,7 +289,7 @@ public class MmsReceivedService extends IntentService {
return new AcknowledgeIndTask(context, ind, transactionSettings, (RetrieveConf) pdu);
}
} catch (MmsException e) {
Log.e(TAG, "error", e);
Timber.e(e, "error");
return null;
}
}
@@ -309,7 +303,7 @@ public class MmsReceivedService extends IntentService {
// need retry ?
task.run();
} catch (IOException e) {
Log.e(TAG, "MMS send received notification, io exception", e);
Timber.e(e, "MMS send received notification, io exception");
throw e;
}
}
@@ -17,7 +17,7 @@ import android.text.TextUtils;
import com.android.mms.service_alt.MmsNetworkManager;
import com.android.mms.service_alt.exception.MmsNetworkException;
import com.google.android.mms.util_alt.SqliteWrapper;
import com.klinker.android.logger.Log;
import timber.log.Timber;
import java.io.IOException;
import java.lang.reflect.Method;
@@ -39,7 +39,6 @@ public class Utils {
* characters to compare against when checking for 160 character sending compatibility
*/
public static final String GSM_CHARACTERS_REGEX = "^[A-Za-z0-9 \\r\\n@Ł$ĽčéůěňÇŘřĹĺ\u0394_\u03A6\u0393\u039B\u03A9\u03A0\u03A8\u03A3\u0398\u039EĆćßÉ!\"#$%&'()*+,\\-./:;<=>?ĄÄÖŃܧżäöńüŕ^{}\\\\\\[~\\]|\u20AC]*$";
private static final String TAG = "Utils";
public static final int DEFAULT_SUBSCRIPTION_ID = 1;
/**
@@ -130,7 +129,7 @@ public class Utils {
throw new IOException("Cannot establish route to proxy " + inetAddr);
}
} catch (Exception e) {
Log.e(TAG, "Cannot establishh route to proxy " + inetAddr, e);
Timber.e(e, "Cannot establishh route to proxy " + inetAddr);
}
} else {
Uri uri = Uri.parse(url);
@@ -145,7 +144,7 @@ public class Utils {
throw new IOException("Cannot establish route to proxy " + inetAddr);
}
} catch (Exception e) {
Log.e(TAG, "Cannot establishh route to proxy " + inetAddr + " for " + url, e);
Timber.e(e, "Cannot establishh route to proxy " + inetAddr + " for " + url);
}
}
}
@@ -165,7 +164,7 @@ public class Utils {
m.setAccessible(true);
return (Boolean) m.invoke(cm);
} catch (Exception e) {
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
return null;
}
}
@@ -181,7 +180,7 @@ public class Utils {
Method m = c.getMethod("getDataEnabled");
return (boolean) m.invoke(telephonyManager);
} catch (Exception e) {
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
return true;
}
}
@@ -198,7 +197,7 @@ public class Utils {
Method m = c.getMethod("getDataEnabled", int.class);
return (boolean) m.invoke(telephonyManager, subId);
} catch (Exception e) {
Log.e(TAG, "exception thrown", e);
Timber.e(e, "exception thrown");
return isDataEnabled(telephonyManager);
}
}
@@ -225,7 +224,7 @@ public class Utils {
m.setAccessible(true);
m.invoke(telephonyService, enabled);
} catch (Exception e) {
Log.e(TAG, "error enabling data on lollipop", e);
Timber.e(e, "error enabling data on lollipop");
}
}