Loading libs/gui/tests/EndToEndNativeInputTest.cpp +25 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <memory> #include <android/gui/BnWindowInfosReportedListener.h> #include <android/keycodes.h> #include <android/native_window.h> Loading Loading @@ -74,6 +75,26 @@ sp<IInputFlinger> getInputFlinger() { static const int LAYER_BASE = INT32_MAX - 10; static constexpr std::chrono::nanoseconds DISPATCHING_TIMEOUT = 5s; class SynchronousWindowInfosReportedListener : public gui::BnWindowInfosReportedListener { public: binder::Status onWindowInfosReported() override { std::lock_guard<std::mutex> lock{mMutex}; mWindowInfosReported = true; mConditionVariable.notify_one(); return binder::Status::ok(); } void wait() { std::unique_lock<std::mutex> lock{mMutex}; mConditionVariable.wait(lock, [&] { return mWindowInfosReported; }); } private: std::mutex mMutex; std::condition_variable mConditionVariable; bool mWindowInfosReported{false}; }; class InputSurface { public: InputSurface(const sp<SurfaceControl> &sc, int width, int height, bool noInputChannel = false) { Loading Loading @@ -264,7 +285,10 @@ public: t.setPosition(mSurfaceControl, x, y); t.setCrop(mSurfaceControl, crop); t.setAlpha(mSurfaceControl, 1); t.apply(true); auto reportedListener = sp<SynchronousWindowInfosReportedListener>::make(); t.addWindowInfosReportedListener(reportedListener); t.apply(); reportedListener->wait(); } void requestFocus(int displayId = ADISPLAY_ID_DEFAULT) { Loading Loading
libs/gui/tests/EndToEndNativeInputTest.cpp +25 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <memory> #include <android/gui/BnWindowInfosReportedListener.h> #include <android/keycodes.h> #include <android/native_window.h> Loading Loading @@ -74,6 +75,26 @@ sp<IInputFlinger> getInputFlinger() { static const int LAYER_BASE = INT32_MAX - 10; static constexpr std::chrono::nanoseconds DISPATCHING_TIMEOUT = 5s; class SynchronousWindowInfosReportedListener : public gui::BnWindowInfosReportedListener { public: binder::Status onWindowInfosReported() override { std::lock_guard<std::mutex> lock{mMutex}; mWindowInfosReported = true; mConditionVariable.notify_one(); return binder::Status::ok(); } void wait() { std::unique_lock<std::mutex> lock{mMutex}; mConditionVariable.wait(lock, [&] { return mWindowInfosReported; }); } private: std::mutex mMutex; std::condition_variable mConditionVariable; bool mWindowInfosReported{false}; }; class InputSurface { public: InputSurface(const sp<SurfaceControl> &sc, int width, int height, bool noInputChannel = false) { Loading Loading @@ -264,7 +285,10 @@ public: t.setPosition(mSurfaceControl, x, y); t.setCrop(mSurfaceControl, crop); t.setAlpha(mSurfaceControl, 1); t.apply(true); auto reportedListener = sp<SynchronousWindowInfosReportedListener>::make(); t.addWindowInfosReportedListener(reportedListener); t.apply(); reportedListener->wait(); } void requestFocus(int displayId = ADISPLAY_ID_DEFAULT) { Loading