summaryrefslogtreecommitdiffstats
path: root/service/java/com/android
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2019-05-21 17:34:56 -0700
committerxshu <xshu@google.com>2019-05-23 13:54:57 -0700
commitc6cb88c37c22daeeac819726cc91b6c452791a46 (patch)
tree10a3d34af6455d1e9f2af9b6e103273509406a98 /service/java/com/android
parentab6b4546f9ba6eff785dd539890a0d4bdfcab4b1 (diff)
downloadandroid_frameworks_opt_net_wifi-c6cb88c37c22daeeac819726cc91b6c452791a46.tar.gz
android_frameworks_opt_net_wifi-c6cb88c37c22daeeac819726cc91b6c452791a46.tar.bz2
android_frameworks_opt_net_wifi-c6cb88c37c22daeeac819726cc91b6c452791a46.zip
Trigger bugreport for abnormally long connections
Bug: 132648941 Test: Unit tests Test: mannually tested with a smaller threshold to verify bugreport is triggering properly. Change-Id: I2f5f9c9c08874f6f356a081b0a2575dd3851c241
Diffstat (limited to 'service/java/com/android')
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java3
-rw-r--r--service/java/com/android/server/wifi/WifiLastResortWatchdog.java48
2 files changed, 51 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 4adf27ff0..008135051 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -955,6 +955,8 @@ public class ClientModeImpl extends StateMachine {
mWifiMetrics.getHandler());
mWifiMonitor.registerHandler(mInterfaceName, CMD_TARGET_BSSID,
mWifiMetrics.getHandler());
+ mWifiMonitor.registerHandler(mInterfaceName, WifiMonitor.NETWORK_CONNECTION_EVENT,
+ mWifiInjector.getWifiLastResortWatchdog().getHandler());
}
private void setMulticastFilter(boolean enabled) {
@@ -4274,6 +4276,7 @@ public class ClientModeImpl extends StateMachine {
mWifiInfo.setMacAddress(currentMacAddress);
Log.i(TAG, "Connecting with " + currentMacAddress + " as the mac address");
if (mWifiNative.connectToNetwork(mInterfaceName, config)) {
+ mWifiInjector.getWifiLastResortWatchdog().noteStartConnectTime();
mWifiMetrics.logStaEvent(StaEvent.TYPE_CMD_START_CONNECT, config);
mLastConnectAttemptTimestamp = mClock.getWallClockMillis();
mTargetWifiConfiguration = config;
diff --git a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
index 6889b5016..286e4ba47 100644
--- a/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
+++ b/service/java/com/android/server/wifi/WifiLastResortWatchdog.java
@@ -20,6 +20,7 @@ import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.os.Handler;
import android.os.Looper;
+import android.os.Message;
import android.text.TextUtils;
import android.util.LocalLog;
import android.util.Log;
@@ -74,6 +75,8 @@ public class WifiLastResortWatchdog {
// Number of milliseconds to wait before re-enable Watchdog triger
@VisibleForTesting
public static final long LAST_TRIGGER_TIMEOUT_MILLIS = 2 * 3600 * 1000; // 2 hours
+ @VisibleForTesting
+ public static final int ABNORMAL_SUCCESSFUL_CONNECTION_DURATION_MS = 1000 * 30; // 30 seconds
/**
* Cached WifiConfigurations of available networks seen within MAX_BSSID_AGE scan results
@@ -105,6 +108,8 @@ public class WifiLastResortWatchdog {
// If any connection failure happened after watchdog triggering restart then assume watchdog
// did not fix the problem
private boolean mWatchdogFixedWifi = true;
+ private long mLastStartConnectTime = 0;
+ private Handler mHandler;
/**
* Local log used for debugging any WifiLastResortWatchdog issues.
@@ -118,6 +123,49 @@ public class WifiLastResortWatchdog {
mWifiMetrics = wifiMetrics;
mClientModeImpl = clientModeImpl;
mClientModeImplLooper = clientModeImplLooper;
+ mHandler = new Handler(clientModeImplLooper) {
+ public void handleMessage(Message msg) {
+ processMessage(msg);
+ }
+ };
+ }
+
+ /**
+ * Returns handler for L2 events from supplicant.
+ * @return Handler
+ */
+ public Handler getHandler() {
+ return mHandler;
+ }
+
+ /**
+ * Refreshes when the last CMD_START_CONNECT is triggered.
+ */
+ public void noteStartConnectTime() {
+ mLastStartConnectTime = mClock.getElapsedSinceBootMillis();
+ }
+
+ private void processMessage(Message msg) {
+ switch (msg.what) {
+ case WifiMonitor.NETWORK_CONNECTION_EVENT:
+ // Trigger bugreport for successful connections that take abnormally long
+ if (mLastStartConnectTime > 0) {
+ long durationMs = mClock.getElapsedSinceBootMillis() - mLastStartConnectTime;
+ if (durationMs > ABNORMAL_SUCCESSFUL_CONNECTION_DURATION_MS) {
+ final String bugTitle = "Wi-Fi Bugreport: Abnormal connection time";
+ final String bugDetail = "Expected connection to take less than "
+ + ABNORMAL_SUCCESSFUL_CONNECTION_DURATION_MS + " milliseconds. "
+ + "Actually took " + durationMs + " milliseconds.";
+ mWifiInjector.getClientModeImplHandler().post(() -> {
+ mClientModeImpl.takeBugReport(bugTitle, bugDetail);
+ });
+ }
+ mLastStartConnectTime = 0;
+ }
+ break;
+ default:
+ return;
+ }
}
/**