summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2018-05-09 23:18:01 -0700
committerRebecca Silberstein <silberst@google.com>2018-05-10 12:39:56 -0700
commitf29c56eb230ac7b4148226151e2f4731011d5a43 (patch)
tree336f01a15f0283b92c21e8209b09935bfc1fc851 /service
parent43b4bb291800401b67daf50156f8d04c64569c21 (diff)
ActiveModeManager: add dump calls
To aid in debugging, add dump calls to active mode managers. Bug: 79155403 Test: manually verify dumpsys wifi Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: Id37bc7e1dc214d3cac057f1645addd4ef162fdea
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ActiveModeManager.java8
-rw-r--r--service/java/com/android/server/wifi/ClientModeManager.java29
-rw-r--r--service/java/com/android/server/wifi/DefaultModeManager.java8
-rw-r--r--service/java/com/android/server/wifi/ScanOnlyModeManager.java29
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java58
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java4
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachinePrime.java18
7 files changed, 139 insertions, 15 deletions
diff --git a/service/java/com/android/server/wifi/ActiveModeManager.java b/service/java/com/android/server/wifi/ActiveModeManager.java
index 6669e32f7..f193a0c94 100644
--- a/service/java/com/android/server/wifi/ActiveModeManager.java
+++ b/service/java/com/android/server/wifi/ActiveModeManager.java
@@ -22,6 +22,9 @@ import android.net.wifi.WifiManager;
import android.os.UserHandle;
import android.util.Log;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* Base class for available WiFi operating modes.
*
@@ -41,6 +44,11 @@ public interface ActiveModeManager {
void stop();
/**
+ * Method to dump for logging state.
+ */
+ void dump(FileDescriptor fd, PrintWriter pw, String[] args);
+
+ /**
* Method that allows Mode Managers to update WifiScanner about the current state.
*
* @param context Context to use for the notification
diff --git a/service/java/com/android/server/wifi/ClientModeManager.java b/service/java/com/android/server/wifi/ClientModeManager.java
index 8aecd1ebd..1f52c336f 100644
--- a/service/java/com/android/server/wifi/ClientModeManager.java
+++ b/service/java/com/android/server/wifi/ClientModeManager.java
@@ -31,6 +31,9 @@ import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.server.wifi.WifiNative.InterfaceCallback;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* Manager WiFi in Client Mode where we connect to configured networks.
*/
@@ -48,7 +51,7 @@ public class ClientModeManager implements ActiveModeManager {
private final WifiStateMachine mWifiStateMachine;
private String mClientInterfaceName;
- private boolean mIfaceIsUp;
+ private boolean mIfaceIsUp = false;
ClientModeManager(Context context, @NonNull Looper looper, WifiNative wifiNative,
Listener listener, WifiMetrics wifiMetrics, ScanRequestProxy scanRequestProxy,
@@ -73,8 +76,7 @@ public class ClientModeManager implements ActiveModeManager {
* Disconnect from any currently connected networks and stop client mode.
*/
public void stop() {
- IState currentState = mStateMachine.getCurrentState();
- Log.d(TAG, " currentstate: " + currentState);
+ Log.d(TAG, " currentstate: " + getCurrentStateName());
if (mClientInterfaceName != null) {
if (mIfaceIsUp) {
updateWifiState(WifiManager.WIFI_STATE_DISABLING,
@@ -88,6 +90,17 @@ public class ClientModeManager implements ActiveModeManager {
}
/**
+ * Dump info about this ClientMode manager.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("--Dump of ClientModeManager--");
+
+ pw.println("current StateMachine mode: " + getCurrentStateName());
+ pw.println("mClientInterfaceName: " + mClientInterfaceName);
+ pw.println("mIfaceIsUp: " + mIfaceIsUp);
+ }
+
+ /**
* Listener for ClientMode state changes.
*/
public interface Listener {
@@ -98,6 +111,16 @@ public class ClientModeManager implements ActiveModeManager {
void onStateChanged(int state);
}
+ private String getCurrentStateName() {
+ IState currentState = mStateMachine.getCurrentState();
+
+ if (currentState != null) {
+ return currentState.getName();
+ }
+
+ return "StateMachine not active";
+ }
+
/**
* Update Wifi state and send the broadcast.
* @param newState new Wifi state
diff --git a/service/java/com/android/server/wifi/DefaultModeManager.java b/service/java/com/android/server/wifi/DefaultModeManager.java
index 6d51c9fde..3a164d644 100644
--- a/service/java/com/android/server/wifi/DefaultModeManager.java
+++ b/service/java/com/android/server/wifi/DefaultModeManager.java
@@ -20,6 +20,9 @@ import android.annotation.NonNull;
import android.content.Context;
import android.os.Looper;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* Manager to handle API calls when wifi is disabled (other mode managers could be active, but this
* class triggers calls to the default implementations).
@@ -40,6 +43,11 @@ public class DefaultModeManager implements ActiveModeManager {
*/
public void stop() { };
+ /**
+ * Dump is not used in default mode.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { }
+
DefaultModeManager(Context context, @NonNull Looper looper) {
mContext = context;
}
diff --git a/service/java/com/android/server/wifi/ScanOnlyModeManager.java b/service/java/com/android/server/wifi/ScanOnlyModeManager.java
index 985d025db..a98c6ba66 100644
--- a/service/java/com/android/server/wifi/ScanOnlyModeManager.java
+++ b/service/java/com/android/server/wifi/ScanOnlyModeManager.java
@@ -29,6 +29,9 @@ import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.server.wifi.WifiNative.InterfaceCallback;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* Manager WiFi in Scan Only Mode - no network connections.
*/
@@ -47,6 +50,7 @@ public class ScanOnlyModeManager implements ActiveModeManager {
private final WakeupController mWakeupController;
private String mClientInterfaceName;
+ private boolean mIfaceIsUp = false;
ScanOnlyModeManager(@NonNull Context context, @NonNull Looper looper,
@NonNull WifiNative wifiNative, @NonNull Listener listener,
@@ -73,12 +77,22 @@ public class ScanOnlyModeManager implements ActiveModeManager {
* Cancel any pending scans and stop scan mode.
*/
public void stop() {
- IState currentState = mStateMachine.getCurrentState();
- Log.d(TAG, " currentstate: " + currentState);
+ Log.d(TAG, " currentstate: " + getCurrentStateName());
mStateMachine.quitNow();
}
/**
+ * Dump info about this ScanOnlyMode manager.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("--Dump of ScanOnlyModeManager--");
+
+ pw.println("current StateMachine mode: " + getCurrentStateName());
+ pw.println("mClientInterfaceName: " + mClientInterfaceName);
+ pw.println("mIfaceIsUp: " + mIfaceIsUp);
+ }
+
+ /**
* Listener for ScanOnlyMode state changes.
*/
public interface Listener {
@@ -89,6 +103,16 @@ public class ScanOnlyModeManager implements ActiveModeManager {
void onStateChanged(int state);
}
+ private String getCurrentStateName() {
+ IState currentState = mStateMachine.getCurrentState();
+
+ if (currentState != null) {
+ return currentState.getName();
+ }
+
+ return "StateMachine not active";
+ }
+
/**
* Update Wifi state.
* @param state new Wifi state
@@ -129,7 +153,6 @@ public class ScanOnlyModeManager implements ActiveModeManager {
}
}
};
- private boolean mIfaceIsUp = false;
ScanOnlyModeStateMachine(Looper looper) {
super(TAG, looper);
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index a23d046e3..dc3c7f578 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -45,6 +45,8 @@ import com.android.server.wifi.WifiNative.InterfaceCallback;
import com.android.server.wifi.WifiNative.SoftApListener;
import com.android.server.wifi.util.ApConfigUtil;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.Locale;
/**
@@ -81,6 +83,12 @@ public class SoftApManager implements ActiveModeManager {
private final int mMode;
private WifiConfiguration mApConfig;
+ private int mReportedFrequency = -1;
+ private int mReportedBandwidth = -1;
+
+ private int mNumAssociatedStations = 0;
+ private boolean mTimeoutEnabled = false;
+
/**
* Listener for soft AP events.
*/
@@ -135,8 +143,7 @@ public class SoftApManager implements ActiveModeManager {
* Stop soft AP.
*/
public void stop() {
- IState currentState = mStateMachine.getCurrentState();
- Log.d(TAG, " currentstate: " + currentState);
+ Log.d(TAG, " currentstate: " + getCurrentStateName());
if (mApInterfaceName != null) {
if (mIfaceIsUp) {
updateApState(WifiManager.WIFI_AP_STATE_DISABLING,
@@ -150,6 +157,40 @@ public class SoftApManager implements ActiveModeManager {
}
/**
+ * Dump info about this softap manager.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("--Dump of SoftApManager--");
+
+ pw.println("current StateMachine mode: " + getCurrentStateName());
+ pw.println("mApInterfaceName: " + mApInterfaceName);
+ pw.println("mIfaceIsUp: " + mIfaceIsUp);
+ pw.println("mMode: " + mMode);
+ pw.println("mCountryCode: " + mCountryCode);
+ if (mApConfig != null) {
+ pw.println("mApConfig.SSID: " + mApConfig.SSID);
+ pw.println("mApConfig.apBand: " + mApConfig.apBand);
+ pw.println("mApConfig.hiddenSSID: " + mApConfig.hiddenSSID);
+ } else {
+ pw.println("mApConfig: null");
+ }
+ pw.println("mNumAssociatedStations: " + mNumAssociatedStations);
+ pw.println("mTimeoutEnabled: " + mTimeoutEnabled);
+ pw.println("mReportedFrequency: " + mReportedFrequency);
+ pw.println("mReportedBandwidth: " + mReportedBandwidth);
+ }
+
+ private String getCurrentStateName() {
+ IState currentState = mStateMachine.getCurrentState();
+
+ if (currentState != null) {
+ return currentState.getName();
+ }
+
+ return "StateMachine not active";
+ }
+
+ /**
* Update AP state.
* @param newState new AP state
* @param currentState current AP state
@@ -324,9 +365,6 @@ public class SoftApManager implements ActiveModeManager {
}
private class StartedState extends State {
- private int mNumAssociatedStations;
-
- private boolean mTimeoutEnabled;
private int mTimeoutDelay;
private WakeupMessage mSoftApTimeoutMessage;
private SoftApTimeoutEnabledSettingObserver mSettingObserver;
@@ -487,10 +525,12 @@ public class SoftApManager implements ActiveModeManager {
setNumAssociatedStations(message.arg1);
break;
case CMD_SOFT_AP_CHANNEL_SWITCHED:
- Log.d(TAG, "Channel switched. Frequency: " + message.arg1 + " Bandwidth: "
- + message.arg2);
- mWifiMetrics.addSoftApChannelSwitchedEvent(message.arg1, message.arg2,
- mMode);
+ mReportedFrequency = message.arg1;
+ mReportedBandwidth = message.arg2;
+ Log.d(TAG, "Channel switched. Frequency: " + mReportedFrequency
+ + " Bandwidth: " + mReportedBandwidth);
+ mWifiMetrics.addSoftApChannelSwitchedEvent(mReportedFrequency,
+ mReportedBandwidth, mMode);
break;
case CMD_TIMEOUT_TOGGLE_CHANGED:
boolean isEnabled = (message.arg1 == 1);
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index eb1746e87..7a381c68f 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -148,6 +148,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
private static final int RUN_WITH_SCISSORS_TIMEOUT_MILLIS = 4000;
final WifiStateMachine mWifiStateMachine;
+ final WifiStateMachinePrime mWifiStateMachinePrime;
final ScanRequestProxy mScanRequestProxy;
private final Context mContext;
@@ -453,6 +454,7 @@ public class WifiServiceImpl extends IWifiManager.Stub {
mUserManager = mWifiInjector.getUserManager();
mCountryCode = mWifiInjector.getWifiCountryCode();
mWifiStateMachine = mWifiInjector.getWifiStateMachine();
+ mWifiStateMachinePrime = mWifiInjector.getWifiStateMachinePrime();
mWifiStateMachine.enableRssiPolling(true);
mScanRequestProxy = mWifiInjector.getScanRequestProxy();
mSettingsStore = mWifiInjector.getWifiSettingsStore();
@@ -2514,6 +2516,8 @@ public class WifiServiceImpl extends IWifiManager.Stub {
pw.println();
mWifiMulticastLockManager.dump(pw);
pw.println();
+ mWifiStateMachinePrime.dump(fd, pw, args);
+ pw.println();
mWifiStateMachine.dump(fd, pw, args);
pw.println();
mWifiStateMachine.updateWifiMetrics();
diff --git a/service/java/com/android/server/wifi/WifiStateMachinePrime.java b/service/java/com/android/server/wifi/WifiStateMachinePrime.java
index fdacd1460..3becd9bad 100644
--- a/service/java/com/android/server/wifi/WifiStateMachinePrime.java
+++ b/service/java/com/android/server/wifi/WifiStateMachinePrime.java
@@ -34,6 +34,9 @@ import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.server.wifi.WifiNative.StatusListener;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* This class provides the implementation for different WiFi operating modes.
*
@@ -216,6 +219,21 @@ public class WifiStateMachinePrime {
});
}
+ /**
+ * Dump current state for active mode managers.
+ *
+ * Must be called from WifiStateMachine thread.
+ */
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("Dump of " + TAG);
+
+ pw.println("Current wifi mode: " + getCurrentMode());
+ pw.println("NumActiveModeManagers: " + mActiveModeManagers.size());
+ for (ActiveModeManager manager : mActiveModeManagers) {
+ manager.dump(fd, pw, args);
+ }
+ }
+
protected String getCurrentMode() {
return mModeStateMachine.getCurrentMode();
}