summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorSunil Ravi <sunilravi@google.com>2019-08-29 22:53:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-08-29 22:53:55 +0000
commit8c75b6b98895a732d715e52d034b905fbc132f2c (patch)
treea71866fbb9a0236d3bb58fbcb218b42277638861 /service
parente7588d9fa3e2661ff0505172c96f5626c3016a91 (diff)
parent6530ff0b4c6038db3a56350fe17db5453fdc9026 (diff)
Merge "Enable WiFi HAL ring buffer in softap mode" into qt-qpr1-dev
Diffstat (limited to 'service')
-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
5 files changed, 131 insertions, 37 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);
}
/**