Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de90ea3d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use libbase to get the elapsed time instead of libutils"

parents a8525a06 cab9854f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ cc_defaults {
    static_libs: [
        "libbase",
        "liblog",
        "libutils",
    ],
}

+12 −2
Original line number Diff line number Diff line
@@ -15,12 +15,16 @@
 */

#include "include/StatsEventCompat.h"

#include <chrono>

#include <android-base/chrono_utils.h>
#include <android-base/properties.h>
#include <android/api-level.h>
#include <android/log.h>
#include <dlfcn.h>
#include <utils/SystemClock.h>

using android::base::boot_clock;
using android::base::GetProperty;

const static int kStatsEventTag = 1937006964;
@@ -41,6 +45,12 @@ bool StatsEventCompat::mAttemptedLoad = false;
void* StatsEventCompat::mStatsEventApi = nullptr;
std::mutex StatsEventCompat::mLoadLock;

static int64_t elapsedRealtimeNano() {
    return std::chrono::time_point_cast<std::chrono::nanoseconds>(boot_clock::now())
            .time_since_epoch()
            .count();
}

StatsEventCompat::StatsEventCompat() : mEventQ(kStatsEventTag) {
    // guard loading because StatsEventCompat might be called from multithreaded
    // environment
@@ -61,7 +71,7 @@ StatsEventCompat::StatsEventCompat() : mEventQ(kStatsEventTag) {
    if (mStatsEventApi) {
        //        mEventR = mStatsEventApi->obtain();
    } else if (!mPlatformAtLeastR) {
        mEventQ << android::elapsedRealtimeNano();
        mEventQ << elapsedRealtimeNano();
    }
}