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

Commit 0d1398b2 authored by Alec Mouri's avatar Alec Mouri
Browse files

[ANativeWindow] Add apex header for getLastQueueDuration

Bug: 137012798
Test: libnativewindow_test
Change-Id: I46d5ab9c11161923ebbbc67400b10b2e7c0c6b61
parent 4ab80de6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -274,3 +274,7 @@ int ANativeWindow_setAutoPrerotation(ANativeWindow* window, bool autoPrerotation
int ANativeWindow_getLastDequeueDuration(ANativeWindow* window) {
    return query(window, NATIVE_WINDOW_LAST_DEQUEUE_DURATION);
}

int ANativeWindow_getLastQueueDuration(ANativeWindow* window) {
    return query(window, NATIVE_WINDOW_LAST_QUEUE_DURATION);
}
+8 −0
Original line number Diff line number Diff line
@@ -31,4 +31,12 @@ __BEGIN_DECLS
 */
int ANativeWindow_getLastDequeueDuration(ANativeWindow* window);

/**
 * Retrieves how long it took for the last time a buffer was queued.
 *
 * \return a negative value on error, otherwise returns the duration in
 * microseconds
 */
int ANativeWindow_getLastQueueDuration(ANativeWindow* window);

__END_DECLS
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ LIBNATIVEWINDOW {
    ANativeWindow_getFormat;
    ANativeWindow_getHeight;
    ANativeWindow_getLastDequeueDuration; # apex # introduced=30
    ANativeWindow_getLastQueueDuration; # apex # introduced=30
    ANativeWindow_getWidth;
    ANativeWindow_lock;
    ANativeWindow_query; # vndk
+35 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ public:

    // Exposes the internal last dequeue duration that's stored on the Surface.
    nsecs_t getLastDequeueDuration() const { return mLastDequeueDuration; }

    // Exposes the internal last queue duration that's stored on the Surface.
    nsecs_t getLastQueueDuration() const { return mLastQueueDuration; }
};

class ANativeWindowTest : public ::testing::Test {
@@ -82,3 +85,35 @@ TEST_F(ANativeWindowTest, getLastDequeueDuration_withDequeue_returnsTime) {
    EXPECT_GT(result, 0);
    EXPECT_EQ(result, mWindow->getLastDequeueDuration() / 1000);
}

TEST_F(ANativeWindowTest, getLastQueueDuration_noDequeue_returnsZero) {
    int result = ANativeWindow_getLastQueueDuration(mWindow.get());
    EXPECT_EQ(0, result);
    EXPECT_EQ(0, mWindow->getLastQueueDuration());
}

TEST_F(ANativeWindowTest, getLastQueueDuration_noQueue_returnsZero) {
    ANativeWindowBuffer* buffer;
    int fd;
    int result = ANativeWindow_dequeueBuffer(mWindow.get(), &buffer, &fd);
    close(fd);
    EXPECT_EQ(0, result);

    result = ANativeWindow_getLastQueueDuration(mWindow.get());
    EXPECT_EQ(result, 0);
    EXPECT_EQ(result, mWindow->getLastQueueDuration());
}

TEST_F(ANativeWindowTest, getLastQueueDuration_withQueue_returnsTime) {
    ANativeWindowBuffer* buffer;
    int fd;
    int result = ANativeWindow_dequeueBuffer(mWindow.get(), &buffer, &fd);
    close(fd);
    EXPECT_EQ(0, result);

    result = ANativeWindow_queueBuffer(mWindow.get(), buffer, 0);

    result = ANativeWindow_getLastQueueDuration(mWindow.get());
    EXPECT_GT(result, 0);
    EXPECT_EQ(result, mWindow->getLastQueueDuration() / 1000);
}