SystemClock JNI update

Switch to @CriticalNative
Test: make & boot

Change-Id: I5ead83f5c201bf9bb50a39b5c6dcd8b6ac6b5ba5
diff --git a/core/jni/android_os_SystemClock.cpp b/core/jni/android_os_SystemClock.cpp
index ccb833a..2fade69 100644
--- a/core/jni/android_os_SystemClock.cpp
+++ b/core/jni/android_os_SystemClock.cpp
@@ -36,29 +36,18 @@
 
 namespace android {
 
-/*
- * native public static long uptimeMillis();
- */
-static jlong android_os_SystemClock_uptimeMillis(JNIEnv* env,
-        jobject clazz)
-{
-    return (jlong)uptimeMillis();
-}
-
-/*
- * native public static long elapsedRealtime();
- */
-static jlong android_os_SystemClock_elapsedRealtime(JNIEnv* env,
-        jobject clazz)
-{
-    return (jlong)elapsedRealtime();
-}
+static_assert(std::is_same<int64_t, jlong>::value, "jlong isn't an int64_t");
+static_assert(std::is_same<decltype(uptimeMillis()), int64_t>::value,
+        "uptimeMillis signature change, expected int64_t return value");
+static_assert(std::is_same<decltype(elapsedRealtime()), int64_t>::value,
+        "uptimeMillis signature change, expected int64_t return value");
+static_assert(std::is_same<decltype(elapsedRealtimeNano()), int64_t>::value,
+        "uptimeMillis signature change, expected int64_t return value");
 
 /*
  * native public static long currentThreadTimeMillis();
  */
-static jlong android_os_SystemClock_currentThreadTimeMillis(JNIEnv* env,
-        jobject clazz)
+static jlong android_os_SystemClock_currentThreadTimeMillis()
 {
     struct timespec tm;
 
@@ -70,8 +59,7 @@
 /*
  * native public static long currentThreadTimeMicro();
  */
-static jlong android_os_SystemClock_currentThreadTimeMicro(JNIEnv* env,
-        jobject clazz)
+static jlong android_os_SystemClock_currentThreadTimeMicro()
 {
     struct timespec tm;
 
@@ -83,8 +71,7 @@
 /*
  * native public static long currentTimeMicro();
  */
-static jlong android_os_SystemClock_currentTimeMicro(JNIEnv* env,
-        jobject clazz)
+static jlong android_os_SystemClock_currentTimeMicro()
 {
     struct timeval tv;
 
@@ -93,31 +80,22 @@
 }
 
 /*
- * public static native long elapsedRealtimeNano();
- */
-static jlong android_os_SystemClock_elapsedRealtimeNano(JNIEnv* env,
-        jobject clazz)
-{
-    return (jlong)elapsedRealtimeNano();
-}
-
-/*
  * JNI registration.
  */
 static const JNINativeMethod gMethods[] = {
-    /* name, signature, funcPtr */
-    { "uptimeMillis",      "!()J",
-            (void*) android_os_SystemClock_uptimeMillis },
-    { "elapsedRealtime",      "!()J",
-            (void*) android_os_SystemClock_elapsedRealtime },
-    { "currentThreadTimeMillis",      "!()J",
+    // All of these are @CriticalNative, so we can defer directly to SystemClock.h for
+    // some of these
+    { "uptimeMillis", "()J", (void*) uptimeMillis },
+    { "elapsedRealtime", "()J", (void*) elapsedRealtime },
+    { "elapsedRealtimeNanos", "()J", (void*) elapsedRealtimeNano },
+
+    // SystemClock doesn't have an implementation for these that we can directly call
+    { "currentThreadTimeMillis", "()J",
             (void*) android_os_SystemClock_currentThreadTimeMillis },
-    { "currentThreadTimeMicro",       "!()J",
+    { "currentThreadTimeMicro", "()J",
             (void*) android_os_SystemClock_currentThreadTimeMicro },
-    { "currentTimeMicro",             "!()J",
+    { "currentTimeMicro", "()J",
             (void*) android_os_SystemClock_currentTimeMicro },
-    { "elapsedRealtimeNanos",      "!()J",
-            (void*) android_os_SystemClock_elapsedRealtimeNano },
 };
 int register_android_os_SystemClock(JNIEnv* env)
 {