Merge "init: Use android::base::boot_clock instead of /proc/uptime"
am: 8e73e6f242
Change-Id: I32c0ee2092a39af494126b7fbe3f42e0f6c0a2d1
This commit is contained in:
commit
c12004dd23
1 changed files with 5 additions and 3 deletions
|
|
@ -32,12 +32,14 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include <android-base/chrono_utils.h>
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
|
|
||||||
using android::base::StringPrintf;
|
using android::base::StringPrintf;
|
||||||
|
using android::base::boot_clock;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
@ -50,9 +52,9 @@ static std::condition_variable g_bootcharting_finished_cv;
|
||||||
static bool g_bootcharting_finished;
|
static bool g_bootcharting_finished;
|
||||||
|
|
||||||
static long long get_uptime_jiffies() {
|
static long long get_uptime_jiffies() {
|
||||||
std::string uptime;
|
constexpr int64_t kNanosecondsPerJiffy = 10000000;
|
||||||
if (!android::base::ReadFileToString("/proc/uptime", &uptime)) return 0;
|
boot_clock::time_point uptime = boot_clock::now();
|
||||||
return 100LL * strtod(uptime.c_str(), NULL);
|
return uptime.time_since_epoch().count() / kNanosecondsPerJiffy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<FILE, decltype(&fclose)> fopen_unique(const char* filename,
|
static std::unique_ptr<FILE, decltype(&fclose)> fopen_unique(const char* filename,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue