Add wifi scan and disconnect heuristics

Change-Id: Ib513af70611367dd0ddce5b21ae7df56a2371b4d
diff --git a/src/com/android/loganalysis/item/DumpsysItem.java b/src/com/android/loganalysis/item/DumpsysItem.java
index 5bd82e2..7f219bf 100644
--- a/src/com/android/loganalysis/item/DumpsysItem.java
+++ b/src/com/android/loganalysis/item/DumpsysItem.java
@@ -28,9 +28,11 @@
     private static final String BATTERY_STATS = "BATTERY_STATS";
     /** Constant for JSON output */
     private static final String PROC_STATS = "PROC_STATS";
+    /** Constant for JSON output */
+    private static final String WIFI_STATS = "WIFI_STATS";
 
     private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
-            BATTERY_STATS, PROC_STATS));
+            BATTERY_STATS, PROC_STATS, WIFI_STATS));
 
     /**
      * The constructor for {@link DumpsysItem}.
@@ -54,6 +56,13 @@
     }
 
     /**
+     * Set the {@link DumpsysWifiStatsItem} of the bugreport.
+     */
+    public void setWifiStats(DumpsysWifiStatsItem wifiStats) {
+        setAttribute(WIFI_STATS, wifiStats);
+    }
+
+    /**
      * Get the {@link DumpsysBatteryStatsItem} of the bugreport.
      */
     public DumpsysBatteryStatsItem getBatteryStats() {
@@ -66,4 +75,11 @@
     public DumpsysProcStatsItem getProcStats() {
         return (DumpsysProcStatsItem) getAttribute(PROC_STATS);
     }
+
+    /**
+     * Get the {@link DumpsysWifiStatsItem} of the bugreport.
+     */
+    public DumpsysWifiStatsItem getWifiStats() {
+        return (DumpsysWifiStatsItem) getAttribute(WIFI_STATS);
+    }
 }
diff --git a/src/com/android/loganalysis/item/DumpsysWifiStatsItem.java b/src/com/android/loganalysis/item/DumpsysWifiStatsItem.java
new file mode 100644
index 0000000..6ceb073
--- /dev/null
+++ b/src/com/android/loganalysis/item/DumpsysWifiStatsItem.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.loganalysis.item;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An {@link IItem} used to store wifi dumps.
+ */
+public class DumpsysWifiStatsItem extends GenericItem {
+    /** Constant for JSON output */
+    public static final String WIFI_DISCONNECT = "WIFI_DISCONNECT";
+    /** Constant for JSON output */
+    public static final String WIFI_SCAN = "WIFI_SCAN";
+
+    private static final Set<String> ATTRIBUTES = new HashSet<String>(Arrays.asList(
+            WIFI_DISCONNECT, WIFI_SCAN));
+
+     /**
+     * The constructor for {@link DumpsysWifiStatsItem}.
+     */
+    public DumpsysWifiStatsItem() {
+        super(ATTRIBUTES);
+    }
+
+    /**
+     * Set number of times of wifi disconnect
+     */
+    public void setNumWifiDisconnect(int numWifiDisconnects) {
+        setAttribute(WIFI_DISCONNECT, numWifiDisconnects);
+    }
+
+    /**
+     * Set number of times of wifi scan
+     */
+    public void setNumWifiScan(int numWifiScans) {
+        setAttribute(WIFI_SCAN, numWifiScans);
+    }
+
+    /**
+     * Get the number of times wifi disconnected
+     */
+    public int getNumWifiDisconnects() {
+        return (int) getAttribute(WIFI_DISCONNECT);
+    }
+
+    /**
+     * Get the number of times wifi scan event triggered
+     */
+    public int getNumWifiScans() {
+        return (int) getAttribute(WIFI_SCAN);
+    }
+}
diff --git a/src/com/android/loganalysis/parser/DumpsysParser.java b/src/com/android/loganalysis/parser/DumpsysParser.java
index d8941e0..b74a86c 100644
--- a/src/com/android/loganalysis/parser/DumpsysParser.java
+++ b/src/com/android/loganalysis/parser/DumpsysParser.java
@@ -19,6 +19,7 @@
 import com.android.loganalysis.item.DumpsysBatteryStatsItem;
 import com.android.loganalysis.item.DumpsysItem;
 import com.android.loganalysis.item.DumpsysProcStatsItem;
