Loading services/core/java/com/android/server/vcn/VcnGatewayConnection.java +19 −1 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.Process; import android.os.SystemClock; import android.provider.Settings; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -788,8 +789,19 @@ public class VcnGatewayConnection extends StateMachine { // TODO(b/179091925): Move the delayed-message handling to BaseState // If underlying is null, all underlying networks have been lost. Disconnect VCN after a // timeout. // timeout (or immediately if in airplane mode, since the device user has indicated that // the radios should all be turned off). if (underlying == null) { if (mDeps.isAirplaneModeOn(mVcnContext)) { sendMessageAndAcquireWakeLock( EVENT_UNDERLYING_NETWORK_CHANGED, TOKEN_ALL, new EventUnderlyingNetworkChangedInfo(null)); sendDisconnectRequestedAndAcquireWakelock( DISCONNECT_REASON_UNDERLYING_NETWORK_LOST, false /* shouldQuit */); return; } setDisconnectRequestAlarm(); } else { // Received a new Network so any previous alarm is irrelevant - cancel + clear it, Loading Loading @@ -2424,6 +2436,12 @@ public class VcnGatewayConnection extends StateMachine { validationStatusCallback); } /** Checks if airplane mode is enabled. */ public boolean isAirplaneModeOn(@NonNull VcnContext vcnContext) { return Settings.Global.getInt(vcnContext.getContext().getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0; } /** Gets the elapsed real time since boot, in millis. */ public long getElapsedRealTime() { return SystemClock.elapsedRealtime(); Loading tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,8 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection @Test public void testNullNetworkDoesNotTriggerDisconnect() throws Exception { doReturn(false).when(mDeps).isAirplaneModeOn(any()); mGatewayConnection .getUnderlyingNetworkControllerCallback() .onSelectedUnderlyingNetworkChanged(null); Loading @@ -128,6 +130,19 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection verifyDisconnectRequestAlarmAndGetCallback(false /* expectCanceled */); } @Test public void testNullNetworkAirplaneModeDisconnects() throws Exception { doReturn(true).when(mDeps).isAirplaneModeOn(any()); mGatewayConnection .getUnderlyingNetworkControllerCallback() .onSelectedUnderlyingNetworkChanged(null); mTestLooper.dispatchAll(); assertEquals(mGatewayConnection.mDisconnectingState, mGatewayConnection.getCurrentState()); verify(mIkeSession).kill(); } @Test public void testNewNetworkTriggersMigration() throws Exception { mGatewayConnection Loading Loading
services/core/java/com/android/server/vcn/VcnGatewayConnection.java +19 −1 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.Process; import android.os.SystemClock; import android.provider.Settings; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -788,8 +789,19 @@ public class VcnGatewayConnection extends StateMachine { // TODO(b/179091925): Move the delayed-message handling to BaseState // If underlying is null, all underlying networks have been lost. Disconnect VCN after a // timeout. // timeout (or immediately if in airplane mode, since the device user has indicated that // the radios should all be turned off). if (underlying == null) { if (mDeps.isAirplaneModeOn(mVcnContext)) { sendMessageAndAcquireWakeLock( EVENT_UNDERLYING_NETWORK_CHANGED, TOKEN_ALL, new EventUnderlyingNetworkChangedInfo(null)); sendDisconnectRequestedAndAcquireWakelock( DISCONNECT_REASON_UNDERLYING_NETWORK_LOST, false /* shouldQuit */); return; } setDisconnectRequestAlarm(); } else { // Received a new Network so any previous alarm is irrelevant - cancel + clear it, Loading Loading @@ -2424,6 +2436,12 @@ public class VcnGatewayConnection extends StateMachine { validationStatusCallback); } /** Checks if airplane mode is enabled. */ public boolean isAirplaneModeOn(@NonNull VcnContext vcnContext) { return Settings.Global.getInt(vcnContext.getContext().getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0; } /** Gets the elapsed real time since boot, in millis. */ public long getElapsedRealTime() { return SystemClock.elapsedRealtime(); Loading
tests/vcn/java/com/android/server/vcn/VcnGatewayConnectionConnectedStateTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,8 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection @Test public void testNullNetworkDoesNotTriggerDisconnect() throws Exception { doReturn(false).when(mDeps).isAirplaneModeOn(any()); mGatewayConnection .getUnderlyingNetworkControllerCallback() .onSelectedUnderlyingNetworkChanged(null); Loading @@ -128,6 +130,19 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection verifyDisconnectRequestAlarmAndGetCallback(false /* expectCanceled */); } @Test public void testNullNetworkAirplaneModeDisconnects() throws Exception { doReturn(true).when(mDeps).isAirplaneModeOn(any()); mGatewayConnection .getUnderlyingNetworkControllerCallback() .onSelectedUnderlyingNetworkChanged(null); mTestLooper.dispatchAll(); assertEquals(mGatewayConnection.mDisconnectingState, mGatewayConnection.getCurrentState()); verify(mIkeSession).kill(); } @Test public void testNewNetworkTriggersMigration() throws Exception { mGatewayConnection Loading