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

Commit 92c7d8c5 authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Ensure non visible layers that have input are traversed for input

If a Layer wasn't visible and nothing else changed that vsync, the
sortSnapshotsByZ function would return early and not update the z
ordered list to include the non visible input layer. Since layers can
have input even if they have no visible content, we need to include them

Test: LayerSnapshotTest#NonVisibleLayerWithInput
Bug: 320370937
Change-Id: I89dd0cdefbd0948f40089b6f7f321ad84b4ad357
parent 22c7b9bc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -587,8 +587,8 @@ LayerSnapshot* LayerSnapshotBuilder::createSnapshot(const LayerHierarchy::Traver
bool LayerSnapshotBuilder::sortSnapshotsByZ(const Args& args) {
    if (!mResortSnapshots && args.forceUpdate == ForceUpdateFlags::NONE &&
        !args.layerLifecycleManager.getGlobalChanges().any(
                RequestedLayerState::Changes::Hierarchy |
                RequestedLayerState::Changes::Visibility)) {
                RequestedLayerState::Changes::Hierarchy | RequestedLayerState::Changes::Visibility |
                RequestedLayerState::Changes::Input)) {
        // We are not force updating and there are no hierarchy or visibility changes. Avoid sorting
        // the snapshots.
        return false;
+38 −0
Original line number Diff line number Diff line
@@ -64,6 +64,18 @@ protected:
        actualBuilder.update(args);
    }

    void update(LayerSnapshotBuilder& actualBuilder) {
        LayerSnapshotBuilder::Args args{.root = mHierarchyBuilder.getHierarchy(),
                                        .layerLifecycleManager = mLifecycleManager,
                                        .includeMetadata = false,
                                        .displays = mFrontEndDisplayInfos,
                                        .globalShadowSettings = globalShadowSettings,
                                        .supportsBlur = true,
                                        .supportedLayerGenericMetadata = {},
                                        .genericLayerMetadataKeyMap = {}};
        update(actualBuilder, args);
    }

    void updateAndVerify(LayerSnapshotBuilder& actualBuilder, bool hasDisplayChanges,
                         const std::vector<uint32_t> expectedVisibleLayerIdsInZOrder) {
        LayerSnapshotBuilder::Args args{.root = mHierarchyBuilder.getHierarchy(),
@@ -1199,4 +1211,30 @@ TEST_F(LayerSnapshotTest, propagateDropInputMode) {
    EXPECT_EQ(getSnapshot(11)->dropInputMode, gui::DropInputMode::ALL);
}

TEST_F(LayerSnapshotTest, NonVisibleLayerWithInput) {
    LayerHierarchyTestBase::createRootLayer(3);
    setColor(3, {-1._hf, -1._hf, -1._hf});
    UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);

    std::vector<TransactionState> transactions;
    transactions.emplace_back();
    transactions.back().states.push_back({});
    transactions.back().states.front().state.what = layer_state_t::eInputInfoChanged;
    transactions.back().states.front().layerId = 3;
    transactions.back().states.front().state.windowInfoHandle = sp<gui::WindowInfoHandle>::make();
    auto inputInfo = transactions.back().states.front().state.windowInfoHandle->editInfo();
    inputInfo->token = sp<BBinder>::make();
    mLifecycleManager.applyTransactions(transactions);

    update(mSnapshotBuilder);

    bool foundInputLayer = false;
    mSnapshotBuilder.forEachInputSnapshot([&](const frontend::LayerSnapshot& snapshot) {
        if (snapshot.uniqueSequence == 3) {
            foundInputLayer = true;
        }
    });
    EXPECT_TRUE(foundInputLayer);
}

} // namespace android::surfaceflinger::frontend