+import com.android.loganalysis.item.DumpsysWifiStatsItem;
 
 import java.util.List;
 
@@ -26,14 +27,16 @@
  * A {@link IParser} to handle the output of the dumpsys section of the bugreport.
  */
 public class DumpsysParser extends AbstractSectionParser {
-    
+
     private static final String BATTERY_STATS_SECTION_REGEX = "^DUMP OF SERVICE batterystats:$";
     private static final String PROC_STATS_SECTION_REGEX = "^DUMP OF SERVICE procstats:";
+    private static final String WIFI_SECTION_REGEX = "^DUMP OF SERVICE wifi:";
     private static final String NOOP_SECTION_REGEX = "DUMP OF SERVICE .*";
 
     private DumpsysBatteryStatsParser mBatteryStatsParser = new DumpsysBatteryStatsParser();
     private DumpsysProcStatsParser mProcStatsParser = new DumpsysProcStatsParser();
-    
+    private DumpsysWifiStatsParser mWifiStatsParser = new DumpsysWifiStatsParser();
+
     private DumpsysItem mDumpsys = null;
 
     /**
@@ -61,6 +64,7 @@
     protected void setup() {
         addSectionParser(mBatteryStatsParser, BATTERY_STATS_SECTION_REGEX);
         addSectionParser(mProcStatsParser, PROC_STATS_SECTION_REGEX);
+        addSectionParser(mWifiStatsParser, WIFI_SECTION_REGEX);
         addSectionParser(new NoopParser(), NOOP_SECTION_REGEX);
     }
 
@@ -77,6 +81,7 @@
         if (mDumpsys != null) {
             mDumpsys.setBatteryInfo((DumpsysBatteryStatsItem) getSection(mBatteryStatsParser));
             mDumpsys.setProcStats((DumpsysProcStatsItem) getSection(mProcStatsParser));
+            mDumpsys.setWifiStats((DumpsysWifiStatsItem) getSection(mWifiStatsParser));
         }
     }
 }
diff --git a/src/com/android/loganalysis/parser/DumpsysWifiStatsParser.java b/src/com/android/loganalysis/parser/DumpsysWifiStatsParser.java
new file mode 100644
index 0000000..d977902
--- /dev/null
+++ b/src/com/android/loganalysis/parser/DumpsysWifiStatsParser.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.loganalysis.parser;
+
+import com.android.loganalysis.item.DumpsysWifiStatsItem;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A {@link IParser} to parse wifi stats and extract the number of disconnects and scans
+ */
+public class DumpsysWifiStatsParser implements IParser {
+
+    /**
+     * Matches: 01-04 00:16:27.666 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]
+     */
+    private static final Pattern WIFI_SCAN = Pattern.compile(
+            "^\\d+-\\d+ \\d+:\\d+:\\d+\\.\\d+ - Event \\[IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED \\]");
+
+    /**
+     * Matches: 01-04 00:16:27.666 - Event [IFNAME=wlan0 CTRL-EVENT-DISCONNECTED
+     * bssid=6c:f3:7f:ae:89:92 reason=0 locally_generated=1]
+     */
+    private static final Pattern WIFI_DISCONNECT = Pattern.compile(
+            "^\\d+-\\d+ \\d+:\\d+:\\d+\\.\\d+ - Event \\[IFNAME=wlan0 CTRL-EVENT-DISCONNECTED "
+            + "bssid=\\w+:\\w+:\\w+:\\w+:\\w+:\\w+ reason=\\d+(\\s*locally_generated=\\d+)?\\]");
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return The {@link DumpsysWifiStatsItem}.
+     */
+    @Override
+    public DumpsysWifiStatsItem parse(List<String> lines) {
+        DumpsysWifiStatsItem item = new DumpsysWifiStatsItem();
+        int numWifiScans = 0;
+        int numWifiDisconnects = 0;
+        for (String line : lines) {
+            Matcher m = WIFI_SCAN.matcher(line);
+            if(m.matches()) {
+                numWifiScans++;
+                continue;
+            }
+            m = WIFI_DISCONNECT.matcher(line);
+            if (m.matches()) {
+                numWifiDisconnects++;
+            }
+        }
+        item.setNumWifiScan(numWifiScans);
+        item.setNumWifiDisconnect(numWifiDisconnects);
+        return item;
+    }
+
+}
diff --git a/src/com/android/loganalysis/rule/AbstractPowerRule.java b/src/com/android/loganalysis/rule/AbstractPowerRule.java
index cab46a3..cd9a0f7 100644
--- a/src/com/android/loganalysis/rule/AbstractPowerRule.java
+++ b/src/com/android/loganalysis/rule/AbstractPowerRule.java
@@ -20,6 +20,7 @@
 import com.android.loganalysis.item.BugreportItem;
 import com.android.loganalysis.item.BatteryStatsSummaryInfoItem;
 import com.android.loganalysis.item.DumpsysProcStatsItem;
+import com.android.loganalysis.item.DumpsysWifiStatsItem;
 
 import org.json.JSONObject;
 
@@ -32,6 +33,7 @@
     private BatteryStatsSummaryInfoItem mPowerSummaryAnalysisItem;
     private BatteryStatsDetailedInfoItem mPowerDetailedAnalysisItem;
     private DumpsysProcStatsItem mProcStatsItem;
+    private DumpsysWifiStatsItem mWifiStatsItem;
 
     public AbstractPowerRule(BugreportItem bugreportItem) {
         mBugreportItem = bugreportItem;
@@ -40,6 +42,7 @@
         mPowerDetailedAnalysisItem = mBugreportItem.getDumpsys().getBatteryStats().
                 getDetailedBatteryStatsItem();
         mProcStatsItem = mBugreportItem.getDumpsys().getProcStats();
+        mWifiStatsItem = mBugreportItem.getDumpsys().getWifiStats();
     }
 
     protected long getTimeOnBattery() {
@@ -58,6 +61,10 @@
         return mProcStatsItem;
     }
 
+    protected DumpsysWifiStatsItem getWifiStatsItem() {
+        return mWifiStatsItem;
+    }
+
     @Override
     public abstract void applyRule();
 
diff --git a/src/com/android/loganalysis/rule/RuleEngine.java b/src/com/android/loganalysis/rule/RuleEngine.java
index 57daa19..61c2081 100644
--- a/src/com/android/loganalysis/rule/RuleEngine.java
+++ b/src/com/android/loganalysis/rule/RuleEngine.java
@@ -67,5 +67,6 @@
         mRulesList.add(new WakelockRule(mBugreportItem));
         mRulesList.add(new ProcessUsageRule(mBugreportItem));
         mRulesList.add(new LocationUsageRule(mBugreportItem));
+        mRulesList.add(new WifiStatsRule(mBugreportItem));
     }
 }
