[ANativeWindow] Add apex stub for getLastDequeueStartTime

Also adding private query64 hook so that timing queries can have
nanosecond precision. Otherwise with a 32-bit width we can only have
millisecond precision for timestamps and microsecond precision for time
intervals, and really we shouldn't need to be less precise if we can
help it.

Bug: 137012798
Test: libnativewindow_test
Change-Id: I62233a588eee80f7ea70b74824c8e47461a3be81
diff --git a/libs/nativewindow/tests/ANativeWindowTest.cpp b/libs/nativewindow/tests/ANativeWindowTest.cpp
index 9b358da..947217d 100644
--- a/libs/nativewindow/tests/ANativeWindowTest.cpp
+++ b/libs/nativewindow/tests/ANativeWindowTest.cpp
@@ -39,6 +39,9 @@
 
     // Exposes the internal last queue duration that's stored on the Surface.
     nsecs_t getLastQueueDuration() const { return mLastQueueDuration; }
+
+    // Exposes the internal last dequeue start time that's stored on the Surface.
+    nsecs_t getLastDequeueStartTime() const { return mLastDequeueStartTime; }
 };
 
 class ANativeWindowTest : public ::testing::Test {
@@ -117,3 +120,21 @@
     EXPECT_GT(result, 0);
     EXPECT_EQ(result, mWindow->getLastQueueDuration() / 1000);
 }
+
+TEST_F(ANativeWindowTest, getLastDequeueStartTime_noDequeue_returnsZero) {
+    int64_t result = ANativeWindow_getLastDequeueStartTime(mWindow.get());
+    EXPECT_EQ(0, result);
+    EXPECT_EQ(0, mWindow->getLastQueueDuration());
+}
+
+TEST_F(ANativeWindowTest, getLastDequeueStartTime_withDequeue_returnsTime) {
+    ANativeWindowBuffer* buffer;
+    int fd;
+    int dequeueResult = ANativeWindow_dequeueBuffer(mWindow.get(), &buffer, &fd);
+    close(fd);
+    EXPECT_EQ(0, dequeueResult);
+
+    int64_t result = ANativeWindow_getLastDequeueStartTime(mWindow.get());
+    EXPECT_GT(result, 0);
+    EXPECT_EQ(result, mWindow->getLastDequeueStartTime());
+}