4343#include < input/BlockingQueue.h>
4444#include < processgroup/processgroup.h>
4545#include < utils/Flattenable.h>
46+ #include < utils/SystemClock.h>
4647
4748#include < linux/sched.h>
4849#include < sys/epoll.h>
@@ -1837,14 +1838,6 @@ TEST_F(BinderLibTest, ThreadPoolStarted) {
18371838 EXPECT_TRUE (reply.readBool ());
18381839}
18391840
1840- size_t epochMillis () {
1841- using std::chrono::duration_cast;
1842- using std::chrono::milliseconds;
1843- using std::chrono::seconds;
1844- using std::chrono::system_clock;
1845- return duration_cast<milliseconds>(system_clock::now ().time_since_epoch ()).count ();
1846- }
1847-
18481841TEST_F (BinderLibTest, HangingServices) {
18491842 Parcel data, reply;
18501843 sp<IBinder> server = addServer ();
@@ -1853,7 +1846,7 @@ TEST_F(BinderLibTest, HangingServices) {
18531846 data.writeInt32 (delay);
18541847 // b/266537959 - must take before taking lock, since countdown is started in the remote
18551848 // process there.
1856- size_t epochMsBefore = epochMillis ();
1849+ int64_t timeBefore = uptimeMillis ();
18571850 EXPECT_THAT (server->transact (BINDER_LIB_TEST_PROCESS_TEMPORARY_LOCK, data, &reply), NO_ERROR);
18581851 std::vector<std::thread> ts;
18591852 for (size_t i = 0 ; i < kKernelThreads + 1 ; i++) {
@@ -1867,10 +1860,10 @@ TEST_F(BinderLibTest, HangingServices) {
18671860 for (auto &t : ts) {
18681861 t.join ();
18691862 }
1870- size_t epochMsAfter = epochMillis ();
1863+ int64_t timeAfter = uptimeMillis ();
18711864
18721865 // deadlock occurred and threads only finished after 1s passed.
1873- EXPECT_GE (epochMsAfter, epochMsBefore + delay);
1866+ EXPECT_GE (timeAfter, timeBefore + delay);
18741867}
18751868
18761869TEST_F (BinderLibTest, BinderProxyCount) {
0 commit comments