}
}
- private final IpConnectivityLog mMetricsLog = new IpConnectivityLog();
+ private final IpConnectivityLog mMetricsLog;
/**
* Implements support for the legacy "one network per network type" model.
public ConnectivityService(Context context, INetworkManagementService netManager,
INetworkStatsService statsService, INetworkPolicyManager policyManager) {
+ this(context, netManager, statsService, policyManager, new IpConnectivityLog());
+ }
+
+ @VisibleForTesting
+ protected ConnectivityService(Context context, INetworkManagementService netManager,
+ INetworkStatsService statsService, INetworkPolicyManager policyManager,
+ IpConnectivityLog logger) {
if (DBG) log("ConnectivityService starting up");
+ mMetricsLog = logger;
mDefaultRequest = createInternetRequestForTransport(-1);
NetworkRequestInfo defaultNRI = new NetworkRequestInfo(null, mDefaultRequest, new Binder());
mNetworkRequests.put(mDefaultRequest, defaultNRI);
private final WifiManager mWifiManager;
private final AlarmManager mAlarmManager;
private final NetworkRequest mDefaultRequest;
- private final IpConnectivityLog mMetricsLog = new IpConnectivityLog();
+ private final IpConnectivityLog mMetricsLog;
private boolean mIsCaptivePortalCheckEnabled;
private boolean mUseHttps;
public NetworkMonitor(Context context, Handler handler, NetworkAgentInfo networkAgentInfo,
NetworkRequest defaultRequest) {
+ this(context, handler, networkAgentInfo, defaultRequest, new IpConnectivityLog());
+ }
+
+ @VisibleForTesting
+ protected NetworkMonitor(Context context, Handler handler, NetworkAgentInfo networkAgentInfo,
+ NetworkRequest defaultRequest, IpConnectivityLog logger) {
// Add suffix indicating which NetworkMonitor we're talking about.
super(TAG + networkAgentInfo.name());
mContext = context;
+ mMetricsLog = logger;
mConnectivityServiceHandler = handler;
mNetworkAgentInfo = networkAgentInfo;
mNetId = mNetworkAgentInfo.network.netId;
import android.net.NetworkMisc;
import android.net.NetworkRequest;
import android.net.RouteInfo;
+import android.net.metrics.IpConnectivityLog;
import android.os.ConditionVariable;
import android.os.Handler;
import android.os.HandlerThread;
public String gen204ProbeRedirectUrl = null;
public WrappedNetworkMonitor(Context context, Handler handler,
- NetworkAgentInfo networkAgentInfo, NetworkRequest defaultRequest) {
- super(context, handler, networkAgentInfo, defaultRequest);
+ NetworkAgentInfo networkAgentInfo, NetworkRequest defaultRequest,
+ IpConnectivityLog log) {
+ super(context, handler, networkAgentInfo, defaultRequest, log);
}
@Override
private WrappedNetworkMonitor mLastCreatedNetworkMonitor;
public WrappedConnectivityService(Context context, INetworkManagementService netManager,
- INetworkStatsService statsService, INetworkPolicyManager policyManager) {
- super(context, netManager, statsService, policyManager);
+ INetworkStatsService statsService, INetworkPolicyManager policyManager,
+ IpConnectivityLog log) {
+ super(context, netManager, statsService, policyManager, log);
mLingerDelayMs = TEST_LINGER_DELAY_MS;
}
@Override
public NetworkMonitor createNetworkMonitor(Context context, Handler handler,
NetworkAgentInfo nai, NetworkRequest defaultRequest) {
- final WrappedNetworkMonitor monitor = new WrappedNetworkMonitor(context, handler, nai,
- defaultRequest);
+ final WrappedNetworkMonitor monitor = new WrappedNetworkMonitor(
+ context, handler, nai, defaultRequest, mock(IpConnectivityLog.class));
mLastCreatedNetworkMonitor = monitor;
return monitor;
}
mService = new WrappedConnectivityService(mServiceContext,
mock(INetworkManagementService.class),
mock(INetworkStatsService.class),
- mock(INetworkPolicyManager.class));
+ mock(INetworkPolicyManager.class),
+ mock(IpConnectivityLog.class));
mService.systemReady();
mCm = new WrappedConnectivityManager(getContext(), mService);