summaryrefslogtreecommitdiff
path: root/src/android/net/ip/IpClient.java
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2020-06-19 06:05:41 +0000
committerRemi NGUYEN VAN <reminv@google.com>2020-06-24 15:45:50 +0900
commit750fe188d303a7075df1d7df151db2334ddb98c1 (patch)
tree547ed4954b19080ec5fa58133d7019eb22454f99 /src/android/net/ip/IpClient.java
parent0c423089f7c64ab82461be73778e067872789f8b (diff)
Send normal termination metrics on wifi off
When turning wifi off, the interface gets torn down and empty LinkProperties are received before wifi calls stop(). This causes a loss of provisioning to be logged, instead of normal termination. Watch interface link status up/down events, and when provisioning is lost when the interface is down, consider it a normal termination. Bug: 151796056 Test: manual: turn wifi off, observe events Test: atest NetworkStackIntegrationTests (see also test-only change) Original-Change: https://android-review.googlesource.com/1343236 Merged-In: I9d086a199de0017aa425219d20882211423925e0 Change-Id: I9d086a199de0017aa425219d20882211423925e0
Diffstat (limited to 'src/android/net/ip/IpClient.java')
-rw-r--r--src/android/net/ip/IpClient.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java
index 1591f43..c4f46ae 100644
--- a/src/android/net/ip/IpClient.java
+++ b/src/android/net/ip/IpClient.java
@@ -389,6 +389,9 @@ public class IpClient extends StateMachine {
private static final int CMD_COMPLETE_PRECONNECTION = 16;
private static final int CMD_UPDATE_L2INFORMATION = 17;
+ private static final int ARG_LINKPROP_CHANGED_LINKSTATE_DOWN = 0;
+ private static final int ARG_LINKPROP_CHANGED_LINKSTATE_UP = 1;
+
// Internal commands to use instead of trying to call transitionTo() inside
// a given State's enter() method. Calling transitionTo() from enter/exit
// encounters a Log.wtf() that can cause trouble on eng builds.
@@ -596,7 +599,9 @@ public class IpClient extends StateMachine {
mLinkObserver = new IpClientLinkObserver(
mContext, getHandler(),
mInterfaceName,
- () -> sendMessage(EVENT_NETLINK_LINKPROPERTIES_CHANGED),
+ (ifaceUp) -> sendMessage(EVENT_NETLINK_LINKPROPERTIES_CHANGED, ifaceUp
+ ? ARG_LINKPROP_CHANGED_LINKSTATE_UP
+ : ARG_LINKPROP_CHANGED_LINKSTATE_DOWN),
config, mLog) {
@Override
public void onInterfaceAdded(String iface) {
@@ -2053,12 +2058,14 @@ public class IpClient extends StateMachine {
case EVENT_NETLINK_LINKPROPERTIES_CHANGED:
// EVENT_NETLINK_LINKPROPERTIES_CHANGED message will be received in both of
- // provisioning loss and normal user termination case (e.g. turn off wifi or
- // switch to another wifi ssid), hence, checking current interface change
- // status (down or up) would help distinguish.
- final boolean ifUp = (msg.arg1 != 0);
+ // provisioning loss and normal user termination cases (e.g. turn off wifi or
+ // switch to another wifi ssid), hence, checking the current interface link
+ // state (down or up) helps distinguish the two cases: if the link state is
+ // down, provisioning is only lost because the link is being torn down (for
+ // example when turning off wifi), so treat it as a normal termination.
if (!handleLinkPropertiesUpdate(SEND_CALLBACKS)) {
- transitionToStoppingState(ifUp ? DisconnectCode.DC_PROVISIONING_FAIL
+ final boolean linkStateUp = (msg.arg1 == ARG_LINKPROP_CHANGED_LINKSTATE_UP);
+ transitionToStoppingState(linkStateUp ? DisconnectCode.DC_PROVISIONING_FAIL
: DisconnectCode.DC_NORMAL_TERMINATION);
}
break;