Merge changes I3eb82680,I9d6147d9
* changes: NetworkWatchlistServiceTests: update IIpConnectivityMetrics. Stop using IIpConnectivityMetrics in ConnectivityService.
This commit is contained in:
@@ -161,7 +161,6 @@ import android.net.DataStallReportParcelable;
|
||||
import android.net.EthernetManager;
|
||||
import android.net.IConnectivityDiagnosticsCallback;
|
||||
import android.net.IDnsResolver;
|
||||
import android.net.IIpConnectivityMetrics;
|
||||
import android.net.INetd;
|
||||
import android.net.INetworkMonitor;
|
||||
import android.net.INetworkMonitorCallbacks;
|
||||
@@ -359,7 +358,6 @@ public class ConnectivityServiceTest {
|
||||
private HandlerThread mAlarmManagerThread;
|
||||
private TestNetIdManager mNetIdManager;
|
||||
|
||||
@Mock IIpConnectivityMetrics mIpConnectivityMetrics;
|
||||
@Mock IpConnectivityMetrics.Logger mMetricsService;
|
||||
@Mock DefaultNetworkMetrics mDefaultNetworkMetrics;
|
||||
@Mock DeviceIdleInternal mDeviceIdleInternal;
|
||||
@@ -1373,7 +1371,6 @@ public class ConnectivityServiceTest {
|
||||
doReturn(mock(ProxyTracker.class)).when(deps).makeProxyTracker(any(), any());
|
||||
doReturn(mMetricsService).when(deps).getMetricsLogger();
|
||||
doReturn(true).when(deps).queryUserAccess(anyInt(), anyInt());
|
||||
doReturn(mIpConnectivityMetrics).when(deps).getIpConnectivityMetrics();
|
||||
doReturn(mBatteryStatsService).when(deps).getBatteryStatsService();
|
||||
doAnswer(inv -> {
|
||||
mPolicyTracker = new WrappedMultinetworkPolicyTracker(
|
||||
|
||||
@@ -124,6 +124,22 @@ public class IpConnectivityMetricsTest {
|
||||
assertEquals("", output2);
|
||||
}
|
||||
|
||||
private void logDefaultNetworkEvent(long timeMs, NetworkAgentInfo nai,
|
||||
NetworkAgentInfo oldNai) {
|
||||
final Network network = (nai != null) ? nai.network() : null;
|
||||
final int score = (nai != null) ? nai.getCurrentScore() : 0;
|
||||
final boolean validated = (nai != null) ? nai.lastValidated : false;
|
||||
final LinkProperties lp = (nai != null) ? nai.linkProperties : null;
|
||||
final NetworkCapabilities nc = (nai != null) ? nai.networkCapabilities : null;
|
||||
|
||||
final Network prevNetwork = (oldNai != null) ? oldNai.network() : null;
|
||||
final int prevScore = (oldNai != null) ? oldNai.getCurrentScore() : 0;
|
||||
final LinkProperties prevLp = (oldNai != null) ? oldNai.linkProperties : null;
|
||||
final NetworkCapabilities prevNc = (oldNai != null) ? oldNai.networkCapabilities : null;
|
||||
|
||||
mService.mDefaultNetworkMetrics.logDefaultNetworkEvent(timeMs, network, score, validated,
|
||||
lp, nc, prevNetwork, prevScore, prevLp, prevNc);
|
||||
}
|
||||
@Test
|
||||
public void testDefaultNetworkEvents() throws Exception {
|
||||
final long cell = BitUtils.packBits(new int[]{NetworkCapabilities.TRANSPORT_CELLULAR});
|
||||
@@ -147,7 +163,7 @@ public class IpConnectivityMetricsTest {
|
||||
for (NetworkAgentInfo[] pair : defaultNetworks) {
|
||||
timeMs += durationMs;
|
||||
durationMs += durationMs;
|
||||
mService.mDefaultNetworkMetrics.logDefaultNetworkEvent(timeMs, pair[1], pair[0]);
|
||||
logDefaultNetworkEvent(timeMs, pair[1], pair[0]);
|
||||
}
|
||||
|
||||
String want = String.join("\n",
|
||||
@@ -331,8 +347,8 @@ public class IpConnectivityMetricsTest {
|
||||
final long wifi = BitUtils.packBits(new int[]{NetworkCapabilities.TRANSPORT_WIFI});
|
||||
NetworkAgentInfo cellNai = makeNai(100, 50, false, true, cell);
|
||||
NetworkAgentInfo wifiNai = makeNai(101, 60, true, false, wifi);
|
||||
mService.mDefaultNetworkMetrics.logDefaultNetworkEvent(timeMs + 200, cellNai, null);
|
||||
mService.mDefaultNetworkMetrics.logDefaultNetworkEvent(timeMs + 300, wifiNai, cellNai);
|
||||
logDefaultNetworkEvent(timeMs + 200L, cellNai, null);
|
||||
logDefaultNetworkEvent(timeMs + 300L, wifiNai, cellNai);
|
||||
|
||||
String want = String.join("\n",
|
||||
"dropped_events: 0",
|
||||
|
||||
Reference in New Issue
Block a user