summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Ravi <sunilravi@google.com>2019-07-24 17:13:29 -0700
committerSunil Ravi <sunilravi@google.com>2019-08-28 17:58:57 +0000
commit6530ff0b4c6038db3a56350fe17db5453fdc9026 (patch)
tree6dfd84a551f69105de5a637c9e392da0b481abdb
parente8b5da4cd4f31ee92095648dd1c9a0cd0483869e (diff)
Enable WiFi HAL ring buffer in softap mode
1.Enable wifi hal ring buffer in softap mode. 2. Handle logging in concurrency mode. Bug: 137229948 Test: Take bug report in STA mode, SoftAp mode and concurrent mode and make sure wifihal ring buffer logs are captured in bugreport. Change-Id: Ib4ecaff96ebf7c89f8e509b118d99d95c91c373c Merged-In: Ib4ecaff96ebf7c89f8e509b118d99d95c91c373c
-rw-r--r--service/java/com/android/server/wifi/BaseWifiDiagnostics.java23
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java8
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java8
-rw-r--r--service/java/com/android/server/wifi/WifiDiagnostics.java127
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java27
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java293
7 files changed, 369 insertions, 119 deletions
diff --git a/service/java/com/android/server/wifi/BaseWifiDiagnostics.java b/service/java/com/android/server/wifi/BaseWifiDiagnostics.java
index 2090cac1e..3abf5100f 100644
--- a/service/java/com/android/server/wifi/BaseWifiDiagnostics.java
+++ b/service/java/com/android/server/wifi/BaseWifiDiagnostics.java
@@ -1,6 +1,8 @@
package com.android.server.wifi;
+import android.annotation.NonNull;
+
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -23,7 +25,11 @@ public class BaseWifiDiagnostics {
mWifiNative = wifiNative;
}
- public synchronized void startLogging(boolean verboseEnabled) {
+ /**
+ * start wifi HAL dependent logging features
+ * @param ifaceName requesting to start logging
+ */
+ public synchronized void startLogging(@NonNull String ifaceName) {
mFirmwareVersion = mWifiNative.getFirmwareVersion();
mDriverVersion = mWifiNative.getDriverVersion();
mSupportedFeatureSet = mWifiNative.getSupportedLoggerFeatureSet();
@@ -33,7 +39,11 @@ public class BaseWifiDiagnostics {
public synchronized void stopPacketLog() { }
- public synchronized void stopLogging() { }
+ /**
+ * stop wifi HAL dependent logging features
+ * @param ifaceName requesting to stop logging
+ */
+ public synchronized void stopLogging(@NonNull String ifaceName) { }
/**
* Inform the diagnostics module of a connection event.
@@ -64,4 +74,11 @@ public class BaseWifiDiagnostics {
pw.println("Driver Version is: " + mDriverVersion);
pw.println("Supported Feature set: " + mSupportedFeatureSet);
}
-} \ No newline at end of file
+
+ /** enables/disables wifi verbose logging */
+ public synchronized void enableVerboseLogging(boolean verboseEnabled) { }
+
+ /** enables packet fate monitoring */
+ public void startPktFateMonitoring(@NonNull String ifaceName) {}
+
+}
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 292e902bc..8e8361ed4 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -1108,7 +1108,7 @@ public class ClientModeImpl extends StateMachine {
setSupplicantLogLevel();
mCountryCode.enableVerboseLogging(verbose);
mWifiScoreReport.enableVerboseLogging(mVerboseLoggingEnabled);
- mWifiDiagnostics.startLogging(mVerboseLoggingEnabled);
+ mWifiDiagnostics.enableVerboseLogging(mVerboseLoggingEnabled);
mWifiMonitor.enableVerboseLogging(verbose);
mWifiNative.enableVerboseLogging(verbose);
mWifiConfigManager.enableVerboseLogging(verbose);
@@ -3767,7 +3767,9 @@ public class ClientModeImpl extends StateMachine {
setRandomMacOui();
mCountryCode.setReadyForChange(true);
- mWifiDiagnostics.startLogging(mVerboseLoggingEnabled);
+ mWifiDiagnostics.startPktFateMonitoring(mInterfaceName);
+ mWifiDiagnostics.startLogging(mInterfaceName);
+
mIsRunning = true;
updateBatteryWorkSource(null);
@@ -3805,7 +3807,7 @@ public class ClientModeImpl extends StateMachine {
*/
private void stopClientMode() {
// exiting supplicant started state is now only applicable to client mode
- mWifiDiagnostics.stopLogging();
+ mWifiDiagnostics.stopLogging(mInterfaceName);
mIsRunning = false;
updateBatteryWorkSource(null);
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index b92dab78d..79bc46fa5 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -95,6 +95,8 @@ public class SoftApManager implements ActiveModeManager {
private long mStartTimestamp = -1;
+ private BaseWifiDiagnostics mWifiDiagnostics;
+
/**
* Listener for soft AP events.
*/
@@ -127,7 +129,8 @@ public class SoftApManager implements ActiveModeManager {
@NonNull WifiApConfigStore wifiApConfigStore,
@NonNull SoftApModeConfiguration apConfig,
@NonNull WifiMetrics wifiMetrics,
- @NonNull SarManager sarManager) {
+ @NonNull SarManager sarManager,
+ @NonNull BaseWifiDiagnostics wifiDiagnostics) {
mContext = context;
mFrameworkFacade = framework;
mWifiNative = wifiNative;
@@ -143,6 +146,7 @@ public class SoftApManager implements ActiveModeManager {
}
mWifiMetrics = wifiMetrics;
mSarManager = sarManager;
+ mWifiDiagnostics = wifiDiagnostics;
mStateMachine = new SoftApStateMachine(looper);
}
@@ -287,6 +291,7 @@ public class SoftApManager implements ActiveModeManager {
Log.e(TAG, "Soft AP start failed");
return ERROR_GENERIC;
}
+ mWifiDiagnostics.startLogging(mApInterfaceName);
mStartTimestamp = SystemClock.elapsedRealtime();
Log.d(TAG, "Soft AP is started");
@@ -297,6 +302,7 @@ public class SoftApManager implements ActiveModeManager {
* Teardown soft AP and teardown the interface.
*/
private void stopSoftAp() {
+ mWifiDiagnostics.stopLogging(mApInterfaceName);
mWifiNative.teardownInterface(mApInterfaceName);
Log.d(TAG, "Soft AP is stopped");
}
diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java
index aa34f6bed..da1e5b3c5 100644
--- a/service/java/com/android/server/wifi/WifiDiagnostics.java
+++ b/service/java/com/android/server/wifi/WifiDiagnostics.java
@@ -18,7 +18,9 @@ package com.android.server.wifi;
import android.annotation.NonNull;
import android.content.Context;
+import android.util.ArraySet;
import android.util.Base64;
+import android.util.Log;
import android.util.SparseLongArray;
import com.android.internal.R;
@@ -40,6 +42,7 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
+import java.util.Set;
import java.util.stream.Collectors;
import java.util.zip.Deflater;
@@ -124,6 +127,9 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
private WifiInjector mWifiInjector;
private Clock mClock;
+ /** Interfaces started logging */
+ private final Set<String> mActiveInterfaces = new ArraySet<>();
+
public WifiDiagnostics(Context context, WifiInjector wifiInjector,
WifiNative wifiNative, BuildProperties buildProperties,
LastMileLogger lastMileLogger, Clock clock) {
@@ -148,40 +154,35 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
mClock = clock;
}
+ /**
+ * Start wifi HAL dependent logging features.
+ * This method should be called only after the interface has
+ * been set up.
+ *
+ * @param ifaceName the interface requesting to start logging.
+ */
@Override
- public synchronized void startLogging(boolean verboseEnabled) {
- mFirmwareVersion = mWifiNative.getFirmwareVersion();
- mDriverVersion = mWifiNative.getDriverVersion();
- mSupportedFeatureSet = mWifiNative.getSupportedLoggerFeatureSet();
-
- if (!mIsLoggingEventHandlerRegistered) {
- mIsLoggingEventHandlerRegistered = mWifiNative.setLoggingEventHandler(mHandler);
+ public synchronized void startLogging(@NonNull String ifaceName) {
+ if (mActiveInterfaces.contains(ifaceName)) {
+ Log.w(TAG, "Interface: " + ifaceName + " had already started logging");
+ return;
}
+ if (mActiveInterfaces.isEmpty()) {
+ mFirmwareVersion = mWifiNative.getFirmwareVersion();
+ mDriverVersion = mWifiNative.getDriverVersion();
+ mSupportedFeatureSet = mWifiNative.getSupportedLoggerFeatureSet();
- if (verboseEnabled) {
- mLogLevel = VERBOSE_LOG_WITH_WAKEUP;
- mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_LARGE;
- } else {
- mLogLevel = VERBOSE_NORMAL_LOG;
- mMaxRingBufferSizeBytes = enableVerboseLoggingForDogfood()
- ? RING_BUFFER_BYTE_LIMIT_LARGE : RING_BUFFER_BYTE_LIMIT_SMALL;
- clearVerboseLogs();
- }
+ if (!mIsLoggingEventHandlerRegistered) {
+ mIsLoggingEventHandlerRegistered = mWifiNative.setLoggingEventHandler(mHandler);
+ }
- if (mRingBuffers == null) {
- fetchRingBuffers();
+ startLoggingRingBuffers();
}
- if (mRingBuffers != null) {
- /* log level may have changed, so restart logging with new levels */
- stopLoggingAllBuffers();
- resizeRingBuffers();
- startLoggingAllExceptPerPacketBuffers();
- }
+ mActiveInterfaces.add(ifaceName);
- if (!mWifiNative.startPktFateMonitoring(mWifiNative.getClientInterfaceName())) {
- mLog.wC("Failed to start packet fate monitoring");
- }
+ Log.d(TAG, "startLogging() iface list is " + mActiveInterfaces
+ + " after adding " + ifaceName);
}
@Override
@@ -202,8 +203,28 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
}
}
+ /**
+ * Stop wifi HAL dependent logging features.
+ * This method should be called before the interface has been
+ * torn down.
+ *
+ * @param ifaceName the interface requesting to stop logging.
+ */
@Override
- public synchronized void stopLogging() {
+ public synchronized void stopLogging(@NonNull String ifaceName) {
+ if (!mActiveInterfaces.contains(ifaceName)) {
+ Log.w(TAG, "ifaceName: " + ifaceName + " is not in the start log user list");
+ return;
+ }
+
+ mActiveInterfaces.remove(ifaceName);
+
+ Log.d(TAG, "stopLogging() iface list is " + mActiveInterfaces
+ + " after removing " + ifaceName);
+
+ if (!mActiveInterfaces.isEmpty()) {
+ return;
+ }
if (mIsLoggingEventHandlerRegistered) {
if (!mWifiNative.resetLogHandler()) {
mLog.wC("Fail to reset log handler");
@@ -217,7 +238,6 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
if (mLogLevel != VERBOSE_NO_LOG) {
stopLoggingAllBuffers();
mRingBuffers = null;
- mLogLevel = VERBOSE_NO_LOG;
}
}
@@ -442,6 +462,28 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
mWifiMetrics.logFirmwareAlert(errorCode);
}
+ /**
+ * Enables or disables verbose logging
+ *
+ * @param verbose - with the obvious interpretation
+ */
+ @Override
+ public synchronized void enableVerboseLogging(boolean verboseEnabled) {
+ if (verboseEnabled) {
+ mLogLevel = VERBOSE_LOG_WITH_WAKEUP;
+ mMaxRingBufferSizeBytes = RING_BUFFER_BYTE_LIMIT_LARGE;
+ } else {
+ mLogLevel = VERBOSE_NORMAL_LOG;
+ mMaxRingBufferSizeBytes = enableVerboseLoggingForDogfood()
+ ? RING_BUFFER_BYTE_LIMIT_LARGE : RING_BUFFER_BYTE_LIMIT_SMALL;
+ }
+
+ if (!mActiveInterfaces.isEmpty()) {
+ mLog.wC("verbosity changed: restart logging");
+ startLoggingRingBuffers();
+ }
+ }
+
private boolean isVerboseLoggingEnabled() {
return mLogLevel > VERBOSE_NORMAL_LOG;
}
@@ -485,6 +527,21 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
}
}
+ private void startLoggingRingBuffers() {
+ if (!isVerboseLoggingEnabled()) {
+ clearVerboseLogs();
+ }
+ if (mRingBuffers == null) {
+ fetchRingBuffers();
+ }
+ if (mRingBuffers != null) {
+ // Log level may have changed, so restart logging with new levels.
+ stopLoggingAllBuffers();
+ resizeRingBuffers();
+ startLoggingAllExceptPerPacketBuffers();
+ }
+ }
+
private boolean startLoggingAllExceptPerPacketBuffers() {
if (mRingBuffers == null) {
@@ -742,4 +799,16 @@ class WifiDiagnostics extends BaseWifiDiagnostics {
pw.println("--------------------------------------------------------------------");
}
+
+ /**
+ * Enable packet fate monitoring.
+ *
+ * @param ifaceName Name of the interface.
+ */
+ @Override
+ public void startPktFateMonitoring(@NonNull String ifaceName) {
+ if (!mWifiNative.startPktFateMonitoring(ifaceName)) {
+ mLog.wC("Failed to start packet fate monitoring");
+ }
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 8095bfac6..3a79e590b 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -537,7 +537,7 @@ public class WifiInjector {
@NonNull SoftApModeConfiguration config) {
return new SoftApManager(mContext, mWifiCoreHandlerThread.getLooper(),
mFrameworkFacade, mWifiNative, mCountryCode.getCountryCode(), callback,
- mWifiApConfigStore, config, mWifiMetrics, mSarManager);
+ mWifiApConfigStore, config, mWifiMetrics, mSarManager, mWifiDiagnostics);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index ed70ef5a2..c08adc1d1 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -89,6 +89,7 @@ public class SoftApManagerTest {
@Mock WifiApConfigStore mWifiApConfigStore;
@Mock WifiMetrics mWifiMetrics;
@Mock SarManager mSarManager;
+ @Mock BaseWifiDiagnostics mWifiDiagnostics;
final ArgumentCaptor<WifiNative.InterfaceCallback> mWifiNativeInterfaceCallbackCaptor =
ArgumentCaptor.forClass(WifiNative.InterfaceCallback.class);
final ArgumentCaptor<WifiNative.SoftApListener> mSoftApListenerCaptor =
@@ -136,7 +137,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
config,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
return newSoftApManager;
@@ -209,7 +211,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
nullApConfig,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
newSoftApManager.start();
mLooper.dispatchAll();
@@ -252,7 +255,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
nullApConfig,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
newSoftApManager.start();
mLooper.dispatchAll();
@@ -294,7 +298,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
nullApConfig,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
newSoftApManager.start();
mLooper.dispatchAll();
@@ -335,7 +340,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
softApConfig,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
newSoftApManager.start();
mLooper.dispatchAll();
@@ -381,7 +387,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
softApConfig,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
newSoftApManager.start();
mLooper.dispatchAll();
@@ -497,7 +504,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
softApConfig,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
newSoftApManager.start();
mLooper.dispatchAll();
@@ -535,7 +543,8 @@ public class SoftApManagerTest {
mWifiApConfigStore,
softApModeConfig,
mWifiMetrics,
- mSarManager);
+ mSarManager,
+ mWifiDiagnostics);
mLooper.dispatchAll();
newSoftApManager.start();
@@ -589,6 +598,7 @@ public class SoftApManagerTest {
order.verify(mCallback).onStateChanged(WifiManager.WIFI_AP_STATE_DISABLED, 0);
verify(mSarManager).setSapWifiState(WifiManager.WIFI_AP_STATE_DISABLED);
+ verify(mWifiDiagnostics).stopLogging(TEST_INTERFACE_NAME);
order.verify(mContext).sendStickyBroadcastAsUser(intentCaptor.capture(),
eq(UserHandle.ALL));
checkApStateChangedBroadcast(intentCaptor.getValue(), WIFI_AP_STATE_DISABLED,
@@ -1097,6 +1107,7 @@ public class SoftApManagerTest {
order.verify(mCallback).onStateChanged(WifiManager.WIFI_AP_STATE_ENABLED, 0);
order.verify(mCallback).onNumClientsChanged(0);
verify(mSarManager).setSapWifiState(WifiManager.WIFI_AP_STATE_ENABLED);
+ verify(mWifiDiagnostics).startLogging(TEST_INTERFACE_NAME);
verify(mContext, times(2)).sendStickyBroadcastAsUser(intentCaptor.capture(),
eq(UserHandle.ALL));
List<Intent> capturedIntents = intentCaptor.getAllValues();
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
index 6b63137a2..988373795 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiDiagnosticsTest.java
@@ -74,6 +74,8 @@ public class WifiDiagnosticsTest {
WifiDiagnostics mWifiDiagnostics;
private static final String FAKE_RING_BUFFER_NAME = "fake-ring-buffer";
+ private static final String STA_IF_NAME = "wlan0";
+ private static final String AP_IF_NAME = "wlan1";
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;
@@ -137,8 +139,8 @@ public class WifiDiagnosticsTest {
/** Verifies that startLogging() registers a logging event handler. */
@Test
public void startLoggingRegistersLogEventHandler() throws Exception {
- final boolean verbosityToggle = false; // even default mode registers handler
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(false);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
verify(mWifiNative).setLoggingEventHandler(anyObject());
}
@@ -152,12 +154,15 @@ public class WifiDiagnosticsTest {
final boolean verbosityToggle = false; // even default mode registers handler
when(mWifiNative.setLoggingEventHandler(anyObject())).thenReturn(false);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
verify(mWifiNative).setLoggingEventHandler(anyObject());
+ mWifiDiagnostics.stopLogging(STA_IF_NAME);
reset(mWifiNative);
when(mWifiNative.setLoggingEventHandler(anyObject())).thenReturn(true);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
verify(mWifiNative).setLoggingEventHandler(anyObject());
}
@@ -165,14 +170,14 @@ public class WifiDiagnosticsTest {
@Test
public void startLoggingDoesNotRegisterLogEventHandlerIfPriorAttemptSucceeded()
throws Exception {
- final boolean verbosityToggle = false; // even default mode registers handler
-
when(mWifiNative.setLoggingEventHandler(anyObject())).thenReturn(true);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(false);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
verify(mWifiNative).setLoggingEventHandler(anyObject());
reset(mWifiNative);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(false);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
verify(mWifiNative, never()).setLoggingEventHandler(anyObject());
}
@@ -186,7 +191,8 @@ public class WifiDiagnosticsTest {
@Test
public void startLoggingStopsAndRestartsRingBufferLoggingInVerboseMode() throws Exception {
final boolean verbosityToggle = true;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
verify(mWifiNative).startLoggingRingBuffer(
eq(WifiDiagnostics.VERBOSE_NO_LOG), anyInt(), anyInt(), anyInt(),
eq(FAKE_RING_BUFFER_NAME));
@@ -198,7 +204,8 @@ public class WifiDiagnosticsTest {
@Test
public void startLoggingStopsAndThenStartRingBufferLoggingInNormalMode() throws Exception {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
verify(mWifiNative).startLoggingRingBuffer(
eq(WifiDiagnostics.VERBOSE_NO_LOG), anyInt(), anyInt(), anyInt(),
eq(FAKE_RING_BUFFER_NAME));
@@ -212,18 +219,19 @@ public class WifiDiagnosticsTest {
public void stopLoggingResetsLogHandlerIfHandlerWasRegistered() throws Exception {
final boolean verbosityToggle = false; // even default mode registers handler
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
when(mWifiNative.setLoggingEventHandler(anyObject())).thenReturn(true);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
reset(mWifiNative);
- mWifiDiagnostics.stopLogging();
+ mWifiDiagnostics.stopLogging(STA_IF_NAME);
verify(mWifiNative).resetLogHandler();
}
/** Verifies that, if a log handler is not registered, stopLogging() skips resetLogHandler(). */
@Test
public void stopLoggingOnlyResetsLogHandlerIfHandlerWasRegistered() throws Exception {
- mWifiDiagnostics.stopLogging();
+ mWifiDiagnostics.stopLogging(STA_IF_NAME);
verify(mWifiNative, never()).resetLogHandler();
}
@@ -233,15 +241,16 @@ public class WifiDiagnosticsTest {
final boolean verbosityToggle = false; // even default mode registers handler
when(mWifiNative.setLoggingEventHandler(anyObject())).thenReturn(true);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
reset(mWifiNative);
when(mWifiNative.resetLogHandler()).thenReturn(true);
- mWifiDiagnostics.stopLogging();
+ mWifiDiagnostics.stopLogging(STA_IF_NAME);
verify(mWifiNative).resetLogHandler();
reset(mWifiNative);
- mWifiDiagnostics.stopLogging();
+ mWifiDiagnostics.stopLogging(STA_IF_NAME);
verify(mWifiNative, never()).resetLogHandler();
}
@@ -251,7 +260,8 @@ public class WifiDiagnosticsTest {
@Test
public void canCaptureAndStoreRingBufferData() throws Exception {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
mWifiDiagnostics.onRingBufferData(mFakeRbs, data);
@@ -269,7 +279,8 @@ public class WifiDiagnosticsTest {
@Test
public void loggerDiscardsExtraneousData() throws Exception {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
final byte[] data1 = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
final byte[] data2 = {1, 2, 3};
@@ -282,34 +293,11 @@ public class WifiDiagnosticsTest {
assertArrayEquals(data2, ringBufferData[0]);
}
- /**
- * Verifies that, when verbose mode is not enabled, startLogging() calls
- * startPktFateMonitoring(any()).
- */
- @Test
- public void startLoggingStartsPacketFateWithoutVerboseMode() {
- final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
- verify(mWifiNative).startPktFateMonitoring(any());
- }
-
- /**
- * Verifies that, when verbose mode is enabled, startLogging() calls
- * startPktFateMonitoring(any()).
- */
- @Test
- public void startLoggingStartsPacketFateInVerboseMode() {
- final boolean verbosityToggle = true;
- mWifiDiagnostics.startLogging(verbosityToggle);
- verify(mWifiNative).startPktFateMonitoring(any());
- }
-
- // Verifies that startLogging() reports failure of startPktFateMonitoring(any()).
+ // Verifies that startPktFateMonitoring(any()) reports failure to start packet fate
@Test
- public void startLoggingReportsFailureOfStartPktFateMonitoring() {
- final boolean verbosityToggle = true;
+ public void startPktFateMonitoringReportsStartFailures() {
when(mWifiNative.startPktFateMonitoring(any())).thenReturn(false);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
verify(mLog).wC(contains("Failed"));
}
@@ -320,7 +308,8 @@ public class WifiDiagnosticsTest {
@Test
public void reportConnectionFailureIsIgnoredWithoutVerboseMode() {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED);
verify(mWifiNative).getTxPktFates(any(), anyObject());
verify(mWifiNative).getRxPktFates(any(), anyObject());
@@ -332,7 +321,8 @@ public class WifiDiagnosticsTest {
@Test
public void reportConnectionFailureFetchesFatesInVerboseMode() {
final boolean verbosityToggle = true;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED);
verify(mWifiNative).getTxPktFates(any(), anyObject());
verify(mWifiNative).getRxPktFates(any(), anyObject());
@@ -341,7 +331,8 @@ public class WifiDiagnosticsTest {
@Test
public void reportConnectionEventPropagatesStartToLastMileLogger() {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_STARTED);
verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_STARTED);
}
@@ -349,7 +340,8 @@ public class WifiDiagnosticsTest {
@Test
public void reportConnectionEventPropagatesSuccessToLastMileLogger() {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_SUCCEEDED);
}
@@ -357,7 +349,8 @@ public class WifiDiagnosticsTest {
@Test
public void reportConnectionEventPropagatesFailureToLastMileLogger() {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED);
verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED);
}
@@ -368,7 +361,8 @@ public class WifiDiagnosticsTest {
@Test
public void reportConnectionEventPropagatesTimeoutToLastMileLogger() {
final boolean verbosityToggle = true;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_TIMEOUT);
verify(mLastMileLogger).reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_TIMEOUT);
}
@@ -380,7 +374,8 @@ public class WifiDiagnosticsTest {
public void loggerFetchesTxFatesEvenIfFetchingRxFatesFails() {
final boolean verbosityToggle = true;
when(mWifiNative.getRxPktFates(any(), anyObject())).thenReturn(false);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED);
verify(mWifiNative).getTxPktFates(any(), anyObject());
verify(mWifiNative).getRxPktFates(any(), anyObject());
@@ -393,7 +388,8 @@ public class WifiDiagnosticsTest {
public void loggerFetchesRxFatesEvenIfFetchingTxFatesFails() {
final boolean verbosityToggle = true;
when(mWifiNative.getTxPktFates(any(), anyObject())).thenReturn(false);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED);
verify(mWifiNative).getTxPktFates(any(), anyObject());
verify(mWifiNative).getRxPktFates(any(), anyObject());
@@ -405,7 +401,8 @@ public class WifiDiagnosticsTest {
final boolean verbosityToggle = false;
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
mWifiDiagnostics.dump(new FileDescriptor(), pw, new String[]{"bogus", "args"});
verify(mWifiNative).getTxPktFates(any(), anyObject());
verify(mWifiNative).getRxPktFates(any(), anyObject());
@@ -435,7 +432,8 @@ public class WifiDiagnosticsTest {
@Test
public void dumpSucceedsWhenFatesHaveBeenFetchedButAreEmpty() {
final boolean verbosityToggle = true;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_FAILED);
verify(mWifiNative).getTxPktFates(any(), anyObject());
verify(mWifiNative).getRxPktFates(any(), anyObject());
@@ -452,7 +450,9 @@ public class WifiDiagnosticsTest {
}
private String getDumpString(boolean verbose) {
- mWifiDiagnostics.startLogging(verbose);
+ mWifiDiagnostics.enableVerboseLogging(verbose);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiNative.enableVerboseLogging(verbose ? 1 : 0);
when(mWifiNative.getTxPktFates(any(), anyObject())).then(new AnswerWithArguments() {
public boolean answer(String ifaceName, WifiNative.TxFateReport[] fates) {
@@ -586,7 +586,8 @@ public class WifiDiagnosticsTest {
@Test
public void dumpOmitsFatesIfVerboseIsDisabledAfterFetch() {
final boolean verbosityToggle = true;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startPktFateMonitoring(STA_IF_NAME);
when(mWifiNative.getTxPktFates(any(), anyObject())).then(new AnswerWithArguments() {
public boolean answer(String ifaceName, WifiNative.TxFateReport[] fates) {
fates[0] = new WifiNative.TxFateReport(
@@ -610,7 +611,8 @@ public class WifiDiagnosticsTest {
verify(mWifiNative).getRxPktFates(any(), anyObject());
final boolean newVerbosityToggle = false;
- mWifiDiagnostics.startLogging(newVerbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(newVerbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -626,7 +628,8 @@ public class WifiDiagnosticsTest {
@Test
public void ringBufferSizeIsSmallByDefault() throws Exception {
final boolean verbosityToggle = false;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
@@ -641,7 +644,8 @@ public class WifiDiagnosticsTest {
when(mBuildProperties.isUserdebugBuild()).thenReturn(true);
when(mBuildProperties.isEngBuild()).thenReturn(false);
when(mBuildProperties.isUserBuild()).thenReturn(false);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
@@ -656,7 +660,8 @@ public class WifiDiagnosticsTest {
when(mBuildProperties.isEngBuild()).thenReturn(true);
when(mBuildProperties.isUserdebugBuild()).thenReturn(false);
when(mBuildProperties.isUserBuild()).thenReturn(false);
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
@@ -668,7 +673,8 @@ public class WifiDiagnosticsTest {
public void ringBufferSizeIsLargeInVerboseMode() throws Exception {
final boolean verbosityToggle = true;
- mWifiDiagnostics.startLogging(verbosityToggle);
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[LARGE_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE]);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
@@ -678,8 +684,10 @@ public class WifiDiagnosticsTest {
/** Verifies that we use large ring buffers when switched from normal to verbose mode. */
@Test
public void startLoggingGrowsRingBuffersIfNeeded() throws Exception {
- mWifiDiagnostics.startLogging(false /* verbose disabled */);
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(false /* verbose disabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[LARGE_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE]);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
@@ -691,12 +699,14 @@ public class WifiDiagnosticsTest {
@Test
public void startLoggingShrinksRingBuffersIfNeeded() throws Exception {
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.onRingBufferData(
mFakeRbs, new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE + 1]);
// Existing data is nuked (too large).
- mWifiDiagnostics.startLogging(false /* verbose disabled */);
+ mWifiDiagnostics.enableVerboseLogging(false /* verbose disabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
assertEquals(0, getLoggerRingBufferData().length);
@@ -734,7 +744,8 @@ public class WifiDiagnosticsTest {
/** Verifies that we capture the firmware and driver dumps if verbose is enabled. */
@Test
public void captureBugReportTakesFirmwareAndDriverDumpsInVerboseMode() {
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).getFwMemoryDump();
verify(mWifiNative).getDriverStateDump();
@@ -745,7 +756,8 @@ public class WifiDiagnosticsTest {
public void dumpIncludesDriverStateDumpIfAvailable() {
when(mWifiNative.getDriverStateDump()).thenReturn(new byte[]{0, 1, 2});
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).getDriverStateDump();
@@ -758,7 +770,8 @@ public class WifiDiagnosticsTest {
/** Verifies that the dump skips driver state, if driver state was not provided by HAL. */
@Test
public void dumpOmitsDriverStateDumpIfUnavailable() {
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).getDriverStateDump();
@@ -773,11 +786,13 @@ public class WifiDiagnosticsTest {
public void dumpOmitsDriverStateDumpIfVerboseDisabledAfterCapture() {
when(mWifiNative.getDriverStateDump()).thenReturn(new byte[]{0, 1, 2});
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).getDriverStateDump();
- mWifiDiagnostics.startLogging(false /* verbose no longer enabled */);
+ mWifiDiagnostics.enableVerboseLogging(false /* verbose disabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -790,7 +805,8 @@ public class WifiDiagnosticsTest {
public void dumpIncludesFirmwareMemoryDumpIfAvailable() {
when(mWifiNative.getFwMemoryDump()).thenReturn(new byte[]{0, 1, 2});
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).getFwMemoryDump();
@@ -803,7 +819,8 @@ public class WifiDiagnosticsTest {
/** Verifies that the dump skips firmware memory, if firmware memory was not provided by HAL. */
@Test
public void dumpOmitsFirmwareMemoryDumpIfUnavailable() {
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).getFwMemoryDump();
@@ -818,11 +835,13 @@ public class WifiDiagnosticsTest {
public void dumpOmitsFirmwareMemoryDumpIfVerboseDisabledAfterCapture() {
when(mWifiNative.getFwMemoryDump()).thenReturn(new byte[]{0, 1, 2});
- mWifiDiagnostics.startLogging(true /* verbose enabled */);
+ mWifiDiagnostics.enableVerboseLogging(true /* verbose enabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
verify(mWifiNative).getFwMemoryDump();
- mWifiDiagnostics.startLogging(false /* verbose no longer enabled */);
+ mWifiDiagnostics.enableVerboseLogging(false /* verbose disabled */);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
@@ -890,4 +909,130 @@ public class WifiDiagnosticsTest {
mWifiDiagnostics.captureAlertData(NON_FATAL_FW_ALART, ALERT_DATA);
verify(mWifiNative, never()).flushRingBufferData();
}
+
+ /**
+ * Verifies that we can capture ring-buffer data in SoftAp mode
+ */
+ @Test
+ public void canCaptureAndStoreRingBufferDataInSoftApMode() throws Exception {
+ final boolean verbosityToggle = false;
+
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(AP_IF_NAME);
+
+ final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
+ mWifiDiagnostics.onRingBufferData(mFakeRbs, data);
+ mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
+
+ byte[][] ringBufferData = getLoggerRingBufferData();
+ assertEquals(1, ringBufferData.length);
+ assertArrayEquals(data, ringBufferData[0]);
+ }
+
+ /**
+ * Verifies that we capture ring-buffer data in Station + SoftAp
+ * Concurrency mode.
+ */
+ @Test
+ public void canCaptureAndStoreRingBufferDataInConcurrencyMode() throws Exception {
+ final boolean verbosityToggle = false;
+
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
+ mWifiDiagnostics.startLogging(AP_IF_NAME);
+
+ final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
+ mWifiDiagnostics.onRingBufferData(mFakeRbs, data);
+ mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
+
+ byte[][] ringBufferData = getLoggerRingBufferData();
+ assertEquals(1, ringBufferData.length);
+ assertArrayEquals(data, ringBufferData[0]);
+ }
+
+ /**
+ * Verifies that we can continue to capture ring-buffer data
+ * after WiFi station is turned off in concurrency mode.
+ */
+ @Test
+ public void canCaptureAndStoreRingBufferDataAfterStaIsTurnedOffInConcurrencyMode()
+ throws Exception {
+ final boolean verbosityToggle = false;
+ final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
+
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
+ mWifiDiagnostics.startLogging(AP_IF_NAME);
+
+ mWifiDiagnostics.onRingBufferData(mFakeRbs, data);
+ mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
+
+ byte[][] ringBufferData0 = getLoggerRingBufferData();
+ assertEquals(1, ringBufferData0.length);
+ assertArrayEquals(data, ringBufferData0[0]);
+
+ mWifiDiagnostics.stopLogging(STA_IF_NAME);
+
+ mWifiDiagnostics.onRingBufferData(mFakeRbs, data);
+ mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
+
+ byte[][] ringBufferData1 = getLoggerRingBufferData();
+ assertEquals(1, ringBufferData1.length);
+ assertArrayEquals(data, ringBufferData1[0]);
+ }
+
+ /**
+ * Verifies that we can continue to capture ring-buffer data
+ * after SoftAp is turned off in concurrency mode.
+ */
+ @Test
+ public void canCaptureAndStoreRingBufferDataAfterSoftApIsTurnedOffInConcurrencyMode()
+ throws Exception {
+ final boolean verbosityToggle = false;
+ final byte[] data = new byte[SMALL_RING_BUFFER_SIZE_KB * BYTES_PER_KBYTE];
+
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
+ mWifiDiagnostics.startLogging(AP_IF_NAME);
+
+ mWifiDiagnostics.onRingBufferData(mFakeRbs, data);
+ mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
+
+ byte[][] ringBufferData0 = getLoggerRingBufferData();
+ assertEquals(1, ringBufferData0.length);
+ assertArrayEquals(data, ringBufferData0[0]);
+
+ mWifiDiagnostics.stopLogging(AP_IF_NAME);
+
+ mWifiDiagnostics.onRingBufferData(mFakeRbs, data);
+ mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_NONE);
+
+ byte[][] ringBufferData1 = getLoggerRingBufferData();
+ assertEquals(1, ringBufferData1.length);
+ assertArrayEquals(data, ringBufferData1[0]);
+ }
+
+ /** Verifies that stoplogging on both the interfaces clean up
+ * all the resources.
+ */
+ @Test
+ public void verifyStopLoggingOnAllInterfacesClearTheResources() throws Exception {
+ final boolean verbosityToggle = false;
+
+ mWifiDiagnostics.enableVerboseLogging(verbosityToggle);
+ when(mWifiNative.setLoggingEventHandler(any())).thenReturn(true);
+ when(mWifiNative.resetLogHandler()).thenReturn(true);
+
+ mWifiDiagnostics.startLogging(STA_IF_NAME);
+ verify(mWifiNative).setLoggingEventHandler(any());
+
+ mWifiDiagnostics.startLogging(AP_IF_NAME);
+
+ mWifiDiagnostics.stopLogging(STA_IF_NAME);
+ verify(mWifiNative, never()).resetLogHandler();
+
+ mWifiDiagnostics.stopLogging(AP_IF_NAME);
+
+ verify(mWifiNative).resetLogHandler();
+ }
}