Merge "SIP: turn off verbose logs." into ics-mr1

This commit is contained in:
Chia-chi Yeh
2011-11-21 15:19:35 -08:00
committed by Android (Google) Code Review
4 changed files with 47 additions and 40 deletions

View File

@@ -73,7 +73,7 @@ import javax.sip.message.Response;
*/
class SipHelper {
private static final String TAG = SipHelper.class.getSimpleName();
private static final boolean DEBUG = true;
private static final boolean DEBUG = false;
private static final boolean DEBUG_PING = false;
private SipStack mSipStack;

View File

@@ -68,8 +68,7 @@ import javax.sip.SipException;
*/
public final class SipService extends ISipService.Stub {
static final String TAG = "SipService";
static final boolean DEBUGV = false;
static final boolean DEBUG = true;
static final boolean DEBUG = false;
private static final int EXPIRY_TIME = 3600;
private static final int SHORT_EXPIRY_TIME = 10;
private static final int MIN_EXPIRY_TIME = 60;
@@ -581,7 +580,7 @@ public final class SipService extends ISipService.Stub {
@Override
public void onRinging(ISipSession s, SipProfile caller,
String sessionDescription) {
if (DEBUGV) Log.d(TAG, "<<<<< onRinging()");
if (DEBUG) Log.d(TAG, "<<<<< onRinging()");
SipSessionGroup.SipSessionImpl session =
(SipSessionGroup.SipSessionImpl) s;
synchronized (SipService.this) {
@@ -778,7 +777,6 @@ public final class SipService extends ISipService.Stub {
private void restartLater() {
synchronized (SipService.this) {
int interval = NAT_MEASUREMENT_RETRY_INTERVAL;
Log.d(TAG, "Retry measurement " + interval + "s later.");
mTimer.cancel(this);
mTimer.set(interval * 1000, this);
}
@@ -788,7 +786,7 @@ public final class SipService extends ISipService.Stub {
private class AutoRegistrationProcess extends SipSessionAdapter
implements Runnable, SipSessionGroup.KeepAliveProcessCallback {
private static final int MIN_KEEPALIVE_SUCCESS_COUNT = 10;
private String TAG = "SipAudoReg";
private String TAG = "SipAutoReg";
private SipSessionGroup.SipSessionImpl mSession;
private SipSessionGroup.SipSessionImpl mKeepAliveSession;
@@ -820,13 +818,12 @@ public final class SipService extends ISipService.Stub {
// in registration to avoid adding duplicate entries to server
mMyWakeLock.acquire(mSession);
mSession.unregister();
if (DEBUG) TAG = mSession.getLocalProfile().getUriString();
if (DEBUG) Log.d(TAG, "start AutoRegistrationProcess");
TAG = "SipAutoReg:" + mSession.getLocalProfile().getUriString();
}
}
private void startKeepAliveProcess(int interval) {
Log.d(TAG, "start keepalive w interval=" + interval);
if (DEBUG) Log.d(TAG, "start keepalive w interval=" + interval);
if (mKeepAliveSession == null) {
mKeepAliveSession = mSession.duplicate();
} else {
@@ -864,9 +861,11 @@ public final class SipService extends ISipService.Stub {
mKeepAliveSuccessCount = 0;
}
} else {
Log.i(TAG, "keep keepalive going with interval "
+ interval + ", past success count="
+ mKeepAliveSuccessCount);
if (DEBUG) {
Log.i(TAG, "keep keepalive going with interval "
+ interval + ", past success count="
+ mKeepAliveSuccessCount);
}
mKeepAliveSuccessCount /= 2;
}
} else {
@@ -894,7 +893,9 @@ public final class SipService extends ISipService.Stub {
// SipSessionGroup.KeepAliveProcessCallback
@Override
public void onError(int errorCode, String description) {
Log.e(TAG, "keepalive error: " + description);
if (DEBUG) {
Log.e(TAG, "keepalive error: " + description);
}
onResponse(true); // re-register immediately
}
@@ -917,7 +918,7 @@ public final class SipService extends ISipService.Stub {
public void onKeepAliveIntervalChanged() {
if (mKeepAliveSession != null) {
int newInterval = getKeepAliveInterval();
if (DEBUGV) {
if (DEBUG) {
Log.v(TAG, "restart keepalive w interval=" + newInterval);
}
mKeepAliveSuccessCount = 0;
@@ -987,7 +988,7 @@ public final class SipService extends ISipService.Stub {
}
private void restart(int duration) {
if (DEBUG) Log.d(TAG, "Refresh registration " + duration + "s later.");
Log.d(TAG, "Refresh registration " + duration + "s later.");
mTimer.cancel(this);
mTimer.set(duration * 1000, this);
}

View File

@@ -89,8 +89,8 @@ import javax.sip.message.Response;
*/
class SipSessionGroup implements SipListener {
private static final String TAG = "SipSession";
private static final boolean DEBUG = true;
private static final boolean DEBUG_PING = DEBUG && false;
private static final boolean DEBUG = false;
private static final boolean DEBUG_PING = false;
private static final String ANONYMOUS = "anonymous";
// Limit the size of thread pool to 1 for the order issue when the phone is
// waken up from sleep and there are many packets to be processed in the SIP
@@ -205,7 +205,9 @@ class SipSessionGroup implements SipListener {
}
synchronized void resetExternalAddress() {
Log.d(TAG, " reset external addr on " + mSipStack);
if (DEBUG) {
Log.d(TAG, " reset external addr on " + mSipStack);
}
mExternalIp = null;
mExternalPort = 0;
}
@@ -362,7 +364,7 @@ class SipSessionGroup implements SipListener {
+ SipSession.State.toString(session.mState));
}
} catch (Throwable e) {
Log.w(TAG, "event process error: " + event, e);
Log.w(TAG, "event process error: " + event, getRootCause(e));
session.onError(e);
}
}
@@ -393,11 +395,22 @@ class SipSessionGroup implements SipListener {
if ((rport > 0) && (externalIp != null)) {
mExternalIp = externalIp;
mExternalPort = rport;
Log.d(TAG, " got external addr " + externalIp + ":" + rport
+ " on " + mSipStack);
if (DEBUG) {
Log.d(TAG, " got external addr " + externalIp + ":" + rport
+ " on " + mSipStack);
}
}
}
private Throwable getRootCause(Throwable exception) {
Throwable cause = exception.getCause();
while (cause != null) {
exception = cause;
cause = exception.getCause();
}
return exception;
}
private SipSessionImpl createNewSession(RequestEvent event,
ISipSessionListener listener, ServerTransaction transaction,
int newState) throws SipException {
@@ -890,7 +903,9 @@ class SipSessionGroup implements SipListener {
if (expires != null && time < expires.getExpires()) {
time = expires.getExpires();
}
Log.v(TAG, "Expiry time = " + time);
if (DEBUG) {
Log.v(TAG, "Expiry time = " + time);
}
return time;
}
@@ -1409,15 +1424,6 @@ class SipSessionGroup implements SipListener {
}
}
private Throwable getRootCause(Throwable exception) {
Throwable cause = exception.getCause();
while (cause != null) {
exception = cause;
cause = exception.getCause();
}
return exception;
}
private int getErrorCode(Throwable exception) {
String message = exception.getMessage();
if (exception instanceof UnknownHostException) {
@@ -1555,8 +1561,10 @@ class SipSessionGroup implements SipListener {
try {
sendKeepAlive();
} catch (Throwable t) {
Log.w(TAG, "keepalive error: "
+ mLocalProfile.getUriString(), getRootCause(t));
if (DEBUG) {
Log.w(TAG, "keepalive error: "
+ mLocalProfile.getUriString(), getRootCause(t));
}
// It's possible that the keepalive process is being stopped
// during session.sendKeepAlive() so need to check mRunning
// again here.

View File

@@ -22,8 +22,8 @@ import android.util.Log;
import java.util.HashSet;
class SipWakeLock {
private static final boolean DEBUGV = SipService.DEBUGV;
private static final String TAG = SipService.TAG;
private static final boolean DEBUG = false;
private static final String TAG = "SipWakeLock";
private PowerManager mPowerManager;
private PowerManager.WakeLock mWakeLock;
private PowerManager.WakeLock mTimerWakeLock;
@@ -34,9 +34,9 @@ class SipWakeLock {
}
synchronized void reset() {
if (DEBUG) Log.v(TAG, "reset count=" + mHolders.size());
mHolders.clear();
release(null);
if (DEBUGV) Log.v(TAG, "~~~ hard reset wakelock");
}
synchronized void acquire(long timeout) {
@@ -55,8 +55,7 @@ class SipWakeLock {
PowerManager.PARTIAL_WAKE_LOCK, "SipWakeLock");
}
if (!mWakeLock.isHeld()) mWakeLock.acquire();
if (DEBUGV) Log.v(TAG, "acquire wakelock: holder count="
+ mHolders.size());
if (DEBUG) Log.v(TAG, "acquire count=" + mHolders.size());
}
synchronized void release(Object holder) {
@@ -65,7 +64,6 @@ class SipWakeLock {
&& mWakeLock.isHeld()) {
mWakeLock.release();
}
if (DEBUGV) Log.v(TAG, "release wakelock: holder count="
+ mHolders.size());
if (DEBUG) Log.v(TAG, "release count=" + mHolders.size());
}
}