From f1e09ef031a6fdb42fee06abdfd955e79f2e49e3 Mon Sep 17 00:00:00 2001 From: Chiachang Wang Date: Wed, 30 Jun 2021 16:22:06 +0800 Subject: [PATCH] Trigger the network score update after setting test allow bad wifi Avoid bad wifi design has to apply in both wifi and cellular networks. Cellular network should contain POLICY_YIELD_TO_BAD_WIFI policy, then system default network could stay in the wifi after wifi becomes unvalidated. The testing API only update the value but not trigger the avoid bad wifi callback to update the score in the existing cellular network. Thus, if the cellular network is connected before setting the overridden value, the yield to bad wifi policy will not updated to cellular network. The system default network will still switch from unvalidated wifi network to cellular network even wifi network is connected with the avoid bad wifi policy. Update to trigger a reevaluation to update the score in each NetworkAgent in the ConnectivityService. Bug: 192149168 Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest\ #testSetAvoidUnvalidated --rerun-until-failure 100 Change-Id: Ie0f777d0030b66dd306332496192c74f6c183284 --- framework/src/android/net/util/MultinetworkPolicyTracker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/android/net/util/MultinetworkPolicyTracker.java b/framework/src/android/net/util/MultinetworkPolicyTracker.java index 7e62d288f8..9791cbfd0c 100644 --- a/framework/src/android/net/util/MultinetworkPolicyTracker.java +++ b/framework/src/android/net/util/MultinetworkPolicyTracker.java @@ -182,7 +182,7 @@ public class MultinetworkPolicyTracker { public void setTestAllowBadWifiUntil(long timeMs) { Log.d(TAG, "setTestAllowBadWifiUntil: " + mTestAllowBadWifiUntilMs); mTestAllowBadWifiUntilMs = timeMs; - updateAvoidBadWifi(); + reevaluateInternal(); } @VisibleForTesting