Only wait for 8 seconds when T && !activelyPreferBadWifi
Also addressing a cleanup comment from aosp/2210758
Test: FrameworksNetTests
Change-Id: I7414c27840ec84e5ad0aef6d76a7aa7bc39c51fc
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index cb209e8..3c9886c 100755
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -357,7 +357,10 @@
// of connectivity (valid, partial, captive portal). If none has been detected after this
// delay, the stack considers this network bad, which may affect how it's handled in ranking
// according to config_networkAvoidBadWifi.
- private static final int INITIAL_EVALUATION_TIMEOUT_MS = 20 * 1000;
+ // Timeout in case the "actively prefer bad wifi" feature is on
+ private static final int ACTIVELY_PREFER_BAD_WIFI_INITIAL_TIMEOUT_MS = 20 * 1000;
+ // Timeout in case the "actively prefer bad wifi" feature is off
+ private static final int DONT_ACTIVELY_PREFER_BAD_WIFI_INITIAL_TIMEOUT_MS = 8 * 1000;
// Default to 30s linger time-out, and 5s for nascent network. Modifiable only for testing.
private static final String LINGER_DELAY_PROPERTY = "persist.netmon.linger";
@@ -3800,6 +3803,11 @@
// the first time this ever happened.
final boolean someConnectivity = (valid || partial || captive);
final boolean becameEvaluated = someConnectivity && nai.setEvaluated();
+ // Because of b/245893397, if the score is updated when updateCapabilities is called,
+ // any callback that receives onAvailable for that rematch receives an extra caps
+ // callback. To prevent that, update the score in the agent so the updates below won't
+ // see an update to both caps and score at the same time.
+ // TODO : fix b/245893397 and remove this.
if (becameEvaluated) nai.updateScoreForNetworkAgentUpdate();
if (!valid && shouldIgnoreValidationFailureAfterRoam(nai)) {
@@ -9234,7 +9242,10 @@
networkAgent.networkMonitor().notifyNetworkConnected(params.linkProperties,
params.networkCapabilities);
}
- scheduleEvaluationTimeout(networkAgent.network, INITIAL_EVALUATION_TIMEOUT_MS);
+ final long delay = activelyPreferBadWifi()
+ ? ACTIVELY_PREFER_BAD_WIFI_INITIAL_TIMEOUT_MS
+ : DONT_ACTIVELY_PREFER_BAD_WIFI_INITIAL_TIMEOUT_MS;
+ scheduleEvaluationTimeout(networkAgent.network, delay);
// Whether a particular NetworkRequest listen should cause signal strength thresholds to
// be communicated to a particular NetworkAgent depends only on the network's immutable,