You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
api-impl-jni: android_os_SystemClock.c: use CLOCK_MONOTONIC to match System.nanoTime
This commit is contained in:
@@ -8,12 +8,12 @@ JNIEXPORT jlong JNICALL Java_android_os_SystemClock_elapsedRealtime(JNIEnv *env,
|
|||||||
struct timespec t;
|
struct timespec t;
|
||||||
clock_gettime(CLOCK_BOOTTIME, &t);
|
clock_gettime(CLOCK_BOOTTIME, &t);
|
||||||
jlong ret = t.tv_sec * 1000 + lround(t.tv_nsec / 1e6);
|
jlong ret = t.tv_sec * 1000 + lround(t.tv_nsec / 1e6);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_android_os_SystemClock_uptimeMillis(JNIEnv *env, jclass this)
|
JNIEXPORT jlong JNICALL Java_android_os_SystemClock_uptimeMillis(JNIEnv *env, jclass this)
|
||||||
{
|
{
|
||||||
struct timespec t;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_REALTIME, &t);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
return t.tv_sec * 1000 + lround(t.tv_nsec / 1e6);
|
return now.tv_sec * 1000 + lround(now.tv_nsec / 1e6);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user