Merge "Set safe mode alarm when validation reports NOT_VALID"
This commit is contained in:
@@ -1558,8 +1558,22 @@ public class VcnGatewayConnection extends StateMachine {
|
|||||||
teardownAsynchronously();
|
teardownAsynchronously();
|
||||||
} /* networkUnwantedCallback */,
|
} /* networkUnwantedCallback */,
|
||||||
(status) -> {
|
(status) -> {
|
||||||
if (status == NetworkAgent.VALIDATION_STATUS_VALID) {
|
switch (status) {
|
||||||
clearFailedAttemptCounterAndSafeModeAlarm();
|
case NetworkAgent.VALIDATION_STATUS_VALID:
|
||||||
|
clearFailedAttemptCounterAndSafeModeAlarm();
|
||||||
|
break;
|
||||||
|
case NetworkAgent.VALIDATION_STATUS_NOT_VALID:
|
||||||
|
// Will only set a new alarm if no safe mode alarm is
|
||||||
|
// currently scheduled.
|
||||||
|
setSafeModeAlarm();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Slog.wtf(
|
||||||
|
TAG,
|
||||||
|
"Unknown validation status "
|
||||||
|
+ status
|
||||||
|
+ "; ignoring");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} /* validationStatusCallback */);
|
} /* validationStatusCallback */);
|
||||||
|
|
||||||
|
|||||||
@@ -343,6 +343,31 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
|||||||
assertFalse(mGatewayConnection.isInSafeMode());
|
assertFalse(mGatewayConnection.isInSafeMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubsequentFailedValidationTriggersSafeMode() throws Exception {
|
||||||
|
triggerChildOpened();
|
||||||
|
mTestLooper.dispatchAll();
|
||||||
|
|
||||||
|
triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID);
|
||||||
|
assertFalse(mGatewayConnection.isInSafeMode());
|
||||||
|
|
||||||
|
// Trigger a failed validation, and the subsequent safemode timeout.
|
||||||
|
triggerValidation(NetworkAgent.VALIDATION_STATUS_NOT_VALID);
|
||||||
|
mTestLooper.dispatchAll();
|
||||||
|
|
||||||
|
final ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class);
|
||||||
|
verify(mDeps, times(2))
|
||||||
|
.newWakeupMessage(
|
||||||
|
eq(mVcnContext),
|
||||||
|
any(),
|
||||||
|
eq(VcnGatewayConnection.SAFEMODE_TIMEOUT_ALARM),
|
||||||
|
runnableCaptor.capture());
|
||||||
|
runnableCaptor.getValue().run();
|
||||||
|
mTestLooper.dispatchAll();
|
||||||
|
|
||||||
|
assertTrue(mGatewayConnection.isInSafeMode());
|
||||||
|
}
|
||||||
|
|
||||||
private Consumer<VcnNetworkAgent> setupNetworkAndGetUnwantedCallback() {
|
private Consumer<VcnNetworkAgent> setupNetworkAndGetUnwantedCallback() {
|
||||||
triggerChildOpened();
|
triggerChildOpened();
|
||||||
mTestLooper.dispatchAll();
|
mTestLooper.dispatchAll();
|
||||||
|
|||||||
Reference in New Issue
Block a user