summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/gui/Android.bp1
-rw-r--r--libs/gui/LayerState.cpp12
-rw-r--r--libs/gui/SurfaceComposerClient.cpp9
-rw-r--r--libs/gui/android/gui/TrustedOverlay.aidl45
-rw-r--r--libs/gui/include/gui/LayerState.h3
-rw-r--r--libs/gui/include/gui/SurfaceComposerClient.h2
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshot.h2
-rw-r--r--services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp19
-rw-r--r--services/surfaceflinger/FrontEnd/RequestedLayerState.cpp2
-rw-r--r--services/surfaceflinger/Layer.cpp2
-rw-r--r--services/surfaceflinger/LayerProtoHelper.cpp3
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp2
-rw-r--r--services/surfaceflinger/Tracing/TransactionProtoParser.cpp6
-rw-r--r--services/surfaceflinger/common/FlagManager.cpp2
-rw-r--r--services/surfaceflinger/common/include/common/FlagManager.h1
-rw-r--r--services/surfaceflinger/surfaceflinger_flags_new.aconfig13
-rw-r--r--services/surfaceflinger/tests/unittests/LayerHierarchyTest.h4
-rw-r--r--services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp83
18 files changed, 190 insertions, 21 deletions
diff --git a/libs/gui/Android.bp b/libs/gui/Android.bp
index 6c45746335..2547297ff8 100644
--- a/libs/gui/Android.bp
+++ b/libs/gui/Android.bp
@@ -87,6 +87,7 @@ filegroup {
"android/gui/DropInputMode.aidl",
"android/gui/StalledTransactionInfo.aidl",
"android/**/TouchOcclusionMode.aidl",
+ "android/gui/TrustedOverlay.aidl",
],
}
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 0a2879975b..c82bde9a83 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -89,7 +89,7 @@ layer_state_t::layer_state_t()
frameRateSelectionStrategy(ANATIVEWINDOW_FRAME_RATE_SELECTION_STRATEGY_PROPAGATE),
fixedTransformHint(ui::Transform::ROT_INVALID),
autoRefresh(false),
- isTrustedOverlay(false),
+ trustedOverlay(gui::TrustedOverlay::UNSET),
bufferCrop(Rect::INVALID_RECT),
destinationFrame(Rect::INVALID_RECT),
dropInputMode(gui::DropInputMode::NONE) {
@@ -179,7 +179,7 @@ status_t layer_state_t::write(Parcel& output) const
SAFE_PARCEL(output.write, stretchEffect);
SAFE_PARCEL(output.write, bufferCrop);
SAFE_PARCEL(output.write, destinationFrame);
- SAFE_PARCEL(output.writeBool, isTrustedOverlay);
+ SAFE_PARCEL(output.writeInt32, static_cast<uint32_t>(trustedOverlay));
SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
@@ -308,7 +308,9 @@ status_t layer_state_t::read(const Parcel& input)
SAFE_PARCEL(input.read, stretchEffect);
SAFE_PARCEL(input.read, bufferCrop);
SAFE_PARCEL(input.read, destinationFrame);
- SAFE_PARCEL(input.readBool, &isTrustedOverlay);
+ uint32_t trustedOverlayInt;
+ SAFE_PARCEL(input.readUint32, &trustedOverlayInt);
+ trustedOverlay = static_cast<gui::TrustedOverlay>(trustedOverlayInt);
uint32_t mode;
SAFE_PARCEL(input.readUint32, &mode);
@@ -674,7 +676,7 @@ void layer_state_t::merge(const layer_state_t& other) {
}
if (other.what & eTrustedOverlayChanged) {
what |= eTrustedOverlayChanged;
- isTrustedOverlay = other.isTrustedOverlay;
+ trustedOverlay = other.trustedOverlay;
}
if (other.what & eStretchChanged) {
what |= eStretchChanged;
@@ -779,7 +781,7 @@ uint64_t layer_state_t::diff(const layer_state_t& other) const {
CHECK_DIFF(diff, eFrameRateSelectionStrategyChanged, other, frameRateSelectionStrategy);
CHECK_DIFF(diff, eFixedTransformHintChanged, other, fixedTransformHint);
CHECK_DIFF(diff, eAutoRefreshChanged, other, autoRefresh);
- CHECK_DIFF(diff, eTrustedOverlayChanged, other, isTrustedOverlay);
+ CHECK_DIFF(diff, eTrustedOverlayChanged, other, trustedOverlay);
CHECK_DIFF(diff, eStretchChanged, other, stretchEffect);
CHECK_DIFF(diff, eBufferCropChanged, other, bufferCrop);
CHECK_DIFF(diff, eDestinationFrameChanged, other, destinationFrame);
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 7aaaebbc8e..e0f1b03e26 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -2175,6 +2175,13 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setAutoR
SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrustedOverlay(
const sp<SurfaceControl>& sc, bool isTrustedOverlay) {
+ return setTrustedOverlay(sc,
+ isTrustedOverlay ? gui::TrustedOverlay::ENABLED
+ : gui::TrustedOverlay::UNSET);
+}
+
+SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrustedOverlay(
+ const sp<SurfaceControl>& sc, gui::TrustedOverlay trustedOverlay) {
layer_state_t* s = getLayerState(sc);
if (!s) {
mStatus = BAD_INDEX;
@@ -2182,7 +2189,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setTrust
}
s->what |= layer_state_t::eTrustedOverlayChanged;
- s->isTrustedOverlay = isTrustedOverlay;
+ s->trustedOverlay = trustedOverlay;
return *this;
}
diff --git a/libs/gui/android/gui/TrustedOverlay.aidl b/libs/gui/android/gui/TrustedOverlay.aidl
new file mode 100644
index 0000000000..06fb5f0bd5
--- /dev/null
+++ b/libs/gui/android/gui/TrustedOverlay.aidl
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2024, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.gui;
+
+
+/**
+ * Trusted overlay state prevents layers from being considered as obscuring for
+ * input occlusion detection purposes.
+ *
+ * @hide
+ */
+@Backing(type="int")
+enum TrustedOverlay {
+ /**
+ * The default, layer will inherit the state from its parents. If the parent state is also
+ * unset, the layer will be considered as untrusted.
+ */
+ UNSET,
+
+ /**
+ * Treats this layer and all its children as an untrusted overlay. This will override any
+ * state set by its parent layers.
+ */
+ DISABLED,
+
+ /**
+ * Treats this layer and all its children as a trusted overlay unless the child layer
+ * explicitly disables its trusted state.
+ */
+ ENABLED
+}
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index ebdf2326d6..849f66718a 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -30,6 +30,7 @@
#include <android/gui/DropInputMode.h>
#include <android/gui/FocusRequest.h>
+#include <android/gui/TrustedOverlay.h>
#include <ftl/flags.h>
#include <gui/DisplayCaptureArgs.h>
@@ -388,7 +389,7 @@ struct layer_state_t {
// An inherited state that indicates that this surface control and its children
// should be trusted for input occlusion detection purposes
- bool isTrustedOverlay;
+ gui::TrustedOverlay trustedOverlay;
// Stretch effect to be applied to this layer
StretchEffect stretchEffect;
diff --git a/libs/gui/include/gui/SurfaceComposerClient.h b/libs/gui/include/gui/SurfaceComposerClient.h
index 987efe01ba..50f2d17f51 100644
--- a/libs/gui/include/gui/SurfaceComposerClient.h
+++ b/libs/gui/include/gui/SurfaceComposerClient.h
@@ -719,6 +719,8 @@ public:
// Sets that this surface control and its children are trusted overlays for input
Transaction& setTrustedOverlay(const sp<SurfaceControl>& sc, bool isTrustedOverlay);
+ Transaction& setTrustedOverlay(const sp<SurfaceControl>& sc,
+ gui::TrustedOverlay trustedOverlay);
// Queues up transactions using this token in SurfaceFlinger. By default, all transactions
// from a client are placed on the same queue. This can be used to prevent multiple
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshot.h b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
index eef8dff94c..398e64a4f1 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshot.h
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshot.h
@@ -84,7 +84,7 @@ struct LayerSnapshot : public compositionengine::LayerFECompositionState {
// is a mirror root
bool ignoreLocalTransform;
gui::DropInputMode dropInputMode;
- bool isTrustedOverlay;
+ gui::TrustedOverlay trustedOverlay;
gui::GameMode gameMode;
scheduler::LayerInfo::FrameRate frameRate;
scheduler::LayerInfo::FrameRate inheritedFrameRate;
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index f10bb33a2f..87706d8491 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -22,6 +22,7 @@
#include <numeric>
#include <optional>
+#include <common/FlagManager.h>
#include <ftl/small_map.h>
#include <gui/TraceUtils.h>
#include <ui/DisplayMap.h>
@@ -373,7 +374,7 @@ LayerSnapshot LayerSnapshotBuilder::getRootSnapshot() {
snapshot.relativeLayerMetadata.mMap.clear();
snapshot.inputInfo.touchOcclusionMode = gui::TouchOcclusionMode::BLOCK_UNTRUSTED;
snapshot.dropInputMode = gui::DropInputMode::NONE;
- snapshot.isTrustedOverlay = false;
+ snapshot.trustedOverlay = gui::TrustedOverlay::UNSET;
snapshot.gameMode = gui::GameMode::Unsupported;
snapshot.frameRate = {};
snapshot.fixedTransformHint = ui::Transform::ROT_INVALID;
@@ -750,7 +751,19 @@ void LayerSnapshotBuilder::updateSnapshot(LayerSnapshot& snapshot, const Args& a
}
if (forceUpdate || snapshot.clientChanges & layer_state_t::eTrustedOverlayChanged) {
- snapshot.isTrustedOverlay = parentSnapshot.isTrustedOverlay || requested.isTrustedOverlay;
+ switch (requested.trustedOverlay) {
+ case gui::TrustedOverlay::UNSET:
+ snapshot.trustedOverlay = parentSnapshot.trustedOverlay;
+ break;
+ case gui::TrustedOverlay::DISABLED:
+ snapshot.trustedOverlay = FlagManager::getInstance().override_trusted_overlay()
+ ? requested.trustedOverlay
+ : parentSnapshot.trustedOverlay;
+ break;
+ case gui::TrustedOverlay::ENABLED:
+ snapshot.trustedOverlay = requested.trustedOverlay;
+ break;
+ }
}
if (snapshot.isHiddenByPolicyFromParent &&
@@ -1125,7 +1138,7 @@ void LayerSnapshotBuilder::updateInput(LayerSnapshot& snapshot,
// Inherit the trusted state from the parent hierarchy, but don't clobber the trusted state
// if it was set by WM for a known system overlay
- if (snapshot.isTrustedOverlay) {
+ if (snapshot.trustedOverlay == gui::TrustedOverlay::ENABLED) {
snapshot.inputInfo.inputConfig |= InputConfig::TRUSTED_OVERLAY;
}
diff --git a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
index f5e5b0233e..3cf45a7fbb 100644
--- a/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
+++ b/services/surfaceflinger/FrontEnd/RequestedLayerState.cpp
@@ -119,7 +119,7 @@ RequestedLayerState::RequestedLayerState(const LayerCreationArgs& args)
shadowRadius = 0.f;
fixedTransformHint = ui::Transform::ROT_INVALID;
destinationFrame.makeInvalid();
- isTrustedOverlay = false;
+ trustedOverlay = gui::TrustedOverlay::UNSET;
dropInputMode = gui::DropInputMode::NONE;
dimmingEnabled = true;
defaultFrameRateCompatibility = static_cast<int8_t>(scheduler::FrameRateCompatibility::Default);
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 363b35c4f3..6b97e2f799 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -3902,7 +3902,7 @@ bool Layer::isSimpleBufferUpdate(const layer_state_t& s) const {
}
if (s.what & layer_state_t::eTrustedOverlayChanged) {
- if (mDrawingState.isTrustedOverlay != s.isTrustedOverlay) {
+ if (mDrawingState.isTrustedOverlay != (s.trustedOverlay == gui::TrustedOverlay::ENABLED)) {
ATRACE_FORMAT_INSTANT("%s: false [eTrustedOverlayChanged changed]", __func__);
return false;
}
diff --git a/services/surfaceflinger/LayerProtoHelper.cpp b/services/surfaceflinger/LayerProtoHelper.cpp
index 753886ad24..496033b749 100644
--- a/services/surfaceflinger/LayerProtoHelper.cpp
+++ b/services/surfaceflinger/LayerProtoHelper.cpp
@@ -382,7 +382,8 @@ void LayerProtoHelper::writeSnapshotToProto(perfetto::protos::LayerProto* layerI
layerInfo->set_corner_radius(
(snapshot.roundedCorner.radius.x + snapshot.roundedCorner.radius.y) / 2.0);
layerInfo->set_background_blur_radius(snapshot.backgroundBlurRadius);
- layerInfo->set_is_trusted_overlay(snapshot.isTrustedOverlay);
+ layerInfo->set_is_trusted_overlay(snapshot.trustedOverlay == gui::TrustedOverlay::ENABLED);
+ // TODO(b/339701674) update protos
LayerProtoHelper::writeToProtoDeprecated(transform, layerInfo->mutable_transform());
LayerProtoHelper::writePositionToProto(transform.tx(), transform.ty(),
[&]() { return layerInfo->mutable_position(); });
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 28d80188ff..059edad467 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5700,7 +5700,7 @@ uint32_t SurfaceFlinger::setClientStateLocked(const FrameTimelineInfo& frameTime
if (layer->setHdrMetadata(s.hdrMetadata)) flags |= eTraversalNeeded;
}
if (what & layer_state_t::eTrustedOverlayChanged) {
- if (layer->setTrustedOverlay(s.isTrustedOverlay)) {
+ if (layer->setTrustedOverlay(s.trustedOverlay == gui::TrustedOverlay::ENABLED)) {
flags |= eTraversalNeeded;
}
}
diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
index b3e9fab261..fc496b2982 100644
--- a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
+++ b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
@@ -247,7 +247,8 @@ perfetto::protos::LayerState TransactionProtoParser::toProto(
proto.set_auto_refresh(layer.autoRefresh);
}
if (layer.what & layer_state_t::eTrustedOverlayChanged) {
- proto.set_is_trusted_overlay(layer.isTrustedOverlay);
+ proto.set_is_trusted_overlay(layer.trustedOverlay == gui::TrustedOverlay::ENABLED);
+ // TODO(b/339701674) update protos
}
if (layer.what & layer_state_t::eBufferCropChanged) {
LayerProtoHelper::writeToProto(layer.bufferCrop, proto.mutable_buffer_crop());
@@ -515,7 +516,8 @@ void TransactionProtoParser::fromProto(const perfetto::protos::LayerState& proto
layer.autoRefresh = proto.auto_refresh();
}
if (proto.what() & layer_state_t::eTrustedOverlayChanged) {
- layer.isTrustedOverlay = proto.is_trusted_overlay();
+ layer.trustedOverlay = proto.is_trusted_overlay() ? gui::TrustedOverlay::ENABLED
+ : gui::TrustedOverlay::UNSET;
}
if (proto.what() & layer_state_t::eBufferCropChanged) {
LayerProtoHelper::readFromProto(proto.buffer_crop(), layer.bufferCrop);
diff --git a/services/surfaceflinger/common/FlagManager.cpp b/services/surfaceflinger/common/FlagManager.cpp
index 121629fd10..57b170fba3 100644
--- a/services/surfaceflinger/common/FlagManager.cpp
+++ b/services/surfaceflinger/common/FlagManager.cpp
@@ -147,6 +147,7 @@ void FlagManager::dump(std::string& result) const {
DUMP_READ_ONLY_FLAG(detached_mirror);
DUMP_READ_ONLY_FLAG(commit_not_composited);
DUMP_READ_ONLY_FLAG(local_tonemap_screenshots);
+ DUMP_READ_ONLY_FLAG(override_trusted_overlay);
#undef DUMP_READ_ONLY_FLAG
#undef DUMP_SERVER_FLAG
@@ -244,6 +245,7 @@ FLAG_MANAGER_READ_ONLY_FLAG(allow_n_vsyncs_in_targeter, "");
FLAG_MANAGER_READ_ONLY_FLAG(detached_mirror, "");
FLAG_MANAGER_READ_ONLY_FLAG(commit_not_composited, "");
FLAG_MANAGER_READ_ONLY_FLAG(local_tonemap_screenshots, "debug.sf.local_tonemap_screenshots");
+FLAG_MANAGER_READ_ONLY_FLAG(override_trusted_overlay, "");
/// Trunk stable server flags ///
FLAG_MANAGER_SERVER_FLAG(refresh_rate_overlay_on_external_display, "")
diff --git a/services/surfaceflinger/common/include/common/FlagManager.h b/services/surfaceflinger/common/include/common/FlagManager.h
index 4cf4453980..9517ff7efb 100644
--- a/services/surfaceflinger/common/include/common/FlagManager.h
+++ b/services/surfaceflinger/common/include/common/FlagManager.h
@@ -86,6 +86,7 @@ public:
bool detached_mirror() const;
bool commit_not_composited() const;
bool local_tonemap_screenshots() const;
+ bool override_trusted_overlay() const;
protected:
// overridden for unit tests
diff --git a/services/surfaceflinger/surfaceflinger_flags_new.aconfig b/services/surfaceflinger/surfaceflinger_flags_new.aconfig
index 5b94f07dff..02d8819785 100644
--- a/services/surfaceflinger/surfaceflinger_flags_new.aconfig
+++ b/services/surfaceflinger/surfaceflinger_flags_new.aconfig
@@ -52,7 +52,7 @@ flag {
metadata {
purpose: PURPOSE_BUGFIX
}
-} # deprecate_vsync_sf
+} # detached_mirror
flag {
name: "frame_rate_category_mrr"
@@ -84,6 +84,17 @@ flag {
is_fixed_read_only: true
} # local_tonemap_screenshots
+ flag {
+ name: "override_trusted_overlay"
+ namespace: "window_surfaces"
+ description: "Allow child to disable trusted overlay set by a parent layer"
+ bug: "339701674"
+ is_fixed_read_only: true
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+} # override_trusted_overlay
+
flag {
name: "vrr_bugfix_24q4"
namespace: "core_graphics"
diff --git a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h
index fd15eef54b..8b3303c809 100644
--- a/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h
+++ b/services/surfaceflinger/tests/unittests/LayerHierarchyTest.h
@@ -494,14 +494,14 @@ protected:
mLifecycleManager.applyTransactions(transactions);
}
- void setTrustedOverlay(uint32_t id, bool isTrustedOverlay) {
+ void setTrustedOverlay(uint32_t id, gui::TrustedOverlay trustedOverlay) {
std::vector<TransactionState> transactions;
transactions.emplace_back();
transactions.back().states.push_back({});
transactions.back().states.front().state.what = layer_state_t::eTrustedOverlayChanged;
transactions.back().states.front().layerId = id;
- transactions.back().states.front().state.isTrustedOverlay = isTrustedOverlay;
+ transactions.back().states.front().state.trustedOverlay = trustedOverlay;
mLifecycleManager.applyTransactions(transactions);
}
diff --git a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
index ce4d798dd8..8acabe3b54 100644
--- a/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
+++ b/services/surfaceflinger/tests/unittests/LayerSnapshotTest.cpp
@@ -1247,7 +1247,7 @@ TEST_F(LayerSnapshotTest, setShadowRadius) {
TEST_F(LayerSnapshotTest, setTrustedOverlayForNonVisibleInput) {
hideLayer(1);
- setTrustedOverlay(1, true);
+ setTrustedOverlay(1, gui::TrustedOverlay::ENABLED);
Region touch{Rect{0, 0, 1000, 1000}};
setTouchableRegion(1, touch);
@@ -1439,4 +1439,85 @@ TEST_F(LayerSnapshotTest, mirroredHierarchyIgnoresLocalTransform) {
EXPECT_EQ(getSnapshot({.id = 111})->geomLayerTransform.ty(), 220);
}
+TEST_F(LayerSnapshotTest, overrideParentTrustedOverlayState) {
+ SET_FLAG_FOR_TEST(flags::override_trusted_overlay, true);
+ hideLayer(1);
+ setTrustedOverlay(1, gui::TrustedOverlay::ENABLED);
+
+ Region touch{Rect{0, 0, 1000, 1000}};
+ setTouchableRegion(1, touch);
+ setTouchableRegion(11, touch);
+ setTouchableRegion(111, touch);
+
+ UPDATE_AND_VERIFY(mSnapshotBuilder, {2});
+ EXPECT_TRUE(getSnapshot(1)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(11)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(111)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+
+ // disable trusted overlay and override parent state
+ setTrustedOverlay(11, gui::TrustedOverlay::DISABLED);
+ UPDATE_AND_VERIFY(mSnapshotBuilder, {2});
+ EXPECT_TRUE(getSnapshot(1)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_FALSE(getSnapshot(11)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_FALSE(getSnapshot(111)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+
+ // unset state and go back to default behavior of inheriting
+ // state
+ setTrustedOverlay(11, gui::TrustedOverlay::UNSET);
+ UPDATE_AND_VERIFY(mSnapshotBuilder, {2});
+ EXPECT_TRUE(getSnapshot(1)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(11)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(111)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+}
+
+TEST_F(LayerSnapshotTest, doNotOverrideParentTrustedOverlayState) {
+ SET_FLAG_FOR_TEST(flags::override_trusted_overlay, false);
+ hideLayer(1);
+ setTrustedOverlay(1, gui::TrustedOverlay::ENABLED);
+
+ Region touch{Rect{0, 0, 1000, 1000}};
+ setTouchableRegion(1, touch);
+ setTouchableRegion(11, touch);
+ setTouchableRegion(111, touch);
+
+ UPDATE_AND_VERIFY(mSnapshotBuilder, {2});
+ EXPECT_TRUE(getSnapshot(1)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(11)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(111)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+
+ // disable trusted overlay but flag is disabled so this behaves
+ // as UNSET
+ setTrustedOverlay(11, gui::TrustedOverlay::DISABLED);
+ UPDATE_AND_VERIFY(mSnapshotBuilder, {2});
+ EXPECT_TRUE(getSnapshot(1)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(11)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(111)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+
+ // unset state and go back to default behavior of inheriting
+ // state
+ setTrustedOverlay(11, gui::TrustedOverlay::UNSET);
+ UPDATE_AND_VERIFY(mSnapshotBuilder, {2});
+ EXPECT_TRUE(getSnapshot(1)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(11)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+ EXPECT_TRUE(getSnapshot(111)->inputInfo.inputConfig.test(
+ gui::WindowInfo::InputConfig::TRUSTED_OVERLAY));
+}
+
} // namespace android::surfaceflinger::frontend