diff --git a/src/com/android/loganalysis/rule/WifiStatsRule.java b/src/com/android/loganalysis/rule/WifiStatsRule.java
new file mode 100644
index 0000000..4a20520
--- /dev/null
+++ b/src/com/android/loganalysis/rule/WifiStatsRule.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.loganalysis.rule;
+
+import com.android.loganalysis.item.BugreportItem;
+import com.android.loganalysis.item.DumpsysWifiStatsItem;
+
+import java.util.concurrent.TimeUnit;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Rules definition for Process usage
+ */
+public class WifiStatsRule extends AbstractPowerRule {
+
+    private static final String WIFI_STATS = "WIFI_STATS";
+    private static final int WIFI_DISCONNECT_THRESHOLD = 1; // wifi disconnect should never happen
+    // Wifi scans are scheduled by GSA every 285 seconds, anything more frequent is an issue
+    private static final long WIFI_SCAN_INTERVAL_THRESHOLD_MS = 285000;
+
+    private StringBuffer mAnalysisBuffer;
+    private BugreportItem mBugreportItem = null;
+
+    public WifiStatsRule (BugreportItem bugreportItem) {
+        super(bugreportItem);
+        mBugreportItem = bugreportItem;
+    }
+
+    @Override
+    public void applyRule() {
+        mAnalysisBuffer = new StringBuffer();
+        if (mBugreportItem.getDumpsys() == null || getTimeOnBattery() <= 0) {
+            return;
+        }
+        DumpsysWifiStatsItem dumpsysWifiStatsItem = mBugreportItem.getDumpsys().getWifiStats();
+        if (dumpsysWifiStatsItem == null) {
+            return;
+        }
+        if (dumpsysWifiStatsItem.getNumWifiScans() > 0) {
+            final long observedWifiScanIntervalMs = getTimeOnBattery() /
+                    dumpsysWifiStatsItem.getNumWifiScans();
+
+            if (observedWifiScanIntervalMs < WIFI_SCAN_INTERVAL_THRESHOLD_MS) {
+                mAnalysisBuffer.append(String.format("Wifi scans happened every %d seconds.",
+                        TimeUnit.MILLISECONDS.toSeconds(observedWifiScanIntervalMs)));
+            }
+            if (dumpsysWifiStatsItem.getNumWifiDisconnects() >= WIFI_DISCONNECT_THRESHOLD) {
+                mAnalysisBuffer.append(String.format("Wifi got disconnected %d times",
+                        dumpsysWifiStatsItem.getNumWifiDisconnects()));
+            }
+        }
+    }
+
+    @Override
+    public JSONObject getAnalysis() {
+        JSONObject wifiStatsAnalysis = new JSONObject();
+        try {
+            wifiStatsAnalysis.put(WIFI_STATS, mAnalysisBuffer.toString());
+        } catch (JSONException e) {
+          // do nothing
+        }
+        return wifiStatsAnalysis;
+    }
+}
diff --git a/tests/src/com/android/loganalysis/parser/DumpsysParserTest.java b/tests/src/com/android/loganalysis/parser/DumpsysParserTest.java
index 7dff3a1..a722ac6 100644
--- a/tests/src/com/android/loganalysis/parser/DumpsysParserTest.java
+++ b/tests/src/com/android/loganalysis/parser/DumpsysParserTest.java
@@ -92,11 +92,38 @@
                 "      Persistent: 100% (159MB-160MB-161MB/153MB-153MB-154MB over 13)",
                 "  * com.google.process.gapps / u0a9 / v22:",
                 "           TOTAL: 100% (22MB-24MB-25MB/18MB-19MB-20MB over 13)",
