summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2016-06-23 11:50:59 -0700
committerMukesh Agrawal <quiche@google.com>2016-07-11 23:12:07 +0000
commit20d76f6f2f264cc27a8821e46ad1bd1dc50700e7 (patch)
tree2b710c7858a68024520f929a970385d82f77b7e6
parentd0a7e444a6af85ccaa03e52bcb82de7f66033cfb (diff)
WifiConfigManager: move dumping of LocalLog
The dump() method of WifiConfigManager dumps the LocalLog that's used by WCM. That would make sense, except that the LocalLog that WCM uses isn't actually owned by WCM. Instead, the LocalLog is allocated by WifiNative, and shared by multiple objects. (The sharing is safe, because LocalLog's methods are synchronized.) Since the LocalLog in question is a shared facility, let's move dumping of the LocalLog to WifiLogger. BUG=29424414 TEST=unit tests TEST=manual Manual test $ adb bugreport foo.zip $ unzip foo.zip $ grep 'WifiNative LocalLog' bugreport*.txt -> expect a match Change-Id: I291ac29385472fd0e56fcb522d818dcffcedfe36 (cherry picked from commit 6b42d03b9d92d6167a0629b042b2a3c2e2489a1b)
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java6
-rw-r--r--service/java/com/android/server/wifi/WifiLogger.java5
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java19
3 files changed, 23 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index ab3b31484..c1a334a5d 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -2975,11 +2975,7 @@ public class WifiConfigManager {
pw.println(s);
}
}
- if (mLocalLog != null) {
- pw.println("WifiConfigManager - Log Begin ----");
- mLocalLog.dump(fd, pw, args);
- pw.println("WifiConfigManager - Log End ----");
- }
+
if (mMOManager.isConfigured()) {
pw.println("Begin dump of ANQP Cache");
mAnqpCache.dump(pw);
diff --git a/service/java/com/android/server/wifi/WifiLogger.java b/service/java/com/android/server/wifi/WifiLogger.java
index a9a906a29..c15e2a841 100644
--- a/service/java/com/android/server/wifi/WifiLogger.java
+++ b/service/java/com/android/server/wifi/WifiLogger.java
@@ -231,8 +231,11 @@ class WifiLogger extends BaseWifiLogger {
}
dumpPacketFates(pw);
-
pw.println("--------------------------------------------------------------------");
+
+ pw.println("WifiNative - Log Begin ----");
+ mWifiNative.getLocalLog().dump(fd, pw, args);
+ pw.println("WifiNative - Log End ----");
}
/* private methods and data */
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
index 81c6274e8..d915ff368 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java
@@ -19,6 +19,7 @@ package com.android.server.wifi;
import android.content.Context;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.internal.R;
+import android.util.LocalLog;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@@ -61,6 +62,7 @@ public class WifiLoggerTest {
private static final int SMALL_RING_BUFFER_SIZE_KB = 32;
private static final int LARGE_RING_BUFFER_SIZE_KB = 1024;
private static final int BYTES_PER_KBYTE = 1024;
+ private LocalLog mWifiNativeLocalLog;
private WifiNative.RingBufferStatus mFakeRbs;
/**
@@ -78,15 +80,17 @@ public class WifiLoggerTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+
mFakeRbs = new WifiNative.RingBufferStatus();
mFakeRbs.name = FAKE_RING_BUFFER_NAME;
-
WifiNative.RingBufferStatus[] ringBufferStatuses = new WifiNative.RingBufferStatus[] {
mFakeRbs
};
+ mWifiNativeLocalLog = new LocalLog(8192);
when(mWifiNative.getRingBufferStatus()).thenReturn(ringBufferStatuses);
when(mWifiNative.readKernelLog()).thenReturn("");
+ when(mWifiNative.getLocalLog()).thenReturn(mWifiNativeLocalLog);
when(mBuildProperties.isEngBuild()).thenReturn(false);
when(mBuildProperties.isUserdebugBuild()).thenReturn(false);
when(mBuildProperties.isUserBuild()).thenReturn(true);
@@ -719,4 +723,17 @@ public class WifiLoggerTest {
mWifiLogger.dump(new FileDescriptor(), pw, new String[]{});
assertFalse(sw.toString().contains(WifiLogger.FIRMWARE_DUMP_SECTION_HEADER));
}
+
+ /** Verifies that the dump() includes contents of WifiNative's LocalLog. */
+ @Test
+ public void dumpIncludesContentOfWifiNativeLocalLog() {
+ final String wifiNativeLogMessage = "This is a message";
+ mWifiNativeLocalLog.log(wifiNativeLogMessage);
+
+ mWifiLogger.startLogging(false /* verbose disabled */);
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ mWifiLogger.dump(new FileDescriptor(), pw, new String[]{});
+ assertTrue(sw.toString().contains(wifiNativeLogMessage));
+ }
}