From 7cf18381fa2099230c49269a435090115b7e633b Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 29 May 2020 13:41:18 -0700 Subject: WifiDiagnostics: Add a timeout for logcat calls The logcat shell command currently blocks forever if something is wrong. Add a timeout to error out after 500 ms. Bug: 157062041 Test: Verified that WifiDiagnostics dump is not broken. Change-Id: Id67082c5fedf259790950acbffa41cfb042c415a --- service/java/com/android/server/wifi/WifiDiagnostics.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/WifiDiagnostics.java b/service/java/com/android/server/wifi/WifiDiagnostics.java index 4ac982063..2ba90c968 100644 --- a/service/java/com/android/server/wifi/WifiDiagnostics.java +++ b/service/java/com/android/server/wifi/WifiDiagnostics.java @@ -44,6 +44,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.zip.Deflater; @@ -107,6 +108,9 @@ class WifiDiagnostics extends BaseWifiDiagnostics { /** Minimum dump period with same error code */ public static final long MIN_DUMP_TIME_WINDOW_MILLIS = 10 * 60 * 1000; // 10 mins + // Timeout for logcat + private static final int LOGCAT_TIMEOUT_MILLIS = 500; + private long mLastBugReportTime; @VisibleForTesting public static final String FIRMWARE_DUMP_SECTION_HEADER = @@ -720,7 +724,7 @@ class WifiDiagnostics extends BaseWifiDiagnostics { while ((line = reader.readLine()) != null) { lines.add(line); } - process.waitFor(); + process.waitFor(LOGCAT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); } catch (InterruptedException|IOException e) { mLog.dump("Exception while capturing logcat: %").c(e.toString()).flush(); } -- cgit v1.2.3 From a442338fbb51bc797ab03eca48d3b0bc0c454e2e Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 29 May 2020 15:47:43 -0700 Subject: ClientModeImpl: Ignore connect when connecting to network Use internal variables to check whether we're connected or connecting to the network requested in WifiManager.connect(). If there is a credential change, we will forcefully retrigger a new connection request. Bug: 157696785 Test: atest com.android.server.wifi Change-Id: I514b5b3a1ed5205fde98bc6fd2b59285e10913ef Merged-In: I514b5b3a1ed5205fde98bc6fd2b59285e10913ef --- service/java/com/android/server/wifi/ClientModeImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'service') diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 0f84b3dd9..7769455e8 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -368,7 +368,7 @@ public class ClientModeImpl extends StateMachine { private String mTargetBssid = SUPPLICANT_BSSID_ANY; // This one is used to track the current target network ID. This is used for error // handling during connection setup since many error message from supplicant does not report - // SSID Once connected, it will be set to invalid + // SSID. Once connected, it will be set to invalid private int mTargetNetworkId = WifiConfiguration.INVALID_NETWORK_ID; private long mLastDriverRoamAttempt = 0; private WifiConfiguration mTargetWifiConfiguration = null; @@ -1211,8 +1211,8 @@ public class ClientModeImpl extends StateMachine { private void connectToUserSelectNetwork(int netId, int uid, boolean forceReconnect) { logd("connectToUserSelectNetwork netId " + netId + ", uid " + uid + ", forceReconnect = " + forceReconnect); - if (!forceReconnect && mWifiInfo.getNetworkId() == netId) { - // We're already connected to the user specified network, don't trigger a + if (!forceReconnect && (mLastNetworkId == netId || mTargetNetworkId == netId)) { + // We're already connecting/connected to the user specified network, don't trigger a // reconnection unless it was forced. logi("connectToUserSelectNetwork already connecting/connected=" + netId); } else { -- cgit v1.2.3