-                "          Imp Fg: 100% (22MB-24MB-25MB/18MB-19MB-20MB over 13)");
+                "          Imp Fg: 100% (22MB-24MB-25MB/18MB-19MB-20MB over 13)",
+                "DUMP OF SERVICE wifi:",
+                "Wi-Fi is enabled",
+                "rec[0]: time=10-09 00:25:16.737 processed=DefaultState org=DeviceActiveState "
+                + "dest=<null> what=155654(0x26006)",
+                "mScreenOff true",
+                " rec[0]: time=10-08 16:49:55.034 processed=WatchdogEnabledState org=OnlineState "
+                + "dest=OnlineWatchState what=135170(0x21002)",
+                "rec[30]: time=10-08 13:06:50.379 processed=DriverStartedState org=ConnectedState "
+                + "dest=<null> what=131143(0x20047) (1)CMD_START_SCAN  rt=4720806/7884852 10013 51 "
+                + "ic=0 proc(ms):14 onGoing full started:1444334810368,11 cnt=24 rssi=-127 f=-1 "
+                + "sc=0 link=-1 tx=1.5, 1.7, 0.0  rx=8.4 fiv=20000 [on:3266 tx:65 rx:556 "
+                + "period:1268] from screen [on:266962 period:266959]",
+                "rec[357]: time=10-08 13:10:13.199 processed=DriverStartedState org=ConnectedState "
+                + "dest=<null> what=131143(0x20047) (-2)CMD_START_SCAN  rt=4923625/8087671 10013 "
+                + "175 ic=0 proc(ms):2 onGoing full started:1444335011199,1999 cnt=24 rssi=-127 "
+                + "f=-1 sc=0 link=-1 tx=8.4, 1.7, 0.0  rx=6.7 fiv=20000 [on:0 tx:0 rx:0 period:990]"
+                + "from screen [on:467747 period:469779]",
+                "WifiConfigStore - Log Begin ----",
+                "10-08 11:09:14.653 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]",
+                "10-08 13:06:29.489 - Event [IFNAME=wlan0 CTRL-EVENT-DISCONNECTED "
+                + "bssid=9c:1c:12:c3:d0:72 reason=0]",
+                "10-08 13:06:22.280 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]",
+                "10-08 13:06:25.363 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]",
+                "10-08 13:08:15.018 - Event [IFNAME=wlan0 CTRL-EVENT-DISCONNECTED "
+                + "bssid=9c:1c:12:e8:72:d2 reason=3 locally_generated=1]",
+                "10-08 13:08:15.324 - wlan0: 442:IFNAME=wlan0 ENABLE_NETWORK 0 -> true");
 
         DumpsysItem dumpsys = new DumpsysParser().parse(inputBlock);
         assertNotNull(dumpsys.getBatteryStats());
         assertNotNull(dumpsys.getProcStats());
