summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-12-06 03:15:28 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2022-12-06 03:15:28 +0000
commitffcf3f0627094c188c0a999473e0b97582a898ec (patch)
tree514389eb8024e1318c177ef0cdcaa184f6762c51
parente4f1fd5622288d039b571b4c3202a7f1e530f97e (diff)
parent41df588cf438b8a5e63e80b702d752f1d27c6004 (diff)
downloadnative-android12L-gsi.tar.gz
Merge "Merge cherrypicks of [18122622, 20123803] into sc-v2-platform-release. am: a57ba775f4" into android12L-gsiandroid12L-gsi
-rw-r--r--libs/gui/tests/EndToEndNativeInputTest.cpp91
-rw-r--r--services/surfaceflinger/Layer.cpp8
2 files changed, 64 insertions, 35 deletions
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index 5daef0df28..cdd8ea65c7 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -74,16 +74,39 @@ static constexpr std::chrono::nanoseconds DISPATCHING_TIMEOUT = 5s;
class InputSurface {
public:
- InputSurface(const sp<SurfaceControl> &sc, int width, int height) {
+ InputSurface(const sp<SurfaceControl> &sc, int width, int height, bool noInputChannel = false) {
mSurfaceControl = sc;
mInputFlinger = getInputFlinger();
- mClientChannel = std::make_shared<InputChannel>();
- mInputFlinger->createInputChannel("testchannels", mClientChannel.get());
+ if (noInputChannel) {
+ mInputInfo.inputFeatures = WindowInfo::Feature::NO_INPUT_CHANNEL;
+ } else {
+ mClientChannel = std::make_shared<InputChannel>();
+ mInputFlinger->createInputChannel("testchannels", mClientChannel.get());
+ mInputInfo.token = mClientChannel->getConnectionToken();
+ mInputConsumer = new InputConsumer(mClientChannel);
+ }
- populateInputInfo(width, height);
+ mInputInfo.name = "Test info";
+ mInputInfo.dispatchingTimeout = 5s;
+ mInputInfo.globalScaleFactor = 1.0;
+ mInputInfo.flags = WindowInfo::Flag::NOT_TOUCH_MODAL;
+ mInputInfo.type = WindowInfo::Type::BASE_APPLICATION;
+ mInputInfo.focusable = true;
+ mInputInfo.hasWallpaper = false;
+ mInputInfo.paused = false;
+ // TODO: Fill in from SF?
+ mInputInfo.ownerPid = 11111;
+ mInputInfo.ownerUid = 11111;
+ mInputInfo.displayId = 0;
+ mInputInfo.touchableRegion.orSelf(Rect(0, 0, width, height));
- mInputConsumer = new InputConsumer(mClientChannel);
+ InputApplicationInfo aInfo;
+ aInfo.token = new BBinder();
+ aInfo.name = "Test app info";
+ aInfo.dispatchingTimeoutMillis =
+ std::chrono::duration_cast<std::chrono::milliseconds>(DISPATCHING_TIMEOUT).count();
+ mInputInfo.applicationInfo = aInfo;
}
static std::unique_ptr<InputSurface> makeColorInputSurface(const sp<SurfaceComposerClient> &scc,
@@ -112,6 +135,16 @@ public:
return std::make_unique<InputSurface>(surfaceControl, width, height);
}
+ static std::unique_ptr<InputSurface> makeContainerInputSurfaceNoInputChannel(
+ const sp<SurfaceComposerClient> &scc, int width, int height) {
+ sp<SurfaceControl> surfaceControl =
+ scc->createSurface(String8("Test Container Surface"), 0 /* bufHeight */,
+ 0 /* bufWidth */, PIXEL_FORMAT_RGBA_8888,
+ ISurfaceComposerClient::eFXSurfaceContainer);
+ return std::make_unique<InputSurface>(surfaceControl, width, height,
+ true /* noInputChannel */);
+ }
+
static std::unique_ptr<InputSurface> makeCursorInputSurface(
const sp<SurfaceComposerClient> &scc, int width, int height) {
sp<SurfaceControl> surfaceControl =
@@ -198,7 +231,9 @@ public:
}
virtual ~InputSurface() {
- mInputFlinger->removeInputChannel(mClientChannel->getConnectionToken());
+ if (mClientChannel) {
+ mInputFlinger->removeInputChannel(mClientChannel->getConnectionToken());
+ }
}
virtual void doTransaction(
@@ -242,32 +277,6 @@ private:
poll(&fd, 1, timeoutMs);
}
- void populateInputInfo(int width, int height) {
- mInputInfo.token = mClientChannel->getConnectionToken();
- mInputInfo.name = "Test info";
- mInputInfo.flags = WindowInfo::Flag::NOT_TOUCH_MODAL;
- mInputInfo.type = WindowInfo::Type::BASE_APPLICATION;
- mInputInfo.dispatchingTimeout = 5s;
- mInputInfo.globalScaleFactor = 1.0;
- mInputInfo.focusable = true;
- mInputInfo.hasWallpaper = false;
- mInputInfo.paused = false;
-
- mInputInfo.touchableRegion.orSelf(Rect(0, 0, width, height));
-
- // TODO: Fill in from SF?
- mInputInfo.ownerPid = 11111;
- mInputInfo.ownerUid = 11111;
- mInputInfo.displayId = 0;
-
- InputApplicationInfo aInfo;
- aInfo.token = new BBinder();
- aInfo.name = "Test app info";
- aInfo.dispatchingTimeoutMillis =
- std::chrono::duration_cast<std::chrono::milliseconds>(DISPATCHING_TIMEOUT).count();
-
- mInputInfo.applicationInfo = aInfo;
- }
public:
sp<SurfaceControl> mSurfaceControl;
std::shared_ptr<InputChannel> mClientChannel;
@@ -960,4 +969,22 @@ TEST_F(InputSurfacesTest, drop_input_policy) {
injectKey(AKEYCODE_V);
EXPECT_EQ(surface->consumeEvent(100), nullptr);
}
+
+TEST_F(InputSurfacesTest, child_container_with_no_input_channel_blocks_parent) {
+ std::unique_ptr<InputSurface> parent = makeSurface(100, 100);
+
+ parent->showAt(100, 100);
+ injectTap(101, 101);
+ parent->expectTap(1, 1);
+
+ std::unique_ptr<InputSurface> childContainerSurface =
+ InputSurface::makeContainerInputSurfaceNoInputChannel(mComposerClient, 100, 100);
+ childContainerSurface->showAt(0, 0);
+ childContainerSurface->doTransaction(
+ [&](auto &t, auto &sc) { t.reparent(sc, parent->mSurfaceControl); });
+ injectTap(101, 101);
+
+ EXPECT_EQ(parent->consumeEvent(100), nullptr);
+}
+
} // namespace android::test
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 4d804fa670..6d26c884f0 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -135,6 +135,7 @@ Layer::Layer(const LayerCreationArgs& args)
mDrawingState.postTime = -1;
mDrawingState.destinationFrame.makeInvalid();
mDrawingState.dropInputMode = gui::DropInputMode::NONE;
+ mDrawingState.isTrustedOverlay = false;
if (args.flags & ISurfaceComposerClient::eNoColorFill) {
// Set an invalid color so there is no color fill.
@@ -2164,7 +2165,7 @@ void Layer::writeToProtoCommonState(LayerProto* layerInfo, LayerVector::StateSet
layerInfo->set_owner_uid(mOwnerUid);
}
- if (traceFlags & SurfaceTracing::TRACE_INPUT) {
+ if (traceFlags & SurfaceTracing::TRACE_INPUT && needsInputInfo()) {
WindowInfo info;
if (useDrawing) {
info = fillInputInfo({nullptr});
@@ -2214,7 +2215,7 @@ void Layer::fillInputFrameInfo(WindowInfo& info, const ui::Transform& toNonRotat
info.frameBottom = 0;
info.transform.reset();
info.touchableRegion = Region();
- info.flags = WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::NOT_FOCUSABLE;
+ info.flags |= WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::NOT_FOCUSABLE;
return;
}
@@ -2468,7 +2469,8 @@ sp<Layer> Layer::getClonedRoot() {
}
bool Layer::hasInputInfo() const {
- return mDrawingState.inputInfo.token != nullptr;
+ return mDrawingState.inputInfo.token != nullptr ||
+ mDrawingState.inputInfo.inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL);
}
bool Layer::canReceiveInput() const {