OSDN Git Service

DO NOT MERGE Netd events: record connect() success/errno
authorHugo Benichi <hugobenichi@google.com>
Mon, 31 Oct 2016 06:04:37 +0000 (15:04 +0900)
committerHugo Benichi <hugobenichi@google.com>
Thu, 15 Dec 2016 11:51:14 +0000 (20:51 +0900)
Test: $ runtest frameworks-net pass
Bug: 32198976

(cherry picked from commit 8b06bcdfd24100302818ae0e11ee751dd813d5cf)

Change-Id: I527f98c28b31f490ea999222ef8d0b685a2f24ed

services/core/java/com/android/server/connectivity/NetdEventListenerService.java

index 8450482..348f64c 100644 (file)
@@ -46,7 +46,7 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
     public static final String SERVICE_NAME = "netd_listener";
 
     private static final String TAG = NetdEventListenerService.class.getSimpleName();
-    private static final boolean DBG = true;
+    private static final boolean DBG = false;
     private static final boolean VDBG = false;
 
     // TODO: read this constant from system property
@@ -88,7 +88,7 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
             byte[] returnCodes = Arrays.copyOf(mReturnCodes, mEventCount);
             int[] latenciesMs = Arrays.copyOf(mLatenciesMs, mEventCount);
             mMetricsLog.log(new DnsEvent(mNetId, eventTypes, returnCodes, latenciesMs));
-            maybeLog(String.format("Logging %d results for netId %d", mEventCount, mNetId));
+            maybeLog("Logging %d results for netId %d", mEventCount, mNetId);
             mEventCount = 0;
         }
 
@@ -155,8 +155,7 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
     public synchronized void onDnsEvent(int netId, int eventType, int returnCode, int latencyMs,
             String hostname, String[] ipAddresses, int ipAddressesCount, int uid)
             throws RemoteException {
-        maybeVerboseLog(String.format("onDnsEvent(%d, %d, %d, %d)",
-                netId, eventType, returnCode, latencyMs));
+        maybeVerboseLog("onDnsEvent(%d, %d, %d, %dms)", netId, eventType, returnCode, latencyMs);
 
         DnsEventBatch batch = mEventBatches.get(netId);
         if (batch == null) {
@@ -174,9 +173,9 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
     @Override
     // Called concurrently by multiple binder threads.
     // This method must not block or perform long-running operations.
-    public synchronized void onConnectEvent(int netId, int latencyMs, String ipAddr, int port,
+    public synchronized void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port,
             int uid) throws RemoteException {
-        maybeVerboseLog(String.format("onConnectEvent(%d, %d)", netId, latencyMs));
+        maybeVerboseLog("onConnectEvent(%d, %d, %dms)", netId, error, latencyMs);
 
         if (mNetdEventCallback != null) {
             mNetdEventCallback.onConnectEvent(ipAddr, port, System.currentTimeMillis(), uid);
@@ -193,11 +192,11 @@ public class NetdEventListenerService extends INetdEventListener.Stub {
         pw.decreaseIndent();
     }
 
-    private static void maybeLog(String s) {
-        if (DBG) Log.d(TAG, s);
+    private static void maybeLog(String s, Object... args) {
+        if (DBG) Log.d(TAG, String.format(s, args));
     }
 
-    private static void maybeVerboseLog(String s) {
-        if (VDBG) Log.d(TAG, s);
+    private static void maybeVerboseLog(String s, Object... args) {
+        if (VDBG) Log.d(TAG, String.format(s, args));
     }
 }