Only wait for 8 seconds when T && !activelyPreferBadWifi

Also addressing a cleanup comment from aosp/2210758

Test: FrameworksNetTests
Change-Id: I7414c27840ec84e5ad0aef6d76a7aa7bc39c51fc
This commit is contained in:
Chalard Jean
2022-09-16 19:31:45 +09:00
parent 020b93ac63
commit e63c42f543

View File

@@ -357,7 +357,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
// of connectivity (valid, partial, captive portal). If none has been detected after this // 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 // delay, the stack considers this network bad, which may affect how it's handled in ranking
// according to config_networkAvoidBadWifi. // 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. // 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"; private static final String LINGER_DELAY_PROPERTY = "persist.netmon.linger";
@@ -3800,6 +3803,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
// the first time this ever happened. // the first time this ever happened.
final boolean someConnectivity = (valid || partial || captive); final boolean someConnectivity = (valid || partial || captive);
final boolean becameEvaluated = someConnectivity && nai.setEvaluated(); 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 (becameEvaluated) nai.updateScoreForNetworkAgentUpdate();
if (!valid && shouldIgnoreValidationFailureAfterRoam(nai)) { if (!valid && shouldIgnoreValidationFailureAfterRoam(nai)) {
@@ -9234,7 +9242,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
networkAgent.networkMonitor().notifyNetworkConnected(params.linkProperties, networkAgent.networkMonitor().notifyNetworkConnected(params.linkProperties,
params.networkCapabilities); 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 // Whether a particular NetworkRequest listen should cause signal strength thresholds to
// be communicated to a particular NetworkAgent depends only on the network's immutable, // be communicated to a particular NetworkAgent depends only on the network's immutable,