summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Tufvesson <lus@google.com>2022-03-04 09:32:07 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-10-18 07:23:20 +0000
commitf40e67f63a2c624e994a080d5b2e7abb1ae49572 (patch)
tree0f6f0848b49bb8c3c0c2bd44224e3ec74bedf67d
parent00f4a2e275b823d194b7f3081ef716e792d800b9 (diff)
downloadnative-f40e67f63a2c624e994a080d5b2e7abb1ae49572.tar.gz
Allow windowhandles with NO_INPUT_CHANNEL - DO NOT MERGE
This allows container surfaces to be considered visible in InputDispatcher and prevent touches from passing through them. In particular this is used by ActivityRecordInputSink to block touches that would otherwise pass through the area available to the activity. Bug: 194480991 Bug: 222292477 Test: Manually tested that blocking still works Test: atest InputSurfacesTest Change-Id: Iacfc952139311363b914b1d6bffc2b4190133d02 (cherry picked from commit a18588206c240b34128bb27e3ac875af17fce7f2) (cherry picked from commit c7df484a6f4265d20418fc64c46ead350f794a0c) Merged-In: Iacfc952139311363b914b1d6bffc2b4190133d02
-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 {