Skip invisible windows in input list
To reduce traffic sent over binder and the number of copied objects in native code, we decide to remove windows from WindowInfosListener that are not visible because input doesn't need to know about the windows that aren't visible, and invisible windows don't affect the operation of other windows.
Fixes: 305254099
Test: adb shell su root dumpsys SurfaceFlinger
Test: atest LayerSnapshotTest
Flag: EXEMPT bugfix
Change-Id: I1ccc29565ee92277a703d16c07fd1141d6df6862
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index e6b8a26..06518fb 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -1551,6 +1551,9 @@
}
TEST_F(LayerSnapshotTest, NonVisibleLayerWithInput) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::
+ skip_invisible_windows_in_input,
+ false);
LayerHierarchyTestBase::createRootLayer(3);
setColor(3, {-1._hf, -1._hf, -1._hf});
UPDATE_AND_VERIFY(mSnapshotBuilder, STARTING_ZORDER);
@@ -1576,6 +1579,39 @@
EXPECT_TRUE(foundInputLayer);
}
+TEST_F(LayerSnapshotTest, NonVisibleLayerWithInputShouldNotBeIncluded) {
+ SET_FLAG_FOR_TEST(com::android::graphics::surfaceflinger::flags::
+ skip_invisible_windows_in_input,
+ true);
+ 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();
+ hideLayer(3);
+ mLifecycleManager.applyTransactions(transactions);
+
+ update(mSnapshotBuilder);
+
+ bool foundInputLayer = false;
+ mSnapshotBuilder.forEachInputSnapshot([&](const frontend::LayerSnapshot& snapshot) {
+ if (snapshot.uniqueSequence == 3) {
+ EXPECT_TRUE(
+ snapshot.inputInfo.inputConfig.test(gui::WindowInfo::InputConfig::NOT_VISIBLE));
+ EXPECT_FALSE(snapshot.isVisible);
+ foundInputLayer = true;
+ }
+ });
+ EXPECT_FALSE(foundInputLayer);
+}
+
TEST_F(LayerSnapshotTest, ForEachSnapshotsWithPredicate) {
std::vector<uint32_t> visitedUniqueSequences;
mSnapshotBuilder.forEachSnapshot(