Fix testRegisterUsageCallback failure in setUp

LocalServices.addService in NetworkStatsService is currently failing
with IllegalStateException "Overriding service registration". Setting up
LocalServices in the test to avoid this issue might be possible, but
moving the registration to the only non-test caller of that constructor
as done here solves the issue and avoids side-effects from a constructor.

Test: this test passes in master through runtest frameworks-net
Bug: b/78487385
Bug: b/80082746
Change-Id: I884a7a8bd7db3fcd220b785ba9914ac8c77720f0
This commit is contained in:
Remi NGUYEN VAN
2018-04-26 17:52:03 +09:00
parent f5ba57b615
commit 04e5975a5a

View File

@@ -227,9 +227,6 @@ public class NetworkStatsServiceTest {
@After
public void tearDown() throws Exception {
// Registered by NetworkStatsService's constructor.
LocalServices.removeServiceForTest(NetworkStatsManagerInternal.class);
IoUtils.deleteContents(mStatsDir);
mServiceContext = null;