Add a field and score flag for first evaluation

A wifi network that is still evaluating, i.e. that doesn't know
yet if it's behind a captive portal, should not be preferred
to a network that yields to bad wifi because the stack doesn't
know yet if it's bad.

To rank the networks correctly, the ranker will therefore need
to know whether a network is still being evaluated. This patch
adds the time when this happened first to the NAI (as a
timestamp for debuggability) and the corresponding flag in
FullScore.

This doesn't have new tests because it doesn't yet expose
new behavior. Tests will come with the behavior.

Test: FrameworksNetTests
Change-Id: I737f314760356926fc07e6eef52f3c8abba2248b
This commit is contained in:
Chalard Jean
2022-08-30 21:25:36 +09:00
parent 4c46308265
commit f9f4a8ddfe
3 changed files with 57 additions and 11 deletions

View File

@@ -29,6 +29,7 @@ import androidx.test.filters.SmallTest
import com.android.server.connectivity.FullScore.MAX_CS_MANAGED_POLICY
import com.android.server.connectivity.FullScore.MIN_CS_MANAGED_POLICY
import com.android.server.connectivity.FullScore.POLICY_ACCEPT_UNVALIDATED
import com.android.server.connectivity.FullScore.POLICY_EVER_EVALUATED
import com.android.server.connectivity.FullScore.POLICY_EVER_USER_SELECTED
import com.android.server.connectivity.FullScore.POLICY_IS_DESTROYED
import com.android.server.connectivity.FullScore.POLICY_IS_UNMETERED
@@ -56,6 +57,7 @@ class FullScoreTest {
vpn: Boolean = false,
onceChosen: Boolean = false,
acceptUnvalidated: Boolean = false,
everEvaluated: Boolean = true,
destroyed: Boolean = false
): FullScore {
val nac = NetworkAgentConfig.Builder().apply {
@@ -67,7 +69,7 @@ class FullScoreTest {
if (validated) addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
}.build()
return mixInScore(nc, nac, validated, false /* avoidUnvalidated */,
false /* yieldToBadWifi */, destroyed)
false /* yieldToBadWifi */, everEvaluated, destroyed)
}
private val TAG = this::class.simpleName
@@ -123,6 +125,7 @@ class FullScoreTest {
assertTrue(ns.withPolicies(onceChosen = true).hasPolicy(POLICY_EVER_USER_SELECTED))
assertTrue(ns.withPolicies(acceptUnvalidated = true).hasPolicy(POLICY_ACCEPT_UNVALIDATED))
assertTrue(ns.withPolicies(destroyed = true).hasPolicy(POLICY_IS_DESTROYED))
assertTrue(ns.withPolicies(everEvaluated = true).hasPolicy(POLICY_EVER_EVALUATED))
}
@Test