summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorKai Shi <kaishi@google.com>2020-04-17 20:07:37 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-04-17 20:07:37 +0000
commit11e48601e54881059f44535efe2fd4b3c017eff2 (patch)
tree6a0524ea1ead7830b01e483282036084224dabf0 /service
parent63da7f604a87743c33f9d0bcf18a87eb5c8e05ec (diff)
parent44e157bad31ad5ba0173a2a09bba9e337c0b1e7f (diff)
Merge "take bug report for abnormal overlapping connection" into rvc-dev
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 9b2c0dc04..603573224 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -2889,7 +2889,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;
}
}