Fix the input info missing for SurfaceView
Layer snapshots with buffers but without inputinfo were not sent to input or other window info listeners. This was due to a bug in how we checked to see if the layer needed an input info. FIx this to send SurfaceView layers to window info listeners.
Fixes: 365167765
Test: LayerSnapshotTest
Test: LayerLifecycleManagerTest
Flag: EXEMPT bugfix
Change-Id: I49e5d1e503af860a8324cc8b36589748ca2b7a25
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index ac15b92..ee605b7 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -279,24 +279,6 @@
snapshot.getDebugString().c_str());
}
-bool needsInputInfo(const LayerSnapshot& snapshot, const RequestedLayerState& requested) {
- if (requested.potentialCursor) {
- return false;
- }
-
- if (snapshot.inputInfo.token != nullptr) {
- return true;
- }
-
- if (snapshot.hasBufferOrSidebandStream()) {
- return true;
- }
-
- return requested.windowInfoHandle &&
- requested.windowInfoHandle->getInfo()->inputConfig.test(
- gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL);
-}
-
void updateMetadata(LayerSnapshot& snapshot, const RequestedLayerState& requested,
const LayerSnapshotBuilder::Args& args) {
snapshot.metadata.clear();
@@ -1162,7 +1144,7 @@
}
updateVisibility(snapshot, snapshot.isVisible);
- if (!needsInputInfo(snapshot, requested)) {
+ if (!requested.needsInputInfo()) {
return;
}
@@ -1172,7 +1154,7 @@
bool noValidDisplay = !displayInfoOpt.has_value();
auto displayInfo = displayInfoOpt.value_or(sDefaultInfo);
- if (!requested.windowInfoHandle) {
+ if (!requested.hasInputInfo()) {
snapshot.inputInfo.inputConfig = InputConfig::NO_INPUT_CHANNEL;
}
fillInputFrameInfo(snapshot.inputInfo, displayInfo.transform, snapshot);
diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
index 17d2610..5734ccf 100644
--- a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
+++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
@@ -62,6 +62,8 @@
metadata.merge(args.metadata);
changes |= RequestedLayerState::Changes::Metadata;
handleAlive = true;
+ // TODO: b/305254099 remove once we don't pass invisible windows to input
+ windowInfoHandle = nullptr;
if (parentId != UNASSIGNED_LAYER_ID) {
canBeRoot = false;
}
@@ -553,6 +555,24 @@
windowInfo->inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL);
}
+bool RequestedLayerState::needsInputInfo() const {
+ if (potentialCursor) {
+ return false;
+ }
+
+ if ((sidebandStream != nullptr) || (externalTexture != nullptr)) {
+ return true;
+ }
+
+ if (!windowInfoHandle) {
+ return false;
+ }
+
+ const auto windowInfo = windowInfoHandle->getInfo();
+ return windowInfo->token != nullptr ||
+ windowInfo->inputConfig.test(gui::WindowInfo::InputConfig::NO_INPUT_CHANNEL);
+}
+
bool RequestedLayerState::hasBlur() const {
return backgroundBlurRadius > 0 || blurRegions.size() > 0;
}
diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.h b/services/surfaceflinger/FrontEnd/RequestedLayerState.h
index 48b9640..1d96dff 100644
--- a/services/surfaceflinger/FrontEnd/RequestedLayerState.h
+++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.h
@@ -87,6 +87,7 @@
aidl::android::hardware::graphics::composer3::Composition getCompositionType() const;
bool hasValidRelativeParent() const;
bool hasInputInfo() const;
+ bool needsInputInfo() const;
bool hasBlur() const;
bool hasFrameUpdate() const;
bool hasReadyFrame() const;