Loading services/core/java/com/android/server/ConnectivityService.java +2 −1 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.UidRange; import android.net.Uri; import android.net.metrics.ConnectivityServiceChangeEvent; import android.os.Binder; import android.os.Build; import android.os.Bundle; Loading Loading @@ -4511,6 +4512,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private void makeDefault(NetworkAgentInfo newNetwork) { if (DBG) log("Switching to new default network: " + newNetwork); ConnectivityServiceChangeEvent.logEvent(newNetwork.network.netId); setupDataActivityTracking(newNetwork); try { mNetd.setDefaultNetId(newNetwork.network.netId); Loading Loading @@ -5141,5 +5143,4 @@ public class ConnectivityService extends IConnectivityManager.Stub NetworkAgentInfo nai, NetworkRequest defaultRequest) { return new NetworkMonitor(context, handler, nai, defaultRequest); } } services/core/java/com/android/server/connectivity/MetricsLoggerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class MetricsLoggerService extends SystemService { private long mLastSentEventTimeMillis = System.currentTimeMillis(); private final void enforceConnectivityInternalPermission() { getContext().enforceCallingPermission( getContext().enforceCallingOrSelfPermission( android.Manifest.permission.CONNECTIVITY_INTERNAL, "MetricsLoggerService"); } Loading services/core/java/com/android/server/connectivity/NetworkMonitor.java +10 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.net.NetworkRequest; import android.net.ProxyInfo; import android.net.TrafficStats; import android.net.Uri; import android.net.metrics.CaptivePortalCheckResultEvent; import android.net.metrics.CaptivePortalStateChangeEvent; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Handler; Loading Loading @@ -297,9 +299,13 @@ public class NetworkMonitor extends StateMachine { transitionTo(mLingeringState); return HANDLED; case CMD_NETWORK_CONNECTED: CaptivePortalStateChangeEvent.logEvent( CaptivePortalStateChangeEvent.NETWORK_MONITOR_CONNECTED); transitionTo(mEvaluatingState); return HANDLED; case CMD_NETWORK_DISCONNECTED: CaptivePortalStateChangeEvent.logEvent( CaptivePortalStateChangeEvent.NETWORK_MONITOR_DISCONNECTED); if (mLaunchCaptivePortalAppBroadcastReceiver != null) { mContext.unregisterReceiver(mLaunchCaptivePortalAppBroadcastReceiver); mLaunchCaptivePortalAppBroadcastReceiver = null; Loading Loading @@ -349,6 +355,8 @@ public class NetworkMonitor extends StateMachine { private class ValidatedState extends State { @Override public void enter() { CaptivePortalStateChangeEvent.logEvent( CaptivePortalStateChangeEvent.NETWORK_MONITOR_VALIDATED); mConnectivityServiceHandler.sendMessage(obtainMessage(EVENT_NETWORK_TESTED, NETWORK_TEST_RESULT_VALID, 0, mNetworkAgentInfo)); } Loading Loading @@ -457,6 +465,8 @@ public class NetworkMonitor extends StateMachine { // will be unresponsive. isCaptivePortal() could be executed on another Thread // if this is found to cause problems. int httpResponseCode = isCaptivePortal(); CaptivePortalCheckResultEvent.logEvent(mNetworkAgentInfo.network.netId, httpResponseCode); if (httpResponseCode == 204) { transitionTo(mValidatedState); } else if (httpResponseCode >= 200 && httpResponseCode <= 399) { Loading services/net/java/android/net/dhcp/DhcpClient.java +9 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.net.DhcpResults; import android.net.InterfaceConfiguration; import android.net.LinkAddress; import android.net.NetworkUtils; import android.net.metrics.IpConnectivityEvent; import android.net.metrics.DhcpClientEvent; import android.os.IBinder; import android.os.INetworkManagementService; import android.os.Message; Loading Loading @@ -355,11 +357,15 @@ public class DhcpClient extends StateMachine { if (!stopped) { Log.e(TAG, "Read error", e); } DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_RECV_ERROR, mIfaceName, e.getMessage()); } catch (DhcpPacket.ParseException e) { Log.e(TAG, "Can't parse packet: " + e.getMessage()); if (PACKET_DBG) { Log.d(TAG, HexDump.dumpHexString(mPacket, 0, length)); } DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_PARSE_ERROR, mIfaceName, e.getMessage()); } } if (DBG) Log.d(TAG, "Receive thread stopped"); Loading Loading @@ -456,7 +462,9 @@ public class DhcpClient extends StateMachine { abstract class LoggingState extends State { public void enter() { if (STATE_DBG) Log.d(TAG, "Entering state " + getName()); String msg = "Entering state " + getName(); if (STATE_DBG) Log.d(TAG, msg); DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_STATE_CHANGE, mIfaceName, msg); } private String messageName(int what) { Loading services/net/java/android/net/ip/IpReachabilityMonitor.java +15 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.net.LinkProperties; import android.net.LinkProperties.ProvisioningChange; import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.metrics.IpReachabilityMonitorMessageEvent; import android.net.metrics.IpReachabilityMonitorProbeEvent; import android.net.netlink.NetlinkConstants; import android.net.netlink.NetlinkErrorMessage; import android.net.netlink.NetlinkMessage; Loading Loading @@ -162,7 +164,7 @@ public class IpReachabilityMonitor { private boolean mRunning; /** * Make the kernel to perform neighbor reachability detection (IPv4 ARP or IPv6 ND) * Make the kernel perform neighbor reachability detection (IPv4 ARP or IPv6 ND) * for the given IP address on the specified interface index. * * @return true, if the request was successfully passed to the kernel; false otherwise. Loading Loading @@ -203,7 +205,8 @@ public class IpReachabilityMonitor { } catch (ErrnoException | InterruptedIOException | SocketException e) { Log.d(TAG, "Error " + msgSnippet, e); } IpReachabilityMonitorProbeEvent.logEvent("ifindex-" + ifIndex, ip.getHostAddress(), returnValue); return returnValue; } Loading Loading @@ -400,8 +403,7 @@ public class IpReachabilityMonitor { return (numUnicastProbes * retransTimeMs) + gracePeriodMs; } // TODO: simply the number of objects by making this extend Thread. // TODO: simplify the number of objects by making this extend Thread. private final class NetlinkSocketObserver implements Runnable { private NetlinkSocket mSocket; Loading Loading @@ -519,6 +521,8 @@ public class IpReachabilityMonitor { final short msgType = neighMsg.getHeader().nlmsg_type; final short nudState = ndMsg.ndm_state; IpReachabilityMonitorMessageEvent.logEvent(maybeGetInterfaceName(mInterfaceIndex), destination.getHostAddress(), msgType, nudState); final String eventMsg = "NeighborEvent{" + "elapsedMs=" + whenMs + ", " + destination.getHostAddress() + ", " Loading Loading @@ -549,4 +553,11 @@ public class IpReachabilityMonitor { } } } private String maybeGetInterfaceName(int index) { if (index == mInterfaceIndex) { return mInterfaceName; } return "ifindex-" + index; } } Loading
services/core/java/com/android/server/ConnectivityService.java +2 −1 Original line number Diff line number Diff line Loading @@ -71,6 +71,7 @@ import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.UidRange; import android.net.Uri; import android.net.metrics.ConnectivityServiceChangeEvent; import android.os.Binder; import android.os.Build; import android.os.Bundle; Loading Loading @@ -4511,6 +4512,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private void makeDefault(NetworkAgentInfo newNetwork) { if (DBG) log("Switching to new default network: " + newNetwork); ConnectivityServiceChangeEvent.logEvent(newNetwork.network.netId); setupDataActivityTracking(newNetwork); try { mNetd.setDefaultNetId(newNetwork.network.netId); Loading Loading @@ -5141,5 +5143,4 @@ public class ConnectivityService extends IConnectivityManager.Stub NetworkAgentInfo nai, NetworkRequest defaultRequest) { return new NetworkMonitor(context, handler, nai, defaultRequest); } }
services/core/java/com/android/server/connectivity/MetricsLoggerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class MetricsLoggerService extends SystemService { private long mLastSentEventTimeMillis = System.currentTimeMillis(); private final void enforceConnectivityInternalPermission() { getContext().enforceCallingPermission( getContext().enforceCallingOrSelfPermission( android.Manifest.permission.CONNECTIVITY_INTERNAL, "MetricsLoggerService"); } Loading
services/core/java/com/android/server/connectivity/NetworkMonitor.java +10 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.net.NetworkRequest; import android.net.ProxyInfo; import android.net.TrafficStats; import android.net.Uri; import android.net.metrics.CaptivePortalCheckResultEvent; import android.net.metrics.CaptivePortalStateChangeEvent; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Handler; Loading Loading @@ -297,9 +299,13 @@ public class NetworkMonitor extends StateMachine { transitionTo(mLingeringState); return HANDLED; case CMD_NETWORK_CONNECTED: CaptivePortalStateChangeEvent.logEvent( CaptivePortalStateChangeEvent.NETWORK_MONITOR_CONNECTED); transitionTo(mEvaluatingState); return HANDLED; case CMD_NETWORK_DISCONNECTED: CaptivePortalStateChangeEvent.logEvent( CaptivePortalStateChangeEvent.NETWORK_MONITOR_DISCONNECTED); if (mLaunchCaptivePortalAppBroadcastReceiver != null) { mContext.unregisterReceiver(mLaunchCaptivePortalAppBroadcastReceiver); mLaunchCaptivePortalAppBroadcastReceiver = null; Loading Loading @@ -349,6 +355,8 @@ public class NetworkMonitor extends StateMachine { private class ValidatedState extends State { @Override public void enter() { CaptivePortalStateChangeEvent.logEvent( CaptivePortalStateChangeEvent.NETWORK_MONITOR_VALIDATED); mConnectivityServiceHandler.sendMessage(obtainMessage(EVENT_NETWORK_TESTED, NETWORK_TEST_RESULT_VALID, 0, mNetworkAgentInfo)); } Loading Loading @@ -457,6 +465,8 @@ public class NetworkMonitor extends StateMachine { // will be unresponsive. isCaptivePortal() could be executed on another Thread // if this is found to cause problems. int httpResponseCode = isCaptivePortal(); CaptivePortalCheckResultEvent.logEvent(mNetworkAgentInfo.network.netId, httpResponseCode); if (httpResponseCode == 204) { transitionTo(mValidatedState); } else if (httpResponseCode >= 200 && httpResponseCode <= 399) { Loading
services/net/java/android/net/dhcp/DhcpClient.java +9 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,8 @@ import android.net.DhcpResults; import android.net.InterfaceConfiguration; import android.net.LinkAddress; import android.net.NetworkUtils; import android.net.metrics.IpConnectivityEvent; import android.net.metrics.DhcpClientEvent; import android.os.IBinder; import android.os.INetworkManagementService; import android.os.Message; Loading Loading @@ -355,11 +357,15 @@ public class DhcpClient extends StateMachine { if (!stopped) { Log.e(TAG, "Read error", e); } DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_RECV_ERROR, mIfaceName, e.getMessage()); } catch (DhcpPacket.ParseException e) { Log.e(TAG, "Can't parse packet: " + e.getMessage()); if (PACKET_DBG) { Log.d(TAG, HexDump.dumpHexString(mPacket, 0, length)); } DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_PARSE_ERROR, mIfaceName, e.getMessage()); } } if (DBG) Log.d(TAG, "Receive thread stopped"); Loading Loading @@ -456,7 +462,9 @@ public class DhcpClient extends StateMachine { abstract class LoggingState extends State { public void enter() { if (STATE_DBG) Log.d(TAG, "Entering state " + getName()); String msg = "Entering state " + getName(); if (STATE_DBG) Log.d(TAG, msg); DhcpClientEvent.logEvent(IpConnectivityEvent.IPCE_DHCP_STATE_CHANGE, mIfaceName, msg); } private String messageName(int what) { Loading
services/net/java/android/net/ip/IpReachabilityMonitor.java +15 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.net.LinkProperties; import android.net.LinkProperties.ProvisioningChange; import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.metrics.IpReachabilityMonitorMessageEvent; import android.net.metrics.IpReachabilityMonitorProbeEvent; import android.net.netlink.NetlinkConstants; import android.net.netlink.NetlinkErrorMessage; import android.net.netlink.NetlinkMessage; Loading Loading @@ -162,7 +164,7 @@ public class IpReachabilityMonitor { private boolean mRunning; /** * Make the kernel to perform neighbor reachability detection (IPv4 ARP or IPv6 ND) * Make the kernel perform neighbor reachability detection (IPv4 ARP or IPv6 ND) * for the given IP address on the specified interface index. * * @return true, if the request was successfully passed to the kernel; false otherwise. Loading Loading @@ -203,7 +205,8 @@ public class IpReachabilityMonitor { } catch (ErrnoException | InterruptedIOException | SocketException e) { Log.d(TAG, "Error " + msgSnippet, e); } IpReachabilityMonitorProbeEvent.logEvent("ifindex-" + ifIndex, ip.getHostAddress(), returnValue); return returnValue; } Loading Loading @@ -400,8 +403,7 @@ public class IpReachabilityMonitor { return (numUnicastProbes * retransTimeMs) + gracePeriodMs; } // TODO: simply the number of objects by making this extend Thread. // TODO: simplify the number of objects by making this extend Thread. private final class NetlinkSocketObserver implements Runnable { private NetlinkSocket mSocket; Loading Loading @@ -519,6 +521,8 @@ public class IpReachabilityMonitor { final short msgType = neighMsg.getHeader().nlmsg_type; final short nudState = ndMsg.ndm_state; IpReachabilityMonitorMessageEvent.logEvent(maybeGetInterfaceName(mInterfaceIndex), destination.getHostAddress(), msgType, nudState); final String eventMsg = "NeighborEvent{" + "elapsedMs=" + whenMs + ", " + destination.getHostAddress() + ", " Loading Loading @@ -549,4 +553,11 @@ public class IpReachabilityMonitor { } } } private String maybeGetInterfaceName(int index) { if (index == mInterfaceIndex) { return mInterfaceName; } return "ifindex-" + index; } }