From 8e47a6767140d067ccc9f9b41d62ff6f924de3ed Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Mon, 1 May 2023 11:30:37 -0500 Subject: [PATCH] Add vsync id and timestamp to WindowInfosListener Bug: 279792237 Test: presubmits Change-Id: I6396800fe7673f592a79c0e9a9f43f68c6443300 --- core/jni/android_window_WindowInfosListener.cpp | 10 ++++++---- libs/input/PointerController.cpp | 5 ++--- libs/input/PointerController.h | 4 ++-- libs/input/tests/PointerController_test.cpp | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/jni/android_window_WindowInfosListener.cpp b/core/jni/android_window_WindowInfosListener.cpp index 850755a62fa6b..55995df299b0d 100644 --- a/core/jni/android_window_WindowInfosListener.cpp +++ b/core/jni/android_window_WindowInfosListener.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -91,8 +92,7 @@ struct WindowInfosListener : public gui::WindowInfosListener { WindowInfosListener(JNIEnv* env, jobject listener) : mListener(env->NewWeakGlobalRef(listener)) {} - void onWindowInfosChanged(const std::vector& windowInfos, - const std::vector& displayInfos) override { + void onWindowInfosChanged(const gui::WindowInfosUpdate& update) override { JNIEnv* env = AndroidRuntime::getJNIEnv(); LOG_ALWAYS_FATAL_IF(env == nullptr, "Unable to retrieve JNIEnv in onWindowInfoChanged."); @@ -103,8 +103,10 @@ struct WindowInfosListener : public gui::WindowInfosListener { return; } - ScopedLocalRef jWindowHandlesArray(env, fromWindowInfos(env, windowInfos)); - ScopedLocalRef jDisplayInfoArray(env, fromDisplayInfos(env, displayInfos)); + ScopedLocalRef jWindowHandlesArray(env, + fromWindowInfos(env, update.windowInfos)); + ScopedLocalRef jDisplayInfoArray(env, + fromDisplayInfos(env, update.displayInfos)); env->CallVoidMethod(listener, gListenerClassInfo.onWindowInfosChanged, jWindowHandlesArray.get(), jDisplayInfoArray.get()); diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp index 88e3519631486..e21d6fb2fe14f 100644 --- a/libs/input/PointerController.cpp +++ b/libs/input/PointerController.cpp @@ -45,14 +45,13 @@ const ui::Transform kIdentityTransform; // --- PointerController::DisplayInfoListener --- void PointerController::DisplayInfoListener::onWindowInfosChanged( - const std::vector&, - const std::vector& displayInfos) { + const gui::WindowInfosUpdate& update) { std::scoped_lock lock(mLock); if (mPointerController == nullptr) return; // PointerController uses DisplayInfoListener's lock. base::ScopedLockAssertion assumeLocked(mPointerController->getLock()); - mPointerController->onDisplayInfosChangedLocked(displayInfos); + mPointerController->onDisplayInfosChangedLocked(update.displayInfos); } void PointerController::DisplayInfoListener::onPointerControllerDestroyed() { diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h index ca14b6e9bfdc4..62ee74331302c 100644 --- a/libs/input/PointerController.h +++ b/libs/input/PointerController.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -114,8 +115,7 @@ private: class DisplayInfoListener : public gui::WindowInfosListener { public: explicit DisplayInfoListener(PointerController* pc) : mPointerController(pc){}; - void onWindowInfosChanged(const std::vector&, - const std::vector&) override; + void onWindowInfosChanged(const gui::WindowInfosUpdate&) override; void onPointerControllerDestroyed(); // This lock is also used by PointerController. See PointerController::getLock(). diff --git a/libs/input/tests/PointerController_test.cpp b/libs/input/tests/PointerController_test.cpp index 2378d42793a1b..85747514aa035 100644 --- a/libs/input/tests/PointerController_test.cpp +++ b/libs/input/tests/PointerController_test.cpp @@ -343,7 +343,7 @@ TEST_F(PointerControllerWindowInfoListenerTest, localListenerCopy = registeredListener; } EXPECT_EQ(nullptr, registeredListener) << "WindowInfosListener was not unregistered"; - localListenerCopy->onWindowInfosChanged({}, {}); + localListenerCopy->onWindowInfosChanged({{}, {}, 0, 0}); } } // namespace android