From 5dd7f07260d91f6e70ad140bcfa33711bc4758b0 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Thu, 26 Apr 2018 17:52:03 +0900 Subject: [PATCH] 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: atest FrameworksNetTests does not choke on this test Bug: b/78487385 Bug: b/80082746 Change-Id: I5dba98fc79aec0800c8b71e6c7e23d1cfbcae852 Merged-In: I884a7a8bd7db3fcd220b785ba9914ac8c77720f0 (Clean cherry-pick of go/ag/4061255) --- .../java/com/android/server/net/NetworkStatsServiceTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java index 280e4c234e..f89f303a13 100644 --- a/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java +++ b/tests/net/java/com/android/server/net/NetworkStatsServiceTest.java @@ -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;