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>
@@ -1716,14 +1717,6 @@ TEST_F(BinderLibTest, ThreadPoolStarted) {
17161717 EXPECT_TRUE (reply.readBool ());
17171718}
17181719
1719- size_t epochMillis () {
1720- using std::chrono::duration_cast;
1721- using std::chrono::milliseconds;
1722- using std::chrono::seconds;
1723- using std::chrono::system_clock;
1724- return duration_cast<milliseconds>(system_clock::now ().time_since_epoch ()).count ();
1725- }
1726-
17271720TEST_F (BinderLibTest, HangingServices) {
17281721 Parcel data, reply;
17291722 sp<IBinder> server = addServer ();
@@ -1732,7 +1725,7 @@ TEST_F(BinderLibTest, HangingServices) {
17321725 data.writeInt32 (delay);
17331726 // b/266537959 - must take before taking lock, since countdown is started in the remote
17341727 // process there.
1735- size_t epochMsBefore = epochMillis ();
1728+ int64_t timeBefore = uptimeMillis ();
17361729 EXPECT_THAT (server->transact (BINDER_LIB_TEST_PROCESS_TEMPORARY_LOCK, data, &reply), NO_ERROR);
17371730 std::vector<std::thread> ts;
17381731 for (size_t i = 0 ; i < kKernelThreads + 1 ; i++) {
@@ -1746,10 +1739,10 @@ TEST_F(BinderLibTest, HangingServices) {
17461739 for (auto &t : ts) {
17471740 t.join ();
17481741 }
1749- size_t epochMsAfter = epochMillis ();
1742+ int64_t timeAfter = uptimeMillis ();
17501743
17511744 // deadlock occurred and threads only finished after 1s passed.
1752- EXPECT_GE (epochMsAfter, epochMsBefore + delay);
1745+ EXPECT_GE (timeAfter, timeBefore + delay);
17531746}
17541747
17551748TEST_F (BinderLibTest, BinderProxyCount) {
0 commit comments