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)
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index ab3b314..c1a334a 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -2975,11 +2975,7 @@
                 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 a9a906a..c15e2a8 100644
--- a/service/java/com/android/server/wifi/WifiLogger.java
+++ b/service/java/com/android/server/wifi/WifiLogger.java
@@ -231,8 +231,11 @@
         }
 
         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 81c6274..d915ff3 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 @@
 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 @@
     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 @@
     @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 @@
         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));
+    }
 }