Loading services/core/java/com/android/server/vcn/Vcn.java +12 −2 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public class Vcn extends Handler { } private void handleSafeModeStatusChanged() { logDbg("VcnGatewayConnection safe mode status changed"); logVdbg("VcnGatewayConnection safe mode status changed"); boolean hasSafeModeGatewayConnection = false; // If any VcnGatewayConnection is in safe mode, mark the entire VCN as being in safe mode Loading @@ -368,7 +368,7 @@ public class Vcn extends Handler { hasSafeModeGatewayConnection ? VCN_STATUS_CODE_SAFE_MODE : VCN_STATUS_CODE_ACTIVE; if (oldStatus != mCurrentStatus) { mVcnCallback.onSafeModeStatusChanged(hasSafeModeGatewayConnection); logDbg( logInfo( "Safe mode " + (mCurrentStatus == VCN_STATUS_CODE_SAFE_MODE ? "entered" : "exited")); } Loading Loading @@ -539,6 +539,16 @@ public class Vcn extends Handler { Slog.d(TAG, getLogPrefix() + msg, tr); } private void logInfo(String msg) { Slog.i(TAG, getLogPrefix() + msg); LOCAL_LOG.log(getLogPrefix() + "INFO: " + msg); } private void logInfo(String msg, Throwable tr) { Slog.i(TAG, getLogPrefix() + msg, tr); LOCAL_LOG.log(getLogPrefix() + "INFO: " + msg + tr); } private void logErr(String msg) { Slog.e(TAG, getLogPrefix() + msg); LOCAL_LOG.log(getLogPrefix() + "ERR: " + msg); Loading services/core/java/com/android/server/vcn/VcnGatewayConnection.java +2 −4 Original line number Diff line number Diff line Loading @@ -1677,11 +1677,9 @@ public class VcnGatewayConnection extends StateMachine { mFailedAttempts = 0; cancelSafeModeAlarm(); if (mIsInSafeMode) { mIsInSafeMode = false; mGatewayStatusCallback.onSafeModeStatusChanged(); } } protected void applyTransform( int token, Loading tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -322,6 +322,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID); verify(mSafeModeTimeoutAlarm).cancel(); assertFalse(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(1 /* invocationCount */, false /* isInSafeMode */); } @Test Loading Loading @@ -391,6 +392,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID); verifySafeModeStateAndCallbackFired(2 /* invocationCount */, false /* isInSafeMode */); assertFalse(mGatewayConnection.isInSafeMode()); } Loading @@ -400,7 +402,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection mTestLooper.dispatchAll(); triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID); assertFalse(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(1 /* invocationCount */, false /* isInSafeMode */); // Trigger a failed validation, and the subsequent safemode timeout. triggerValidation(NetworkAgent.VALIDATION_STATUS_NOT_VALID); Loading @@ -416,7 +418,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection runnableCaptor.getValue().run(); mTestLooper.dispatchAll(); assertTrue(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(2 /* invocationCount */, true /* isInSafeMode */); } private Consumer<VcnNetworkAgent> setupNetworkAndGetUnwantedCallback() { Loading tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTestBase.java +6 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static com.android.server.vcn.VcnTestUtils.setupIpSecManager; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.CALLS_REAL_METHODS; Loading Loading @@ -301,6 +300,11 @@ public class VcnGatewayConnectionTestBase { expectCanceled); } protected void verifySafeModeStateAndCallbackFired(int invocationCount, boolean isInSafeMode) { verify(mGatewayStatusCallback, times(invocationCount)).onSafeModeStatusChanged(); assertEquals(isInSafeMode, mGatewayConnection.isInSafeMode()); } protected void verifySafeModeTimeoutNotifiesCallbackAndUnregistersNetworkAgent( @NonNull State expectedState) { // Set a VcnNetworkAgent, and expect it to be unregistered and cleared Loading @@ -314,9 +318,8 @@ public class VcnGatewayConnectionTestBase { delayedEvent.run(); mTestLooper.dispatchAll(); verify(mGatewayStatusCallback).onSafeModeStatusChanged(); assertEquals(expectedState, mGatewayConnection.getCurrentState()); assertTrue(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(1, true); verify(mockNetworkAgent).unregister(); assertNull(mGatewayConnection.getNetworkAgent()); Loading Loading
services/core/java/com/android/server/vcn/Vcn.java +12 −2 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ public class Vcn extends Handler { } private void handleSafeModeStatusChanged() { logDbg("VcnGatewayConnection safe mode status changed"); logVdbg("VcnGatewayConnection safe mode status changed"); boolean hasSafeModeGatewayConnection = false; // If any VcnGatewayConnection is in safe mode, mark the entire VCN as being in safe mode Loading @@ -368,7 +368,7 @@ public class Vcn extends Handler { hasSafeModeGatewayConnection ? VCN_STATUS_CODE_SAFE_MODE : VCN_STATUS_CODE_ACTIVE; if (oldStatus != mCurrentStatus) { mVcnCallback.onSafeModeStatusChanged(hasSafeModeGatewayConnection); logDbg( logInfo( "Safe mode " + (mCurrentStatus == VCN_STATUS_CODE_SAFE_MODE ? "entered" : "exited")); } Loading Loading @@ -539,6 +539,16 @@ public class Vcn extends Handler { Slog.d(TAG, getLogPrefix() + msg, tr); } private void logInfo(String msg) { Slog.i(TAG, getLogPrefix() + msg); LOCAL_LOG.log(getLogPrefix() + "INFO: " + msg); } private void logInfo(String msg, Throwable tr) { Slog.i(TAG, getLogPrefix() + msg, tr); LOCAL_LOG.log(getLogPrefix() + "INFO: " + msg + tr); } private void logErr(String msg) { Slog.e(TAG, getLogPrefix() + msg); LOCAL_LOG.log(getLogPrefix() + "ERR: " + msg); Loading
services/core/java/com/android/server/vcn/VcnGatewayConnection.java +2 −4 Original line number Diff line number Diff line Loading @@ -1677,11 +1677,9 @@ public class VcnGatewayConnection extends StateMachine { mFailedAttempts = 0; cancelSafeModeAlarm(); if (mIsInSafeMode) { mIsInSafeMode = false; mGatewayStatusCallback.onSafeModeStatusChanged(); } } protected void applyTransform( int token, Loading
tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -322,6 +322,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID); verify(mSafeModeTimeoutAlarm).cancel(); assertFalse(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(1 /* invocationCount */, false /* isInSafeMode */); } @Test Loading Loading @@ -391,6 +392,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID); verifySafeModeStateAndCallbackFired(2 /* invocationCount */, false /* isInSafeMode */); assertFalse(mGatewayConnection.isInSafeMode()); } Loading @@ -400,7 +402,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection mTestLooper.dispatchAll(); triggerValidation(NetworkAgent.VALIDATION_STATUS_VALID); assertFalse(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(1 /* invocationCount */, false /* isInSafeMode */); // Trigger a failed validation, and the subsequent safemode timeout. triggerValidation(NetworkAgent.VALIDATION_STATUS_NOT_VALID); Loading @@ -416,7 +418,7 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection runnableCaptor.getValue().run(); mTestLooper.dispatchAll(); assertTrue(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(2 /* invocationCount */, true /* isInSafeMode */); } private Consumer<VcnNetworkAgent> setupNetworkAndGetUnwantedCallback() { Loading
tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionTestBase.java +6 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static com.android.server.vcn.VcnTestUtils.setupIpSecManager; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.CALLS_REAL_METHODS; Loading Loading @@ -301,6 +300,11 @@ public class VcnGatewayConnectionTestBase { expectCanceled); } protected void verifySafeModeStateAndCallbackFired(int invocationCount, boolean isInSafeMode) { verify(mGatewayStatusCallback, times(invocationCount)).onSafeModeStatusChanged(); assertEquals(isInSafeMode, mGatewayConnection.isInSafeMode()); } protected void verifySafeModeTimeoutNotifiesCallbackAndUnregistersNetworkAgent( @NonNull State expectedState) { // Set a VcnNetworkAgent, and expect it to be unregistered and cleared Loading @@ -314,9 +318,8 @@ public class VcnGatewayConnectionTestBase { delayedEvent.run(); mTestLooper.dispatchAll(); verify(mGatewayStatusCallback).onSafeModeStatusChanged(); assertEquals(expectedState, mGatewayConnection.getCurrentState()); assertTrue(mGatewayConnection.isInSafeMode()); verifySafeModeStateAndCallbackFired(1, true); verify(mockNetworkAgent).unregister(); assertNull(mGatewayConnection.getNetworkAgent()); Loading