+        assertNotNull(dumpsys.getWifiStats());
     }
 }
 
diff --git a/tests/src/com/android/loganalysis/parser/DumpsysWifiStatsParserTest.java b/tests/src/com/android/loganalysis/parser/DumpsysWifiStatsParserTest.java
new file mode 100644
index 0000000..6a9e302
--- /dev/null
+++ b/tests/src/com/android/loganalysis/parser/DumpsysWifiStatsParserTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.loganalysis.parser;
+
+import com.android.loganalysis.item.DumpsysWifiStatsItem;
+
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Unit tests for {@link DumpsysWifiStatsParser}
+ */
+public class DumpsysWifiStatsParserTest extends TestCase {
+
+    /**
+     * Test that normal input is parsed.
+     */
+    public void testDumpsysWifiStatsParser() {
+        List<String> inputBlock = Arrays.asList(
+                "Wi-Fi is enabled",
+                "rec[0]: time=10-09 00:25:16.737 processed=DefaultState org=DeviceActiveState "
+                + "dest=<null> what=155654(0x26006)",
+                "mScreenOff true",
+                " rec[0]: time=10-08 16:49:55.034 processed=WatchdogEnabledState org=OnlineState "
+                + "dest=OnlineWatchState what=135170(0x21002)",
+                "rec[30]: time=10-08 13:06:50.379 processed=DriverStartedState org=ConnectedState "
+                + "dest=<null> what=131143(0x20047) (1)CMD_START_SCAN  rt=4720806/7884852 10013 51 "
+                + "ic=0 proc(ms):14 onGoing full started:1444334810368,11 cnt=24 rssi=-127 f=-1 "
+                + "sc=0 link=-1 tx=1.5, 1.7, 0.0  rx=8.4 fiv=20000 [on:3266 tx:65 rx:556 "
+                + "period:1268] from screen [on:266962 period:266959]",
+                "rec[357]: time=10-08 13:10:13.199 processed=DriverStartedState org=ConnectedState "
+                + "dest=<null> what=131143(0x20047) (-2)CMD_START_SCAN  rt=4923625/8087671 10013 "
+                + "175 ic=0 proc(ms):2 onGoing full started:1444335011199,1999 cnt=24 rssi=-127 "
+                + "f=-1 sc=0 link=-1 tx=8.4, 1.7, 0.0  rx=6.7 fiv=20000 [on:0 tx:0 rx:0 period:990] "
+                + "from screen [on:467747 period:469779]",
+                "WifiConfigStore - Log Begin ----",
+                "10-08 11:09:14.653 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]",
+                "10-08 13:06:29.489 - Event [IFNAME=wlan0 CTRL-EVENT-DISCONNECTED "
+                + "bssid=9c:1c:12:c3:d0:72 reason=0]",
+                "10-08 13:06:22.280 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]",
+                "10-08 13:06:25.363 - Event [IFNAME=wlan0 CTRL-EVENT-SCAN-STARTED ]",
+                "10-08 13:08:15.018 - Event [IFNAME=wlan0 CTRL-EVENT-DISCONNECTED "
+                + "bssid=9c:1c:12:e8:72:d2 reason=3 locally_generated=1]",
+                "10-08 13:08:15.324 - wlan0: 442:IFNAME=wlan0 ENABLE_NETWORK 0 -> true");
+
+        DumpsysWifiStatsItem wifiStats = new DumpsysWifiStatsParser().parse(inputBlock);
+        assertEquals(2, wifiStats.getNumWifiDisconnects());
+        assertEquals(3, wifiStats.getNumWifiScans());
+    }
+
+    /**
+     * Test that input with no wifi disconnect and wifi scans.
+     */
+    public void testDumpsysWifiStatsParser_no_wifi_scan_disconnect() {
+        List<String> inputBlock = Arrays.asList(
+                "Wi-Fi is enabled",
+                "rec[0]: time=10-09 00:25:16.737 processed=DefaultState org=DeviceActiveState "
+                + "dest=<null> what=155654(0x26006)",
+                "mScreenOff true",
+                " rec[0]: time=10-08 16:49:55.034 processed=WatchdogEnabledState org=OnlineState "
+                + "dest=OnlineWatchState what=135170(0x21002)",
+                "rec[30]: time=10-08 13:06:50.379 processed=DriverStartedState org=ConnectedState "
+                + "dest=<null> what=131143(0x20047) (1)CMD_START_SCAN  rt=4720806/7884852 10013 51 "
+                + "ic=0 proc(ms):14 onGoing full started:1444334810368,11 cnt=24 rssi=-127 f=-1 "
+                + "sc=0 link=-1 tx=1.5, 1.7, 0.0  rx=8.4 fiv=20000 [on:3266 tx:65 rx:556 "
+                + "period:1268] from screen [on:266962 period:266959]",
+                "rec[357]: time=10-08 13:10:13.199 processed=DriverStartedState org=ConnectedState "
+                + "dest=<null> what=131143(0x20047) (-2)CMD_START_SCAN  rt=4923625/8087671 10013 "
+                + "175 ic=0 proc(ms):2 onGoing full started:1444335011199,1999 cnt=24 rssi=-127 "
+                + "f=-1 sc=0 link=-1 tx=8.4, 1.7, 0.0  rx=6.7 fiv=20000 [on:0 tx:0 rx:0 period:990]"
+                + "from screen [on:467747 period:469779]",
+                "WifiConfigStore - Log Begin ----",
+                "10-08 13:07:37.777 - wlan0: 384:IFNAME=wlan0 ENABLE_NETWORK 4 -> true",
+                "10-08 13:07:37.789 - wlan0: 388:IFNAME=wlan0 SAVE_CONFIG -> true",
+                "10-08 13:08:15.065 - wlan0: 427:IFNAME=wlan0 SET ps 1 -> true",
+                "10-08 13:08:15.179 - wlan0: 432:IFNAME=wlan0 SET pno 1 -> true");
+
+        DumpsysWifiStatsItem wifiStats = new DumpsysWifiStatsParser().parse(inputBlock);
+        assertEquals(0, wifiStats.getNumWifiDisconnects());
+        assertEquals(0, wifiStats.getNumWifiScans());
+    }
+}
+