diff options
author | Paul Stewart <pstew@google.com> | 2016-10-24 14:01:12 -0700 |
---|---|---|
committer | Paul Stewart <pstew@google.com> | 2016-10-25 08:57:35 -0700 |
commit | 84ee4726383fd968ab43caf120d15d9f47a51a54 (patch) | |
tree | e651fde9ccade445a0a5e767917a12789cf60a0c | |
parent | 4569b3880ba8d741d466e2f880f91b29b56d5e18 (diff) |
Make disconnect due to NUD_FAILURE optional
Provide a special dumpsys parameter to inhibit disconnect due to IP
connectivity failure. Running "dumpsys wifi set-ipreach-disconnect disabled"
will enable this functionality. This will be useful for performing tests
where we would like to understand what happens if we stay online after
a NUD_FAILURE.
Bug: 32331899
Test: run "adb shell dumpsys wifi set-ipreach-disconnect" on DUT
Change-Id: I12474671e22871c4e1c2f755af2a1cac8f652f5b
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 16 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 23 |
2 files changed, 37 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index b71bf39ae..3539cc249 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -119,6 +119,11 @@ public class WifiServiceImpl extends IWifiManager.Stub { private static final boolean DBG = true; private static final boolean VDBG = false; + // Dumpsys argument to enable/disable disconnect on IP reachability failures. + private static final String DUMP_ARG_SET_IPREACH_DISCONNECT = "set-ipreach-disconnect"; + private static final String DUMP_ARG_SET_IPREACH_DISCONNECT_ENABLED = "enabled"; + private static final String DUMP_ARG_SET_IPREACH_DISCONNECT_DISABLED = "disabled"; + final WifiStateMachine mWifiStateMachine; private final Context mContext; @@ -1396,6 +1401,17 @@ public class WifiServiceImpl extends IWifiManager.Stub { String[] ipManagerArgs = new String[args.length - 1]; System.arraycopy(args, 1, ipManagerArgs, 0, ipManagerArgs.length); mWifiStateMachine.dumpIpManager(fd, pw, ipManagerArgs); + } else if (args.length > 0 && DUMP_ARG_SET_IPREACH_DISCONNECT.equals(args[0])) { + if (args.length > 1) { + if (DUMP_ARG_SET_IPREACH_DISCONNECT_ENABLED.equals(args[1])) { + mWifiStateMachine.setIpReachabilityDisconnectEnabled(true); + } else if (DUMP_ARG_SET_IPREACH_DISCONNECT_DISABLED.equals(args[1])) { + mWifiStateMachine.setIpReachabilityDisconnectEnabled(false); + } + } + pw.println("IPREACH_DISCONNECT state is " + + mWifiStateMachine.getIpReachabilityDisconnectEnabled()); + return; } else { pw.println("Wi-Fi is " + mWifiStateMachine.syncGetWifiStateByName()); pw.println("Stay-awake conditions: " + diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 859bbb241..8e5d904dd 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -231,6 +231,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private boolean mIsLinkDebouncing = false; private final StateMachineDeathRecipient mDeathRecipient = new StateMachineDeathRecipient(this, CMD_CLIENT_INTERFACE_BINDER_DEATH); + private boolean mIpReachabilityDisconnectEnabled = true; @Override public void onRssiThresholdBreached(byte curRssi) { @@ -5612,8 +5613,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss break; case CMD_IP_REACHABILITY_LOST: if (mVerboseLoggingEnabled && message.obj != null) log((String) message.obj); - handleIpReachabilityLost(); - transitionTo(mDisconnectingState); + if (mIpReachabilityDisconnectEnabled) { + handleIpReachabilityLost(); + transitionTo(mDisconnectingState); + } else { + logd("CMD_IP_REACHABILITY_LOST but disconnect disabled -- ignore"); + } break; case CMD_DISCONNECT: mWifiNative.disconnect(); @@ -6919,4 +6924,18 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private boolean hasConnectionRequests() { return mConnectionReqCount > 0 || mUntrustedReqCount > 0; } + + /** + * Returns whether CMD_IP_REACHABILITY_LOST events should trigger disconnects. + */ + public boolean getIpReachabilityDisconnectEnabled() { + return mIpReachabilityDisconnectEnabled; + } + + /** + * Sets whether CMD_IP_REACHABILITY_LOST events should trigger disconnects. + */ + public void setIpReachabilityDisconnectEnabled(boolean enabled) { + mIpReachabilityDisconnectEnabled = enabled; + } } |