Merge "Set safe mode alarm when validation reports NOT_VALID" am: 19be41cb30 am: 5bf42637a8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1689285 Change-Id: I9d806e017e873b72f5b37ab9f5371651ca360696
This commit is contained in:
@@ -1558,8 +1558,22 @@ public class VcnGatewayConnection extends StateMachine {
|
||||
teardownAsynchronously();
|
||||
} /* networkUnwantedCallback */,
|
||||
(status) -> {
|
||||
if (status == NetworkAgent.VALIDATION_STATUS_VALID) {
|
||||
clearFailedAttemptCounterAndSafeModeAlarm();
|
||||
switch (status) {
|
||||
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 */);
|
||||
|
||||
|
||||
@@ -343,6 +343,31 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
|
||||
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() {
|
||||
triggerChildOpened();
|
||||
mTestLooper.dispatchAll();
|
||||
|
||||
Reference in New Issue
Block a user