Skip to content

Commit bfd85f9

Browse files
Chia-chi YehAndroid (Google) Code Review
authored andcommitted
Merge "SIP: turn off verbose logs." into ics-mr1
2 parents 0507ac4 + cb6ee06 commit bfd85f9

File tree

4 files changed

+47
-40
lines changed

4 files changed

+47
-40
lines changed

voip/java/com/android/server/sip/SipHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
*/
7474
class SipHelper {
7575
private static final String TAG = SipHelper.class.getSimpleName();
76-
private static final boolean DEBUG = true;
76+
private static final boolean DEBUG = false;
7777
private static final boolean DEBUG_PING = false;
7878

7979
private SipStack mSipStack;

voip/java/com/android/server/sip/SipService.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@
6868
*/
6969
public final class SipService extends ISipService.Stub {
7070
static final String TAG = "SipService";
71-
static final boolean DEBUGV = false;
72-
static final boolean DEBUG = true;
71+
static final boolean DEBUG = false;
7372
private static final int EXPIRY_TIME = 3600;
7473
private static final int SHORT_EXPIRY_TIME = 10;
7574
private static final int MIN_EXPIRY_TIME = 60;
@@ -581,7 +580,7 @@ public ISipSession createSession(ISipSessionListener listener) {
581580
@Override
582581
public void onRinging(ISipSession s, SipProfile caller,
583582
String sessionDescription) {
584-
if (DEBUGV) Log.d(TAG, "<<<<< onRinging()");
583+
if (DEBUG) Log.d(TAG, "<<<<< onRinging()");
585584
SipSessionGroup.SipSessionImpl session =
586585
(SipSessionGroup.SipSessionImpl) s;
587586
synchronized (SipService.this) {
@@ -778,7 +777,6 @@ public void run() {
778777
private void restartLater() {
779778
synchronized (SipService.this) {
780779
int interval = NAT_MEASUREMENT_RETRY_INTERVAL;
781-
Log.d(TAG, "Retry measurement " + interval + "s later.");
782780
mTimer.cancel(this);
783781
mTimer.set(interval * 1000, this);
784782
}
@@ -788,7 +786,7 @@ private void restartLater() {
788786
private class AutoRegistrationProcess extends SipSessionAdapter
789787
implements Runnable, SipSessionGroup.KeepAliveProcessCallback {
790788
private static final int MIN_KEEPALIVE_SUCCESS_COUNT = 10;
791-
private String TAG = "SipAudoReg";
789+
private String TAG = "SipAutoReg";
792790

793791
private SipSessionGroup.SipSessionImpl mSession;
794792
private SipSessionGroup.SipSessionImpl mKeepAliveSession;
@@ -820,13 +818,12 @@ public void start(SipSessionGroup group) {
820818
// in registration to avoid adding duplicate entries to server
821819
mMyWakeLock.acquire(mSession);
822820
mSession.unregister();
823-
if (DEBUG) TAG = mSession.getLocalProfile().getUriString();
824-
if (DEBUG) Log.d(TAG, "start AutoRegistrationProcess");
821+
TAG = "SipAutoReg:" + mSession.getLocalProfile().getUriString();
825822
}
826823
}
827824

828825
private void startKeepAliveProcess(int interval) {
829-
Log.d(TAG, "start keepalive w interval=" + interval);
826+
if (DEBUG) Log.d(TAG, "start keepalive w interval=" + interval);
830827
if (mKeepAliveSession == null) {
831828
mKeepAliveSession = mSession.duplicate();
832829
} else {
@@ -864,9 +861,11 @@ public void onResponse(boolean portChanged) {
864861
mKeepAliveSuccessCount = 0;
865862
}
866863
} else {
867-
Log.i(TAG, "keep keepalive going with interval "
868-
+ interval + ", past success count="
869-
+ mKeepAliveSuccessCount);
864+
if (DEBUG) {
865+
Log.i(TAG, "keep keepalive going with interval "
866+
+ interval + ", past success count="
867+
+ mKeepAliveSuccessCount);
868+
}
870869
mKeepAliveSuccessCount /= 2;
871870
}
872871
} else {
@@ -894,7 +893,9 @@ public void onResponse(boolean portChanged) {
894893
// SipSessionGroup.KeepAliveProcessCallback
895894
@Override
896895
public void onError(int errorCode, String description) {
897-
Log.e(TAG, "keepalive error: " + description);
896+
if (DEBUG) {
897+
Log.e(TAG, "keepalive error: " + description);
898+
}
898899
onResponse(true); // re-register immediately
899900
}
900901

@@ -917,7 +918,7 @@ public void stop() {
917918
public void onKeepAliveIntervalChanged() {
918919
if (mKeepAliveSession != null) {
919920
int newInterval = getKeepAliveInterval();
920-
if (DEBUGV) {
921+
if (DEBUG) {
921922
Log.v(TAG, "restart keepalive w interval=" + newInterval);
922923
}
923924
mKeepAliveSuccessCount = 0;
@@ -987,7 +988,7 @@ public void run() {
987988
}
988989

989990
private void restart(int duration) {
990-
if (DEBUG) Log.d(TAG, "Refresh registration " + duration + "s later.");
991+
Log.d(TAG, "Refresh registration " + duration + "s later.");
991992
mTimer.cancel(this);
992993
mTimer.set(duration * 1000, this);
993994
}

voip/java/com/android/server/sip/SipSessionGroup.java

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
*/
9090
class SipSessionGroup implements SipListener {
9191
private static final String TAG = "SipSession";
92-
private static final boolean DEBUG = true;
93-
private static final boolean DEBUG_PING = DEBUG && false;
92+
private static final boolean DEBUG = false;
93+
private static final boolean DEBUG_PING = false;
9494
private static final String ANONYMOUS = "anonymous";
9595
// Limit the size of thread pool to 1 for the order issue when the phone is
9696
// waken up from sleep and there are many packets to be processed in the SIP
@@ -205,7 +205,9 @@ synchronized void onConnectivityChanged() {
205205
}
206206

207207
synchronized void resetExternalAddress() {
208-
Log.d(TAG, " reset external addr on " + mSipStack);
208+
if (DEBUG) {
209+
Log.d(TAG, " reset external addr on " + mSipStack);
210+
}
209211
mExternalIp = null;
210212
mExternalPort = 0;
211213
}
@@ -362,7 +364,7 @@ private synchronized void process(EventObject event) {
362364
+ SipSession.State.toString(session.mState));
363365
}
364366
} catch (Throwable e) {
365-
Log.w(TAG, "event process error: " + event, e);
367+
Log.w(TAG, "event process error: " + event, getRootCause(e));
366368
session.onError(e);
367369
}
368370
}
@@ -393,9 +395,20 @@ private void extractExternalAddress(ResponseEvent evt) {
393395
if ((rport > 0) && (externalIp != null)) {
394396
mExternalIp = externalIp;
395397
mExternalPort = rport;
396-
Log.d(TAG, " got external addr " + externalIp + ":" + rport
397-
+ " on " + mSipStack);
398+
if (DEBUG) {
399+
Log.d(TAG, " got external addr " + externalIp + ":" + rport
400+
+ " on " + mSipStack);
401+
}
402+
}
403+
}
404+
405+
private Throwable getRootCause(Throwable exception) {
406+
Throwable cause = exception.getCause();
407+
while (cause != null) {
408+
exception = cause;
409+
cause = exception.getCause();
398410
}
411+
return exception;
399412
}
400413

401414
private SipSessionImpl createNewSession(RequestEvent event,
@@ -890,7 +903,9 @@ private int getExpiryTime(Response response) {
890903
if (expires != null && time < expires.getExpires()) {
891904
time = expires.getExpires();
892905
}
893-
Log.v(TAG, "Expiry time = " + time);
906+
if (DEBUG) {
907+
Log.v(TAG, "Expiry time = " + time);
908+
}
894909
return time;
895910
}
896911

@@ -1409,15 +1424,6 @@ private int getErrorCode(int responseStatusCode) {
14091424
}
14101425
}
14111426

1412-
private Throwable getRootCause(Throwable exception) {
1413-
Throwable cause = exception.getCause();
1414-
while (cause != null) {
1415-
exception = cause;
1416-
cause = exception.getCause();
1417-
}
1418-
return exception;
1419-
}
1420-
14211427
private int getErrorCode(Throwable exception) {
14221428
String message = exception.getMessage();
14231429
if (exception instanceof UnknownHostException) {
@@ -1555,8 +1561,10 @@ public void run() {
15551561
try {
15561562
sendKeepAlive();
15571563
} catch (Throwable t) {
1558-
Log.w(TAG, "keepalive error: "
1559-
+ mLocalProfile.getUriString(), getRootCause(t));
1564+
if (DEBUG) {
1565+
Log.w(TAG, "keepalive error: "
1566+
+ mLocalProfile.getUriString(), getRootCause(t));
1567+
}
15601568
// It's possible that the keepalive process is being stopped
15611569
// during session.sendKeepAlive() so need to check mRunning
15621570
// again here.

voip/java/com/android/server/sip/SipWakeLock.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import java.util.HashSet;
2323

2424
class SipWakeLock {
25-
private static final boolean DEBUGV = SipService.DEBUGV;
26-
private static final String TAG = SipService.TAG;
25+
private static final boolean DEBUG = false;
26+
private static final String TAG = "SipWakeLock";
2727
private PowerManager mPowerManager;
2828
private PowerManager.WakeLock mWakeLock;
2929
private PowerManager.WakeLock mTimerWakeLock;
@@ -34,9 +34,9 @@ class SipWakeLock {
3434
}
3535

3636
synchronized void reset() {
37+
if (DEBUG) Log.v(TAG, "reset count=" + mHolders.size());
3738
mHolders.clear();
3839
release(null);
39-
if (DEBUGV) Log.v(TAG, "~~~ hard reset wakelock");
4040
}
4141

4242
synchronized void acquire(long timeout) {
@@ -55,8 +55,7 @@ synchronized void acquire(Object holder) {
5555
PowerManager.PARTIAL_WAKE_LOCK, "SipWakeLock");
5656
}
5757
if (!mWakeLock.isHeld()) mWakeLock.acquire();
58-
if (DEBUGV) Log.v(TAG, "acquire wakelock: holder count="
59-
+ mHolders.size());
58+
if (DEBUG) Log.v(TAG, "acquire count=" + mHolders.size());
6059
}
6160

6261
synchronized void release(Object holder) {
@@ -65,7 +64,6 @@ synchronized void release(Object holder) {
6564
&& mWakeLock.isHeld()) {
6665
mWakeLock.release();
6766
}
68-
if (DEBUGV) Log.v(TAG, "release wakelock: holder count="
69-
+ mHolders.size());
67+
if (DEBUG) Log.v(TAG, "release count=" + mHolders.size());
7068
}
7169
}

0 commit comments

Comments
 (0)