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

Commit 8c285982 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

SF: Enforce that layers with invalid input bounds are not focusable

Bug: 162194035
Test: atest libgui_test
Change-Id: Ic561e8b3e52faae28888ef3d323583e09aa278c0
parent 6fa425a8
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -987,6 +987,31 @@ TEST_F(InputSurfacesTest, drop_input_policy) {
    EXPECT_EQ(surface->consumeEvent(100), nullptr);
}

TEST_F(InputSurfacesTest, layer_with_empty_crop_cannot_be_focused) {
    std::unique_ptr<InputSurface> bufferSurface =
            InputSurface::makeBufferInputSurface(mComposerClient, 100, 100);

    bufferSurface->showAt(50, 50, Rect::EMPTY_RECT);

    bufferSurface->requestFocus();
    EXPECT_EQ(bufferSurface->consumeEvent(100), nullptr);

    bufferSurface->showAt(50, 50, Rect::INVALID_RECT);

    bufferSurface->requestFocus();
    EXPECT_EQ(bufferSurface->consumeEvent(100), nullptr);
}

TEST_F(InputSurfacesTest, layer_with_valid_crop_can_be_focused) {
    std::unique_ptr<InputSurface> bufferSurface =
            InputSurface::makeBufferInputSurface(mComposerClient, 100, 100);

    bufferSurface->showAt(50, 50, Rect{0, 0, 100, 100});

    bufferSurface->requestFocus();
    bufferSurface->assertFocusChange(true);
}

/**
 * If a cropped layer's touchable region is replaced with a null crop, it should receive input in
 * its own crop.
+1 −0
Original line number Diff line number Diff line
@@ -2170,6 +2170,7 @@ void Layer::fillInputFrameInfo(WindowInfo& info, const ui::Transform& displayTra
    Rect layerBounds = getInputBounds();
    if (!layerBounds.isValid()) {
        info.flags = WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::NOT_FOCUSABLE;
        info.focusable = false;
        info.touchableRegion.clear();
        // A layer could have invalid input bounds and still expect to receive touch input if it has
        // replaceTouchableRegionWithCrop. For that case, the input transform needs to be calculated