summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormukesh agrawal <quiche@google.com>2017-05-11 20:18:57 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-05-11 20:18:57 +0000
commit6fc3eb35ecb986259c19142166deffdcd2b03b14 (patch)
treeca83611805e296b441632ebbfaa24c884594be65
parent9f51cc970b39325c0b30c15756f87bdec94cb18e (diff)
parentf72eaac0e38a0f4682839fc1826651015f2c94a9 (diff)
Merge "WifiDiagnostics: disable ring-buffers on |user| builds" into oc-dev
am: f72eaac0e3 Change-Id: I5df8304315a1eec36826d984adfdbab253a3932e
-rw-r--r--service/java/com/android/server/wifi/WifiDiagnostics.java5
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java38
2 files changed, 36 insertions, 7 deletions
diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java
index 9803b6dc0..b2acb2abf 100644
--- a/service/java/com/android/server/wifi/WifiDiagnostics.java
+++ b/service/java/com/android/server/wifi/WifiDiagnostics.java
@@ -413,6 +413,11 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
}
private boolean fetchRingBuffers() {
+ if (mBuildProperties.isUserBuild()) {
+ mRingBuffers = null;
+ return false;
+ }
+
if (mRingBuffers != null) return true;
mRingBuffers = mWifiNative.getRingBufferStatus();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
index 41453d6a7..f4b710e91 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
@@ -168,6 +168,7 @@ public class WifiDiagnosticsTest {
@Test
public void startLoggingStopsAndRestartsRingBufferLogging() throws Exception {
final boolean verbosityToggle = false;
+ setBuildPropertiesToEnableRingBuffers();
mWifiDiagnostics.startLogging(verbosityToggle);
verify(mWifiNative).startLoggingRingBuffer(
eq(WifiDiagnostics.VERBOSE_NO_LOG), anyInt(), anyInt(), anyInt(),
@@ -177,6 +178,14 @@ public class WifiDiagnosticsTest {
eq(FAKE_RING_BUFFER_NAME));
}
+ @Test
+ public void startLoggingDoesNotStartRingBuffersOnUserBuilds() throws Exception {
+ final boolean verbosityToggle = true;
+ mWifiDiagnostics.startLogging(verbosityToggle);
+ verify(mWifiNative, never()).startLoggingRingBuffer(
+ anyInt(), anyInt(), anyInt(), anyInt(), anyString());
+ }
+
/** Verifies that, if a log handler was registered, then stopLogging() resets it. */
@Test
public void stopLoggingResetsLogHandlerIfHandlerWasRegistered() throws Exception {
@@ -222,6 +231,7 @@ public class WifiDiagnosticsTest {
@Test
public void canCaptureAndStoreRingBufferData() throws Exception {
final boolean verbosityToggle = false;
+ setBuildPropertiesToEnableRingBuffers();
mWifiDiagnostics.startLogging(verbosityToggle);
final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
@@ -239,6 +249,7 @@ public class WifiDiagnosticsTest {
@Test
public void loggerDiscardsExtraneousData() throws Exception {
final boolean verbosityToggle = false;
+ setBuildPropertiesToEnableRingBuffers();
mWifiDiagnostics.startLogging(verbosityToggle);
final byte[] data1 = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
@@ -593,15 +604,16 @@ public class WifiDiagnosticsTest {
assertFalse(fateDumpString.contains("Frame bytes"));
}
- /** Verifies that the default size of our ring buffers is small. */
@Test
- public void ringBufferSizeIsSmallByDefault() throws Exception {
- final boolean verbosityToggle = false;
+ public void dumpSucceedsEvenIfRingBuffersAreDisabled() {
+ final boolean verbosityToggle = true;
mWifiDiagnostics.startLogging(verbosityToggle);
- mWifiDiagnostics.onRingBufferData(
- mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
- mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
- assertEquals(0, getLoggerRingBufferData().length);
+ verify(mWifiNative, never()).startLoggingRingBuffer(
+ anyInt(), anyInt(), anyInt(), anyInt(), anyString());
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ mWifiDiagnostics.dump(new FileDescriptor(), pw, new String[]{"bogus", "args"});
}
/** Verifies that we use small ring buffers by default, on userdebug builds. */
@@ -636,6 +648,8 @@ public class WifiDiagnosticsTest {
@Test
public void ringBufferSizeIsLargeInVerboseMode() throws Exception {
final boolean verbosityToggle = true;
+ setBuildPropertiesToEnableRingBuffers();
+
mWifiDiagnostics.startLogging(verbosityToggle);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[LARGE_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE]);
@@ -646,6 +660,8 @@ public class WifiDiagnosticsTest {
/** Verifies that we use large ring buffers when switched from normal to verbose mode. */
@Test
public void startLoggingGrowsRingBuffersIfNeeded() throws Exception {
+ setBuildPropertiesToEnableRingBuffers();
+
mWifiDiagnostics.startLogging(false /* verbose disabled */);
mWifiDiagnostics.startLogging(true /* verbose enabled */);
mWifiDiagnostics.onRingBufferData(
@@ -657,6 +673,8 @@ public class WifiDiagnosticsTest {
/** Verifies that we use small ring buffers when switched from verbose to normal mode. */
@Test
public void startLoggingShrinksRingBuffersIfNeeded() throws Exception {
+ setBuildPropertiesToEnableRingBuffers();
+
mWifiDiagnostics.startLogging(true /* verbose enabled */);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
@@ -786,4 +804,10 @@ public class WifiDiagnosticsTest {
new FileDescriptor(), new PrintWriter(new StringWriter()), new String[]{});
verify(mLastMileLogger).dump(anyObject());
}
+
+ private void setBuildPropertiesToEnableRingBuffers() {
+ when(mBuildProperties.isEngBuild()).thenReturn(false);
+ when(mBuildProperties.isUserdebugBuild()).thenReturn(true);
+ when(mBuildProperties.isUserBuild()).thenReturn(false);
+ }
}