Migrate from libutils SystemClock.h to std::chrono
Bug: 341997808
Test: mma
Change-Id: Ib4d60eeaaac73566cc79d473f6551e9abd20e69a
diff --git a/libs/binder/ActivityManager.cpp b/libs/binder/ActivityManager.cpp
index 5264276..98349c6 100644
--- a/libs/binder/ActivityManager.cpp
+++ b/libs/binder/ActivityManager.cpp
@@ -23,10 +23,10 @@
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
-#include <utils/SystemClock.h>
-
namespace android {
+using namespace std::chrono_literals;
+
ActivityManager::ActivityManager()
{
}
@@ -43,15 +43,16 @@
}
} else {
ALOGI("Thread pool not started. Polling for activity service.");
- int64_t startTime = 0;
+ auto startTime = std::chrono::steady_clock::now().min();
while (service == nullptr || !IInterface::asBinder(service)->isBinderAlive()) {
sp<IBinder> binder = defaultServiceManager()->checkService(String16("activity"));
if (binder == nullptr) {
// Wait for the activity service to come back...
- if (startTime == 0) {
- startTime = uptimeMillis();
+ if (startTime == startTime.min()) {
+ startTime = std::chrono::steady_clock::now();
ALOGI("Waiting for activity service");
- } else if ((uptimeMillis() - startTime) > 1000000) {
+ } else if (std::chrono::steady_clock::now() - startTime > 1000s) {
+ // TODO(b/342453147): timeout of 1000s = 16min and 40s doesn't seem intended
ALOGW("Waiting too long for activity service, giving up");
service = nullptr;
break;