summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Tufvesson <lus@google.com>2022-07-01 09:20:15 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-07-01 09:20:15 +0000
commit193b8969e5ff717d7ec861bade464c158942f338 (patch)
tree0f6f0848b49bb8c3c0c2bd44224e3ec74bedf67d
parent5f4769af2d1a806ab1f1a414e4930b28762b0e48 (diff)
parentc7df484a6f4265d20418fc64c46ead350f794a0c (diff)
downloadnative-193b8969e5ff717d7ec861bade464c158942f338.tar.gz
Allow windowhandles with NO_INPUT_CHANNEL - DO NOT MERGE am: c7df484a6f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/18029504 Change-Id: I60323ba01a16be6a0c5258a5618db998f3c1b728 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libs/gui/tests/EndToEndNativeInputTest.cpp93
-rw-r--r--services/surfaceflinger/Layer.cpp3
2 files changed, 61 insertions, 35 deletions
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index 8e42c688af..e3f4798019 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -66,17 +66,40 @@ static const int LAYER_BASE = INT32_MAX - 10;
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;
- InputChannel::openInputChannelPair("testchannels", mServerChannel, mClientChannel);
-
mInputFlinger = getInputFlinger();
- mInputFlinger->registerInputChannel(mServerChannel);
+ if (noInputChannel) {
+ mInputInfo.inputFeatures = InputWindowInfo::INPUT_FEATURE_NO_INPUT_CHANNEL;
+ } else {
+ InputChannel::openInputChannelPair("testchannels", mServerChannel, mClientChannel);
+ mInputFlinger->registerInputChannel(mServerChannel);
+ mInputInfo.token = mServerChannel->getConnectionToken();
+ mInputConsumer = new InputConsumer(mClientChannel);
+ }
- populateInputInfo(width, height);
+ mInputInfo.name = "Test info";
+ mInputInfo.layoutParamsFlags = InputWindowInfo::FLAG_NOT_TOUCH_MODAL;
+ mInputInfo.layoutParamsType = InputWindowInfo::TYPE_BASE_APPLICATION;
+ mInputInfo.dispatchingTimeout = seconds_to_nanoseconds(5);
+ mInputInfo.globalScaleFactor = 1.0;
+ mInputInfo.canReceiveKeys = true;
+ mInputInfo.hasFocus = 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.inputFeatures = 0;
+ mInputInfo.displayId = 0;
- mInputConsumer = new InputConsumer(mClientChannel);
+ InputApplicationInfo aInfo;
+ aInfo.token = new BBinder();
+ aInfo.name = "Test app info";
+ aInfo.dispatchingTimeout = seconds_to_nanoseconds(5);
+ mInputInfo.applicationInfo = aInfo;
}
static std::unique_ptr<InputSurface> makeColorInputSurface(const sp<SurfaceComposerClient> &scc,
@@ -105,6 +128,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 =
@@ -173,7 +206,9 @@ public:
}
~InputSurface() {
- mInputFlinger->unregisterInputChannel(mServerChannel);
+ if (mInputInfo.token) {
+ mInputFlinger->unregisterInputChannel(mServerChannel);
+ }
}
void doTransaction(std::function<void(SurfaceComposerClient::Transaction&,
@@ -203,33 +238,6 @@ private:
poll(&fd, 1, timeoutMs);
}
- void populateInputInfo(int width, int height) {
- mInputInfo.token = mServerChannel->getConnectionToken();
- mInputInfo.name = "Test info";
- mInputInfo.layoutParamsFlags = InputWindowInfo::FLAG_NOT_TOUCH_MODAL;
- mInputInfo.layoutParamsType = InputWindowInfo::TYPE_BASE_APPLICATION;
- mInputInfo.dispatchingTimeout = seconds_to_nanoseconds(5);
- mInputInfo.globalScaleFactor = 1.0;
- mInputInfo.canReceiveKeys = true;
- mInputInfo.hasFocus = 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.inputFeatures = 0;
- mInputInfo.displayId = 0;
-
- InputApplicationInfo aInfo;
- aInfo.token = new BBinder();
- aInfo.name = "Test app info";
- aInfo.dispatchingTimeout = seconds_to_nanoseconds(5);
-
- mInputInfo.applicationInfo = aInfo;
- }
public:
sp<SurfaceControl> mSurfaceControl;
sp<InputChannel> mServerChannel, mClientChannel;
@@ -589,6 +597,23 @@ TEST_F(InputSurfacesTest, input_ignores_cursor_layer) {
surface->expectTap(1, 1);
}
+TEST_F(InputSurfacesTest, child_container_with_no_input_channel_blocks_parent) {
+ std::unique_ptr<InputSurface> parent = makeSurface(100, 100);
+ parent->showAt(100, 100);
+ parent->assertFocusChange(true);
+ 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->getHandle()); });
+ injectTap(101, 101);
+
+ EXPECT_EQ(parent->consumeEvent(100), nullptr);
+}
+
TEST_F(InputSurfacesTest, drop_input_policy) {
std::unique_ptr<InputSurface> surface = makeSurface(100, 100);
surface->doTransaction(
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 6a0623e8cc..6215d5cecc 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2529,7 +2529,8 @@ sp<Layer> Layer::getClonedRoot() {
}
bool Layer::hasInputInfo() const {
- return mDrawingState.inputInfo.token != nullptr;
+ return mDrawingState.inputInfo.token != nullptr ||
+ mDrawingState.inputInfo.inputFeatures & InputWindowInfo::INPUT_FEATURE_NO_INPUT_CHANNEL;
}
bool Layer::canReceiveInput() const {