Quit handler threads at the end of the tests

The created handler threads should be quit after the tests to
prevent memory leakage. Also, this commit updates the method
used to close the created HandlerThread to do it correctly.

Bug: 308537727
Test: atest ConnectivityCoverageTests
Change-Id: I3715a73a9142418c05f98bc95e275f97161ab3cd
This commit is contained in:
Chiachang Wang
2023-10-31 09:23:18 +00:00
parent 6c83f00b09
commit 2973cf4363

View File

@@ -4323,7 +4323,9 @@ public class ConnectivityServiceTest {
testFactory.terminate();
testFactory.assertNoRequestChanged();
if (networkCallback != null) mCm.unregisterNetworkCallback(networkCallback);
handlerThread.quit();
handlerThread.quitSafely();
handlerThread.join();
}
@Test
@@ -4384,6 +4386,8 @@ public class ConnectivityServiceTest {
expectNoRequestChanged(testFactoryAll); // still seeing the request
mWiFiAgent.disconnect();
handlerThread.quitSafely();
handlerThread.join();
}
@Test
@@ -4417,7 +4421,8 @@ public class ConnectivityServiceTest {
}
}
}
handlerThread.quit();
handlerThread.quitSafely();
handlerThread.join();
}
@Test
@@ -6038,7 +6043,8 @@ public class ConnectivityServiceTest {
testFactory.assertNoRequestChanged();
} finally {
mCm.unregisterNetworkCallback(cellNetworkCallback);
handlerThread.quit();
handlerThread.quitSafely();
handlerThread.join();
}
}
@@ -6628,7 +6634,8 @@ public class ConnectivityServiceTest {
}
} finally {
testFactory.terminate();
handlerThread.quit();
handlerThread.quitSafely();
handlerThread.join();
}
}
@@ -15331,6 +15338,8 @@ public class ConnectivityServiceTest {
expectNoRequestChanged(oemPaidFactory);
internetFactory.expectRequestAdd();
mCm.unregisterNetworkCallback(wifiCallback);
handlerThread.quitSafely();
handlerThread.join();
}
/**
@@ -15695,6 +15704,8 @@ public class ConnectivityServiceTest {
assertTrue(testFactory.getMyStartRequested());
} finally {
testFactory.terminate();
handlerThread.quitSafely();
handlerThread.join();
}
}