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

Commit 95f11589 authored by Nick Pelly's avatar Nick Pelly
Browse files

Introduce SystemClock#elapsedRealtimeNano.

Change-Id: I47e1b14d45c5321f959d46e1805f86aafd72f5d4
parent 824582dc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16342,6 +16342,7 @@ package android.os {
  public final class SystemClock {
    method public static long currentThreadTimeMillis();
    method public static long elapsedRealtime();
    method public static long elapsedRealtimeNano();
    method public static boolean setCurrentTimeMillis(long);
    method public static void sleep(long);
    method public static long uptimeMillis();
+17 −9
Original line number Diff line number Diff line
@@ -46,15 +46,16 @@ package android.os;
 *     such as {@link Thread#sleep(long) Thread.sleep(millls)},
 *     {@link Object#wait(long) Object.wait(millis)}, and
 *     {@link System#nanoTime System.nanoTime()}.  This clock is guaranteed
 *     to be monotonic, and is the recommended basis for the general purpose
 *     interval timing of user interface events, performance measurements,
 *     and anything else that does not need to measure elapsed time during
 *     device sleep.  Most methods that accept a timestamp value expect the
 *     {@link #uptimeMillis} clock.
 *
 *     <li> <p> {@link #elapsedRealtime} is counted in milliseconds since the
 *     system was booted, including deep sleep.  This clock should be used
 *     when measuring time intervals that may span periods of system sleep.
 *     to be monotonic, and is suitable for interval timing when the
 *     interval does not span device sleep.  Most methods that accept a
 *     timestamp value currently expect the {@link #uptimeMillis} clock.
 *
 *     <li> <p> {@link #elapsedRealtime} and {@link #elapsedRealtimeNano}
 *     return the time since the system was booted, and include deep sleep.
 *     This clock is guaranteed to be monotonic, and continues to tick even
 *     when the CPU is in power saving modes, so is the recommend basis
 *     for general purpose interval timing.
 *
 * </ul>
 *
 * There are several mechanisms for controlling the timing of events:
@@ -151,6 +152,13 @@ public final class SystemClock {
     */
    native public static long elapsedRealtime();

    /**
     * Returns nanoseconds since boot, including time spent in sleep.
     *
     * @return elapsed nanoseconds since boot.
     */
    public static native long elapsedRealtimeNano();

    /**
     * Returns milliseconds running in the current thread.
     * 
+11 −0
Original line number Diff line number Diff line
@@ -111,6 +111,15 @@ static jlong android_os_SystemClock_currentTimeMicro(JNIEnv* env,
    return tv.tv_sec * 1000000LL + tv.tv_usec;
}

/*
 * public static native long elapsedRealtimeNano();
 */
static jlong android_os_SystemClock_elapsedRealtimeNano(JNIEnv* env,
        jobject clazz)
{
    return (jlong)elapsedRealtimeNano();
}

/*
 * JNI registration.
 */
@@ -128,6 +137,8 @@ static JNINativeMethod gMethods[] = {
            (void*) android_os_SystemClock_currentThreadTimeMicro },
    { "currentTimeMicro",             "()J",
            (void*) android_os_SystemClock_currentTimeMicro },
    { "elapsedRealtimeNano",      "()J",
            (void*) android_os_SystemClock_elapsedRealtimeNano },
};
int register_android_os_SystemClock(JNIEnv* env)
{