Add an IS_DESTROYED flag to FullScore.
This is being added as the lowest priority score factor, just above the tie-breakers. It ensures that a network that has been destroyed will lose to another identical network that has not been destroyed, but will otherwise be scored identically. The flag is a CS-managed flag that is stored in NetworkAgentInfo. Currently it is always false, but it will be populated in future CLs. Bug: 216567577 Test: atest FrameworksNetTests Change-Id: Ib1cd342ab7dfc4df45715da19b743d711fe8d605
This commit is contained in:
@@ -26,6 +26,7 @@ import androidx.test.filters.SmallTest
|
||||
import com.android.server.connectivity.FullScore.MAX_CS_MANAGED_POLICY
|
||||
import com.android.server.connectivity.FullScore.POLICY_ACCEPT_UNVALIDATED
|
||||
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
|
||||
import com.android.server.connectivity.FullScore.POLICY_IS_VALIDATED
|
||||
import com.android.server.connectivity.FullScore.POLICY_IS_VPN
|
||||
@@ -48,7 +49,8 @@ class FullScoreTest {
|
||||
validated: Boolean = false,
|
||||
vpn: Boolean = false,
|
||||
onceChosen: Boolean = false,
|
||||
acceptUnvalidated: Boolean = false
|
||||
acceptUnvalidated: Boolean = false,
|
||||
destroyed: Boolean = false
|
||||
): FullScore {
|
||||
val nac = NetworkAgentConfig.Builder().apply {
|
||||
setUnvalidatedConnectivityAcceptable(acceptUnvalidated)
|
||||
@@ -58,7 +60,7 @@ class FullScoreTest {
|
||||
if (vpn) addTransportType(NetworkCapabilities.TRANSPORT_VPN)
|
||||
if (validated) addCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
||||
}.build()
|
||||
return mixInScore(nc, nac, validated, false /* yieldToBadWifi */)
|
||||
return mixInScore(nc, nac, validated, false /* yieldToBadWifi */, destroyed)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,6 +122,7 @@ class FullScoreTest {
|
||||
assertTrue(ns.withPolicies(vpn = true).hasPolicy(POLICY_IS_VPN))
|
||||
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))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user