forked from upstream-mirrors/quik
Use Timber for all logs
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
+7
-15
@@ -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) {
|
||||
|
||||
+12
-20
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user