am 0e67685e: am bfd85f9a: Merge "SIP: turn off verbose logs." into ics-mr1

* commit '0e67685e53cbcf7682a0364cf34fd3ac0632596f':
  SIP: turn off verbose logs.
diff --git a/java/com/android/server/sip/SipHelper.java b/java/com/android/server/sip/SipHelper.java
index dc628e0..113f007 100644
--- a/java/com/android/server/sip/SipHelper.java
+++ b/java/com/android/server/sip/SipHelper.java
@@ -73,7 +73,7 @@
  */
 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;
diff --git a/java/com/android/server/sip/SipService.java b/java/com/android/server/sip/SipService.java
index 119ed54..38a683e 100644
--- a/java/com/android/server/sip/SipService.java
+++ b/java/com/android/server/sip/SipService.java
@@ -68,8 +68,7 @@
  */
 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 @@
         @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 @@
         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 @@
     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 @@
                 // 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 @@
                             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 @@
         // 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 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 @@
         }
 
         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);
         }
diff --git a/java/com/android/server/sip/SipSessionGroup.java b/java/com/android/server/sip/SipSessionGroup.java
index 06cdaf2..877a0a4 100644
--- a/java/com/android/server/sip/SipSessionGroup.java
+++ b/java/com/android/server/sip/SipSessionGroup.java
@@ -89,8 +89,8 @@
  */
 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 @@
     }
 
     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 @@
                         + 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 @@
         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 @@
             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 @@
             }
         }
 
-        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 @@
                     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.
diff --git a/java/com/android/server/sip/SipWakeLock.java b/java/com/android/server/sip/SipWakeLock.java
index 52bc094..0c4d14c 100644
--- a/java/com/android/server/sip/SipWakeLock.java
+++ b/java/com/android/server/sip/SipWakeLock.java
@@ -22,8 +22,8 @@
 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 @@
     }
 
     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 @@
                     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 @@
                 && mWakeLock.isHeld()) {
             mWakeLock.release();
         }
-        if (DEBUGV) Log.v(TAG, "release wakelock: holder count="
-                + mHolders.size());
+        if (DEBUG) Log.v(TAG, "release count=" + mHolders.size());
     }
 }