diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2012-01-20 14:24:15 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-01-20 14:24:15 -0800 |
commit | 67d853b61a2d077d51545c480206b1873c74ea46 (patch) | |
tree | 1d6306e40f26c67d89790675b2baacd47fbe2e8d /services | |
parent | 1bf599a01e7ad720150d8cc12416ba67bebd74c9 (diff) | |
parent | 470fd72a06390d7a6b854583afd0ed76ce0a03ee (diff) | |
download | frameworks_base-67d853b61a2d077d51545c480206b1873c74ea46.zip frameworks_base-67d853b61a2d077d51545c480206b1873c74ea46.tar.gz frameworks_base-67d853b61a2d077d51545c480206b1873c74ea46.tar.bz2 |
Merge "Log netd traffic nicely."
Diffstat (limited to 'services')
3 files changed, 28 insertions, 6 deletions
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java index a32e9f5..366160b 100644 --- a/services/java/com/android/server/MountService.java +++ b/services/java/com/android/server/MountService.java @@ -1169,7 +1169,7 @@ class MountService extends IMountService.Stub * amount of containers we'd ever expect to have. This keeps an * "asec list" from blocking a thread repeatedly. */ - mConnector = new NativeDaemonConnector(this, "vold", MAX_CONTAINERS * 2, VOLD_TAG); + mConnector = new NativeDaemonConnector(this, "vold", MAX_CONTAINERS * 2, VOLD_TAG, 25); mReady = false; Thread thread = new Thread(mConnector, VOLD_TAG); thread.start(); @@ -2429,6 +2429,10 @@ class MountService extends IMountService.Stub pw.println(v.toString()); } } + + pw.println(); + pw.println(" mConnection:"); + mConnector.dump(fd, pw, args); } /** {@inheritDoc} */ diff --git a/services/java/com/android/server/NativeDaemonConnector.java b/services/java/com/android/server/NativeDaemonConnector.java index cc2bcd9..f475dd6 100644 --- a/services/java/com/android/server/NativeDaemonConnector.java +++ b/services/java/com/android/server/NativeDaemonConnector.java @@ -22,14 +22,17 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.os.SystemClock; +import android.util.LocalLog; import android.util.Slog; import com.google.android.collect.Lists; +import java.nio.charset.Charsets; +import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.charset.Charsets; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -45,6 +48,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo private String mSocket; private OutputStream mOutputStream; + private LocalLog mLocalLog; private final BlockingQueue<NativeDaemonEvent> mResponseQueue; @@ -57,11 +61,12 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo private final int BUFFER_SIZE = 4096; NativeDaemonConnector(INativeDaemonConnectorCallbacks callbacks, String socket, - int responseQueueSize, String logTag) { + int responseQueueSize, String logTag, int maxLogSize) { mCallbacks = callbacks; mSocket = socket; mResponseQueue = new LinkedBlockingQueue<NativeDaemonEvent>(responseQueueSize); TAG = logTag != null ? logTag : "NativeDaemonConnector"; + mLocalLog = new LocalLog(maxLogSize); } @Override @@ -125,7 +130,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo if (buffer[i] == 0) { final String rawEvent = new String( buffer, start, i - start, Charsets.UTF_8); - if (LOGD) Slog.d(TAG, "RCV <- " + rawEvent); + log("RCV <- {" + rawEvent + "}"); try { final NativeDaemonEvent event = NativeDaemonEvent.parseRawEvent( @@ -208,7 +213,7 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo } final String unterminated = builder.toString(); - if (LOGD) Slog.d(TAG, "SND -> " + unterminated); + log("SND -> {" + unterminated + "}"); builder.append('\0'); @@ -432,4 +437,13 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo public void monitor() { synchronized (mDaemonLock) { } } + + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + mLocalLog.dump(fd, pw, args); + } + + private void log(String logstring) { + if (LOGD) Slog.d(TAG, logstring); + mLocalLog.log(logstring); + } } diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index c1d8a13..7bb7938 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -163,7 +163,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub } mConnector = new NativeDaemonConnector( - new NetdCallbackReceiver(), "netd", 10, NETD_TAG); + new NetdCallbackReceiver(), "netd", 10, NETD_TAG, 50); mThread = new Thread(mConnector, NETD_TAG); // Add ourself to the Watchdog monitors. @@ -1265,6 +1265,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { mContext.enforceCallingOrSelfPermission(DUMP, TAG); + pw.println("NetworkManagementService NativeDaemonConnector Log:"); + mConnector.dump(fd, pw, args); + pw.println(); + pw.print("Bandwidth control enabled: "); pw.println(mBandwidthControlEnabled); synchronized (mQuotaLock) { |