diff options
author | mukesh agrawal <quiche@google.com> | 2016-05-17 15:12:22 -0700 |
---|---|---|
committer | mukesh agrawal <quiche@google.com> | 2016-05-17 17:18:05 -0700 |
commit | 8df302f5b9c647f69acee24e09fa20d8b5c54c4a (patch) | |
tree | 1948246094f15bb3bcc450f745c7185125370ab9 | |
parent | b6d6e31dc6ed9a9a0178990a0cec8edb9ad36c77 (diff) |
WifiLogger: use large ringbuffers on eng/userdebug
We're having trouble resolving some field reports, due
to insufficient time coverage in the HAL ring buffers.
Increase the ringbuffer size of eng/userdebug builds,
to make it easier to debug issues reported by
dogfooders.
This change will be reverted closer to launch.
(b/28822174 has been filed for the reversion.)
BUG=28729317
TEST=unit tests
Change-Id: I5884dee05db79245d211a457ff44b5e7b96ddbcb
4 files changed, 70 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/FrameworkFacade.java b/service/java/com/android/server/wifi/FrameworkFacade.java index 7c1151cc2..dd5c1e9f2 100644 --- a/service/java/com/android/server/wifi/FrameworkFacade.java +++ b/service/java/com/android/server/wifi/FrameworkFacade.java @@ -48,8 +48,9 @@ public class FrameworkFacade { return new BaseWifiLogger(); } - public BaseWifiLogger makeRealLogger(WifiStateMachine stateMachine, WifiNative wifiNative) { - return new WifiLogger(stateMachine, wifiNative); + public BaseWifiLogger makeRealLogger( + WifiStateMachine stateMachine, WifiNative wifiNative, BuildProperties buildProperties) { + return new WifiLogger(stateMachine, wifiNative, buildProperties); } public boolean setIntegerSetting(Context context, String name, int def) { diff --git a/service/java/com/android/server/wifi/WifiLogger.java b/service/java/com/android/server/wifi/WifiLogger.java index 755bbf1c4..1433ab613 100644 --- a/service/java/com/android/server/wifi/WifiLogger.java +++ b/service/java/com/android/server/wifi/WifiLogger.java @@ -102,12 +102,15 @@ class WifiLogger extends BaseWifiLogger { private WifiNative.RingBufferStatus mPerPacketRingBuffer; private WifiStateMachine mWifiStateMachine; private final WifiNative mWifiNative; + private final BuildProperties mBuildProperties; private int mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_SMALL; public WifiLogger( - WifiStateMachine wifiStateMachine, WifiNative wifiNative) { + WifiStateMachine wifiStateMachine, WifiNative wifiNative, + BuildProperties buildProperties) { mWifiStateMachine = wifiStateMachine; mWifiNative = wifiNative; + mBuildProperties = buildProperties; mIsLoggingEventHandlerRegistered = false; } @@ -126,7 +129,8 @@ class WifiLogger extends BaseWifiLogger { mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_LARGE; } else { mLogLevel = VERBOSE_NORMAL_LOG; - mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_SMALL; + mMaxRingBufferSizeBytes = enableVerboseLoggingForDogfood() + ? RING_BUFFER_BYTE_LIMIT_LARGE : RING_BUFFER_BYTE_LIMIT_SMALL; clearVerboseLogs(); } @@ -490,6 +494,11 @@ class WifiLogger extends BaseWifiLogger { return true; } + /* STOPSHIP TODO(b/28822174): Disable before release. */ + private boolean enableVerboseLoggingForDogfood() { + return mBuildProperties.isEngBuild() || mBuildProperties.isUserdebugBuild(); + } + private BugReport captureBugreport(int errorCode, boolean captureFWDump) { BugReport report = new BugReport(); report.errorCode = errorCode; diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 775a40bd0..242071c52 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -1048,7 +1048,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss R.bool.config_wifi_enable_wifi_firmware_debugging); if (enableFirmwareLogs) { - mWifiLogger = facade.makeRealLogger(this, mWifiNative); + mWifiLogger = facade.makeRealLogger(this, mWifiNative, mBuildProperties); } else { mWifiLogger = facade.makeBaseLogger(); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java index 357818e9a..76851882e 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiLoggerTest.java @@ -50,6 +50,7 @@ public class WifiLoggerTest { @Mock WifiStateMachine mWsm; @Mock WifiNative mWifiNative; + @Mock BuildProperties mBuildProperties; WifiLogger mWifiLogger; private static final String FAKE_RING_BUFFER_NAME = "fake-ring-buffer"; @@ -79,8 +80,11 @@ public class WifiLoggerTest { when(mWifiNative.getRingBufferStatus()).thenReturn(ringBufferStatuses); when(mWifiNative.readKernelLog()).thenReturn(""); + when(mBuildProperties.isEngBuild()).thenReturn(false); + when(mBuildProperties.isUserdebugBuild()).thenReturn(false); + when(mBuildProperties.isUserBuild()).thenReturn(true); - mWifiLogger = new WifiLogger(mWsm, mWifiNative); + mWifiLogger = new WifiLogger(mWsm, mWifiNative, mBuildProperties); mWifiNative.enableVerboseLogging(0); } @@ -458,6 +462,30 @@ public class WifiLoggerTest { assertTrue(expected_index_of_verbose_frame_2 < expected_index_of_verbose_frame_3); } + /** Verifies that eng builds do not show fate detail outside of verbose mode. */ + @Test + public void dumpOmitsFateDetailInEngBuildsOutsideOfVerboseMode() throws Exception { + final boolean verbosityToggle = false; + when(mBuildProperties.isEngBuild()).thenReturn(true); + when(mBuildProperties.isUserdebugBuild()).thenReturn(false); + when(mBuildProperties.isUserBuild()).thenReturn(false); + String dumpString = getDumpString(verbosityToggle); + assertFalse(dumpString.contains("VERBOSE PACKET FATE DUMP")); + assertFalse(dumpString.contains("Frame bytes")); + } + + /** Verifies that userdebug builds do not show fate detail outside of verbose mode. */ + @Test + public void dumpOmitsFateDetailInUserdebugBuildsOutsideOfVerboseMode() throws Exception { + final boolean verbosityToggle = false; + when(mBuildProperties.isUserdebugBuild()).thenReturn(true); + when(mBuildProperties.isEngBuild()).thenReturn(false); + when(mBuildProperties.isUserBuild()).thenReturn(false); + String dumpString = getDumpString(verbosityToggle); + assertFalse(dumpString.contains("VERBOSE PACKET FATE DUMP")); + assertFalse(dumpString.contains("Frame bytes")); + } + /** * Verifies that, if verbose is disabled after fetching fates, the dump does not include * verbose fate logs. @@ -511,6 +539,32 @@ public class WifiLoggerTest { assertEquals(0, getLoggerRingBufferData().length); } + /** Verifies that we use large ring buffers by default, on userdebug builds. */ + @Test + public void ringBufferSizeIsLargeByDefaultOnUserdebugBuilds() throws Exception { + final boolean verbosityToggle = false; + when(mBuildProperties.isUserdebugBuild()).thenReturn(true); + when(mBuildProperties.isEngBuild()).thenReturn(false); + when(mBuildProperties.isUserBuild()).thenReturn(false); + mWifiLogger.startLogging(verbosityToggle); + mWifiLogger.onRingBufferData(mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_LARGE]); + mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE); + assertEquals(1, getLoggerRingBufferData().length); + } + + /** Verifies that we use large ring buffers by default, on eng builds. */ + @Test + public void ringBufferSizeIsLargeByDefaultOnEngBuilds() throws Exception { + final boolean verbosityToggle = false; + when(mBuildProperties.isEngBuild()).thenReturn(true); + when(mBuildProperties.isUserdebugBuild()).thenReturn(false); + when(mBuildProperties.isUserBuild()).thenReturn(false); + mWifiLogger.startLogging(verbosityToggle); + mWifiLogger.onRingBufferData(mFakeRbs, new byte[WifiLogger.RING_BUFFER_BYTE_LIMIT_LARGE]); + mWifiLogger.captureBugReportData(WifiLogger.REPORT_REASON_NONE); + assertEquals(1, getLoggerRingBufferData().length); + } + /** Verifies that we use large ring buffers when initially started in verbose mode. */ @Test public void ringBufferSizeIsLargeInVerboseMode() throws Exception { |