Disable ignoring validation on roam just after boot.
shouldIgnoreValidationFailureAfterRoam will incorrectly return true in the first few seconds after boot even if the network never roamed. This is extremely unlikely to happen, but add a check for that just in case. Fix: 230450214 Test: new unit test Change-Id: I0789d9bdaa0bd9e78673e8f4248a2ca610052f1e
This commit is contained in:
@@ -16861,6 +16861,35 @@ public class ConnectivityServiceTest {
|
||||
doTestIgnoreValidationAfterRoam(5_000, enabled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldIgnoreValidationFailureAfterRoam() {
|
||||
// Always disabled on T+.
|
||||
assumeFalse(SdkLevel.isAtLeastT());
|
||||
|
||||
NetworkAgentInfo nai = fakeWifiNai(new NetworkCapabilities());
|
||||
|
||||
// Enabled, but never roamed.
|
||||
doReturn(5_000).when(mResources)
|
||||
.getInteger(R.integer.config_validationFailureAfterRoamIgnoreTimeMillis);
|
||||
assertEquals(0, nai.lastRoamTime);
|
||||
assertFalse(mService.shouldIgnoreValidationFailureAfterRoam(nai));
|
||||
|
||||
// Roamed recently.
|
||||
nai.lastRoamTime = SystemClock.elapsedRealtime() - 500 /* ms */;
|
||||
assertTrue(mService.shouldIgnoreValidationFailureAfterRoam(nai));
|
||||
|
||||
// Disabled due to invalid setting (maximum is 10 seconds).
|
||||
doReturn(15_000).when(mResources)
|
||||
.getInteger(R.integer.config_validationFailureAfterRoamIgnoreTimeMillis);
|
||||
assertFalse(mService.shouldIgnoreValidationFailureAfterRoam(nai));
|
||||
|
||||
// Disabled.
|
||||
doReturn(-1).when(mResources)
|
||||
.getInteger(R.integer.config_validationFailureAfterRoamIgnoreTimeMillis);
|
||||
assertFalse(mService.shouldIgnoreValidationFailureAfterRoam(nai));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLegacyTetheringApiGuardWithProperPermission() throws Exception {
|
||||
final String testIface = "test0";
|
||||
|
||||
Reference in New Issue
Block a user