diff options
| author | Chalard Jean <jchalard@google.com> | 2019-11-19 19:03:53 +0900 |
|---|---|---|
| committer | Chalard Jean <jchalard@google.com> | 2019-12-02 13:02:38 +0900 |
| commit | bbaa33e1d31c66ea1203a226523caf174bb701e6 (patch) | |
| tree | 70f53c19bc1510e70a612b844070aac7206dcfde /tests/net/java/com/android/server/ConnectivityServiceTest.java | |
| parent | 24b7fe0108acc501820fb01f1631595be2397775 (diff) | |
[NS A14] Move code notifying battery stats in its right place
This should be done once every time an interface comes online.
Doing this in updateLinkProperties guarantees this happens every
time a new interface comes online, but it doesn't do it more
often than needed.
Test: FrameworksNetTests NetworkStackTests
Change-Id: I0613c23f44192944266d76107308da8d1c541d1c
Diffstat (limited to 'tests/net/java/com/android/server/ConnectivityServiceTest.java')
| -rw-r--r-- | tests/net/java/com/android/server/ConnectivityServiceTest.java | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/tests/net/java/com/android/server/ConnectivityServiceTest.java b/tests/net/java/com/android/server/ConnectivityServiceTest.java index da83397b49ad..9b0ccdd4451d 100644 --- a/tests/net/java/com/android/server/ConnectivityServiceTest.java +++ b/tests/net/java/com/android/server/ConnectivityServiceTest.java @@ -5664,14 +5664,6 @@ public class ConnectivityServiceTest { TYPE_WIFI); reset(mBatteryStatsService); - // TODO : In the current code, ConnectivityService only tells BatteryStatsService about - // the type of networks that satisfy a request. That is a bug in a sense, but it has no - // consequences because a network that never satisfies any request gets torn down right - // away. Because of this, in the context of this test, the cell network agent does not - // satisfy any request as long as WiFi is connected, so the test below would fail if - // the WiFi network agent is not disconnected first. When this bug is fixed, remove the - // WiFi disconnect for more precise testing. - mWiFiNetworkAgent.disconnect(); mCellNetworkAgent.disconnect(); cellLp.setInterfaceName("wifi0"); @@ -5722,13 +5714,12 @@ public class ConnectivityServiceTest { mCm.registerNetworkCallback(networkRequest, networkCallback); // Prepare ipv6 only link properties. - mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR); - final int cellNetId = mCellNetworkAgent.getNetwork().netId; final LinkProperties cellLp = new LinkProperties(); cellLp.setInterfaceName(MOBILE_IFNAME); cellLp.addLinkAddress(myIpv6); cellLp.addRoute(new RouteInfo((IpPrefix) null, myIpv6.getAddress(), MOBILE_IFNAME)); cellLp.addRoute(new RouteInfo(myIpv6, null, MOBILE_IFNAME)); + mCellNetworkAgent = new TestNetworkAgentWrapper(TRANSPORT_CELLULAR, cellLp); reset(mNetworkManagementService); reset(mMockDnsResolver); reset(mMockNetd); @@ -5737,8 +5728,8 @@ public class ConnectivityServiceTest { .thenReturn(getClatInterfaceConfig(myIpv4)); // Connect with ipv6 link properties. Expect prefix discovery to be started. - mCellNetworkAgent.sendLinkProperties(cellLp); mCellNetworkAgent.connect(true); + final int cellNetId = mCellNetworkAgent.getNetwork().netId; waitForIdle(); verify(mMockNetd, times(1)).networkCreatePhysical(eq(cellNetId), anyInt()); @@ -5811,14 +5802,10 @@ public class ConnectivityServiceTest { assertEquals(1, resolvrParams.servers.length); assertTrue(ArrayUtils.contains(resolvrParams.servers, "8.8.8.8")); - // TODO : this should be invoked but in the current code there is no path to invoke - // it. In practice, it will be invoked next time this network changes what requests it - // satisfies through rematchNetworkAndRequests, which may in fact be too late. This code - // should be reinstated when the bug is fixed. -// for (final LinkProperties stackedLp : stackedLpsAfterChange) { -// verify(mBatteryStatsService).noteNetworkInterfaceType(stackedLp.getInterfaceName(), -// TYPE_MOBILE); -// } + for (final LinkProperties stackedLp : stackedLpsAfterChange) { + verify(mBatteryStatsService).noteNetworkInterfaceType(stackedLp.getInterfaceName(), + TYPE_MOBILE); + } // Add ipv4 address, expect that clatd and prefix discovery are stopped and stacked // linkproperties are cleaned up. |
