summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-04-16 17:49:16 -0700
committerKai Shi <kaishi@google.com>2020-04-16 18:31:55 -0700
commit44e157bad31ad5ba0173a2a09bba9e337c0b1e7f (patch)
tree26f9b4c2ac3e3615f46131853877d8c8a54a7fc3 /service
parent2cdbd0860a83e252ea3b0da27cf4d5d0e86d50d7 (diff)
take bug report for abnormal overlapping connection
Add an optin to take bug report in user debug build when it detects abnormal overlapping connection. This option is off by default. Test: atest com.android.server.wifi Bug: 154274650 Change-Id: Ia7ae1e242c7b28d3e3eb2fccbccbd968e67d5e6e
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java11
-rw-r--r--service/java/com/android/server/wifi/DeviceConfigFacade.java23
-rw-r--r--service/java/com/android/server/wifi/WifiMetrics.java13
3 files changed, 43 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 99fa7f585..68c8aee23 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -2904,7 +2904,16 @@ public class ClientModeImpl extends StateMachine {
*/
private void reportConnectionAttemptStart(
WifiConfiguration config, String targetBSSID, int roamType) {
- mWifiMetrics.startConnectionEvent(config, targetBSSID, roamType);
+ int overlapWithLastConnectionMs =
+ mWifiMetrics.startConnectionEvent(config, targetBSSID, roamType);
+ DeviceConfigFacade deviceConfigFacade = mWifiInjector.getDeviceConfigFacade();
+ if (deviceConfigFacade.isOverlappingConnectionBugreportEnabled()
+ && overlapWithLastConnectionMs
+ > deviceConfigFacade.getOverlappingConnectionDurationThresholdMs()) {
+ String bugTitle = "Wi-Fi BugReport";
+ String bugDetail = "Detect abnormal overlapping connection";
+ takeBugReport(bugTitle, bugDetail);
+ }
mWifiDiagnostics.reportConnectionEvent(WifiDiagnostics.CONNECTION_EVENT_STARTED);
mWrongPasswordNotifier.onNewConnectionAttempt();
removeMessages(CMD_DIAGS_CONNECT_TIMEOUT);
diff --git a/service/java/com/android/server/wifi/DeviceConfigFacade.java b/service/java/com/android/server/wifi/DeviceConfigFacade.java
index 67cc01ce9..d25a50a10 100644
--- a/service/java/com/android/server/wifi/DeviceConfigFacade.java
+++ b/service/java/com/android/server/wifi/DeviceConfigFacade.java
@@ -95,6 +95,8 @@ public class DeviceConfigFacade {
// Default report-high threshold to take-bug-report threshold ratio.
// It should be larger than 1 since the bar to take bugreport should be higher.
static final int DEFAULT_BUG_REPORT_THRESHOLD_EXTRA_RATIO = 2;
+ // Default overlapping connection duration threshold in ms to trigger bug report
+ static final int DEFAULT_OVERLAPPING_CONNECTION_DURATION_THRESHOLD_MS = 75_000;
// Cached values of fields updated via updateDeviceConfigFlags()
private boolean mIsAbnormalConnectionBugreportEnabled;
@@ -132,6 +134,8 @@ public class DeviceConfigFacade {
private int mHealthMonitorMinNumConnectionAttempt;
private int mBugReportMinWindowMs;
private int mBugReportThresholdExtraRatio;
+ private boolean mIsOverlappingConnectionBugreportEnabled;
+ private int mOverlappingConnectionDurationThresholdMs;
public DeviceConfigFacade(Context context, Handler handler, WifiMetrics wifiMetrics) {
mContext = context;
@@ -245,6 +249,11 @@ public class DeviceConfigFacade {
mBugReportThresholdExtraRatio = DeviceConfig.getInt(NAMESPACE,
"report_bug_report_threshold_extra_ratio",
DEFAULT_BUG_REPORT_THRESHOLD_EXTRA_RATIO);
+ mIsOverlappingConnectionBugreportEnabled = DeviceConfig.getBoolean(NAMESPACE,
+ "overlapping_connection_bugreport_enabled", false);
+ mOverlappingConnectionDurationThresholdMs = DeviceConfig.getInt(NAMESPACE,
+ "overlapping_connection_duration_threshold_ms",
+ DEFAULT_OVERLAPPING_CONNECTION_DURATION_THRESHOLD_MS);
}
private Set<String> getUnmodifiableSetQuoted(String key) {
@@ -508,4 +517,18 @@ public class DeviceConfigFacade {
public int getBugReportThresholdExtraRatio() {
return mBugReportThresholdExtraRatio;
}
+
+ /**
+ * Gets the feature flag for reporting overlapping connection.
+ */
+ public boolean isOverlappingConnectionBugreportEnabled() {
+ return mIsOverlappingConnectionBugreportEnabled;
+ }
+
+ /**
+ * Gets overlapping connection duration threshold in ms
+ */
+ public int getOverlappingConnectionDurationThresholdMs() {
+ return mOverlappingConnectionDurationThresholdMs;
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index 031c495cc..03c824968 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -1390,18 +1390,24 @@ public class WifiMetrics {
private static final int SCREEN_OFF = 0;
/**
- * Create a new connection event. Call when wifi attempts to make a new network connection
+ * Create a new connection event and check if the new one overlaps with previous one.
+ * Call when wifi attempts to make a new network connection
* If there is a current 'un-ended' connection event, it will be ended with UNKNOWN connectivity
* failure code.
* Gathers and sets the RouterFingerPrint data as well
*
* @param config WifiConfiguration of the config used for the current connection attempt
* @param roamType Roam type that caused connection attempt, see WifiMetricsProto.WifiLog.ROAM_X
+ * @return The duration in ms since the last unfinished connection attempt,
+ * or 0 if there is no unfinished connection
*/
- public void startConnectionEvent(WifiConfiguration config, String targetBSSID, int roamType) {
+ public int startConnectionEvent(
+ WifiConfiguration config, String targetBSSID, int roamType) {
synchronized (mLock) {
- // Check if this is overlapping another current connection event
+ int overlapWithLastConnectionMs = 0;
if (mCurrentConnectionEvent != null) {
+ overlapWithLastConnectionMs = (int) (mClock.getElapsedSinceBootMillis()
+ - mCurrentConnectionEvent.mRealStartTime);
//Is this new Connection Event the same as the current one
if (mCurrentConnectionEvent.mConfigSsid != null
&& mCurrentConnectionEvent.mConfigBssid != null
@@ -1505,6 +1511,7 @@ public class WifiMetrics {
recentStats.getCount(WifiScoreCard.CNT_CONSECUTIVE_CONNECTION_FAILURE);
}
}
+ return overlapWithLastConnectionMs;
}
}