Do not initiate MBB when internet is validated on lingering secondary
Fix a bug where MBB happens twice. After the initial MBB wifi-to-wifi
switch is complete, MBB should not trigger again if internet gets
validated on the lingering secondary STA.
Bug: 226675850
Test: atest com.android.server.wifi
Change-Id: Ife734efea94ae88561424825494639c848253760
diff --git a/service/java/com/android/server/wifi/MakeBeforeBreakManager.java b/service/java/com/android/server/wifi/MakeBeforeBreakManager.java
index ec20612..6474e08 100644
--- a/service/java/com/android/server/wifi/MakeBeforeBreakManager.java
+++ b/service/java/com/android/server/wifi/MakeBeforeBreakManager.java
@@ -214,6 +214,11 @@
ROLE_CLIENT_PRIMARY, mFrameworkFacade.getSettingsWorkSource(mContext));
return;
}
+ if (newPrimary.getPreviousRole() == ROLE_CLIENT_PRIMARY) {
+ Log.i(TAG, "Don't start MBB when internet is validated on the lingering "
+ + "secondary.");
+ return;
+ }
Log.i(TAG, "Starting MBB switch primary from " + currentPrimary + " to " + newPrimary
+ " by setting current primary's role to ROLE_CLIENT_SECONDARY_TRANSIENT");
diff --git a/service/tests/wifitests/src/com/android/server/wifi/MakeBeforeBreakManagerTest.java b/service/tests/wifitests/src/com/android/server/wifi/MakeBeforeBreakManagerTest.java
index b384174..9a3f60c 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/MakeBeforeBreakManagerTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/MakeBeforeBreakManagerTest.java
@@ -92,6 +92,14 @@
}
@Test
+ public void onL3ValidatedSecondaryTransientThatWasPreviouslyPrimary_noOp() {
+ when(mNewPrimaryCmm.getPreviousRole()).thenReturn(ROLE_CLIENT_PRIMARY);
+ mCmiListenerCaptor.getValue().onInternetValidated(mNewPrimaryCmm);
+
+ verify(mNewPrimaryCmm, never()).setRole(any(), any());
+ }
+
+ @Test
public void onL3ValidatedNonSecondaryTransient_noOp() {
when(mNewPrimaryCmm.getRole()).thenReturn(ROLE_CLIENT_SECONDARY_LONG_LIVED);
mCmiListenerCaptor.getValue().onInternetValidated(mNewPrimaryCmm);