Loading libs/gui/tests/EndToEndNativeInputTest.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,15 @@ public: return std::make_unique<InputSurface>(surfaceControl, width, height); } static std::unique_ptr<InputSurface> makeCursorInputSurface( const sp<SurfaceComposerClient> &scc, int width, int height) { sp<SurfaceControl> surfaceControl = scc->createSurface(String8("Test Cursor Surface"), 0 /* bufHeight */, 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eCursorWindow); return std::make_unique<InputSurface>(surfaceControl, width, height); } InputEvent* consumeEvent() { waitForEventAvailable(); Loading Loading @@ -134,12 +143,14 @@ public: EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); EXPECT_EQ(x, mev->getX(0)); EXPECT_EQ(y, mev->getY(0)); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); ev = consumeEvent(); ASSERT_NE(ev, nullptr); ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); mev = static_cast<MotionEvent*>(ev); EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); } ~InputSurface() { Loading Loading @@ -537,5 +548,18 @@ TEST_F(InputSurfacesTest, input_respects_outscreen) { injectTap(0, 0); surface->expectTap(1, 1); } TEST_F(InputSurfacesTest, input_ignores_cursor_layer) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); std::unique_ptr<InputSurface> cursorSurface = InputSurface::makeCursorInputSurface(mComposerClient, 10, 10); surface->showAt(10, 10); surface->assertFocusChange(true); cursorSurface->showAt(10, 10); injectTap(11, 11); surface->expectTap(1, 1); } } } services/surfaceflinger/BufferLayer.h +2 −2 Original line number Diff line number Diff line Loading @@ -148,10 +148,10 @@ private: virtual status_t updateActiveBuffer() = 0; virtual status_t updateFrameNumber(nsecs_t latchTime) = 0; // We generate InputWindowHandles for all buffered layers regardless of whether they // We generate InputWindowHandles for all non-cursor buffered layers regardless of whether they // have an InputChannel. This is to enable the InputDispatcher to do PID based occlusion // detection. bool needsInputInfo() const override { return true; } bool needsInputInfo() const override { return !mPotentialCursor; } protected: struct BufferInfo { Loading Loading
libs/gui/tests/EndToEndNativeInputTest.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,15 @@ public: return std::make_unique<InputSurface>(surfaceControl, width, height); } static std::unique_ptr<InputSurface> makeCursorInputSurface( const sp<SurfaceComposerClient> &scc, int width, int height) { sp<SurfaceControl> surfaceControl = scc->createSurface(String8("Test Cursor Surface"), 0 /* bufHeight */, 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888, ISurfaceComposerClient::eCursorWindow); return std::make_unique<InputSurface>(surfaceControl, width, height); } InputEvent* consumeEvent() { waitForEventAvailable(); Loading Loading @@ -134,12 +143,14 @@ public: EXPECT_EQ(AMOTION_EVENT_ACTION_DOWN, mev->getAction()); EXPECT_EQ(x, mev->getX(0)); EXPECT_EQ(y, mev->getY(0)); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); ev = consumeEvent(); ASSERT_NE(ev, nullptr); ASSERT_EQ(AINPUT_EVENT_TYPE_MOTION, ev->getType()); mev = static_cast<MotionEvent*>(ev); EXPECT_EQ(AMOTION_EVENT_ACTION_UP, mev->getAction()); EXPECT_EQ(0, mev->getFlags() & VERIFIED_MOTION_EVENT_FLAGS); } ~InputSurface() { Loading Loading @@ -537,5 +548,18 @@ TEST_F(InputSurfacesTest, input_respects_outscreen) { injectTap(0, 0); surface->expectTap(1, 1); } TEST_F(InputSurfacesTest, input_ignores_cursor_layer) { std::unique_ptr<InputSurface> surface = makeSurface(100, 100); std::unique_ptr<InputSurface> cursorSurface = InputSurface::makeCursorInputSurface(mComposerClient, 10, 10); surface->showAt(10, 10); surface->assertFocusChange(true); cursorSurface->showAt(10, 10); injectTap(11, 11); surface->expectTap(1, 1); } } }
services/surfaceflinger/BufferLayer.h +2 −2 Original line number Diff line number Diff line Loading @@ -148,10 +148,10 @@ private: virtual status_t updateActiveBuffer() = 0; virtual status_t updateFrameNumber(nsecs_t latchTime) = 0; // We generate InputWindowHandles for all buffered layers regardless of whether they // We generate InputWindowHandles for all non-cursor buffered layers regardless of whether they // have an InputChannel. This is to enable the InputDispatcher to do PID based occlusion // detection. bool needsInputInfo() const override { return true; } bool needsInputInfo() const override { return !mPotentialCursor; } protected: struct BufferInfo { Loading