WindowInfo: Merge InputConfig and Feature flags
Merge the two flags in native code. We move the InputConfig flag
defintions to AIDL since we will be using the flags in Java as part of
the InputWindowHandle API next.
InputFeatureFlags are now a WM-only flag, but is temporarily used by
InputWindowHandle until the cleanup is completed.
Bug: 216806304
Test: atest libgui_test
Test: atest inputflinger_tests
Change-Id: I82d6de35b30d9cd4bcaf61499216c8faf407e885
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 32c3a12..7a00222 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -2698,18 +2698,16 @@
std::string InputDispatcher::dumpWindowForTouchOcclusion(const WindowInfo* info,
bool isTouchedWindow) const {
- return StringPrintf(INDENT2
- "* %spackage=%s/%" PRId32 ", id=%" PRId32 ", mode=%s, alpha=%.2f, "
- "frame=[%" PRId32 ",%" PRId32 "][%" PRId32 ",%" PRId32
- "], touchableRegion=%s, window={%s}, inputConfig={%s}, inputFeatures={%s}, "
- "hasToken=%s, applicationInfo.name=%s, applicationInfo.token=%s\n",
+ return StringPrintf(INDENT2 "* %spackage=%s/%" PRId32 ", id=%" PRId32 ", mode=%s, alpha=%.2f, "
+ "frame=[%" PRId32 ",%" PRId32 "][%" PRId32 ",%" PRId32
+ "], touchableRegion=%s, window={%s}, inputConfig={%s}, "
+ "hasToken=%s, applicationInfo.name=%s, applicationInfo.token=%s\n",
isTouchedWindow ? "[TOUCHED] " : "", info->packageName.c_str(),
info->ownerUid, info->id, toString(info->touchOcclusionMode).c_str(),
info->alpha, info->frameLeft, info->frameTop, info->frameRight,
info->frameBottom, dumpRegion(info->touchableRegion).c_str(),
info->name.c_str(), info->inputConfig.string().c_str(),
- info->inputFeatures.string().c_str(), toString(info->token != nullptr),
- info->applicationInfo.name.c_str(),
+ toString(info->token != nullptr), info->applicationInfo.name.c_str(),
toString(info->applicationInfo.token).c_str());
}
@@ -2787,7 +2785,7 @@
sp<WindowInfoHandle> focusedWindowHandle = getFocusedWindowHandleLocked(displayId);
if (focusedWindowHandle != nullptr) {
const WindowInfo* info = focusedWindowHandle->getInfo();
- if (info->inputFeatures.test(WindowInfo::Feature::DISABLE_USER_ACTIVITY)) {
+ if (info->inputConfig.test(WindowInfo::InputConfig::DISABLE_USER_ACTIVITY)) {
if (DEBUG_DISPATCH_CYCLE) {
ALOGD("Not poking user activity: disabled by window '%s'.", info->name.c_str());
}
@@ -4516,7 +4514,7 @@
bool InputDispatcher::hasResponsiveConnectionLocked(WindowInfoHandle& windowHandle) const {
sp<Connection> connection = getConnectionLocked(windowHandle.getToken());
const bool noInputChannel =
- windowHandle.getInfo()->inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL);
+ windowHandle.getInfo()->inputConfig.test(WindowInfo::InputConfig::NO_INPUT_CHANNEL);
if (connection != nullptr && noInputChannel) {
ALOGW("%s has feature NO_INPUT_CHANNEL, but it matched to connection %s",
windowHandle.getName().c_str(), connection->inputChannel->getName().c_str());
@@ -4566,7 +4564,7 @@
const WindowInfo* info = handle->getInfo();
if (getInputChannelLocked(handle->getToken()) == nullptr) {
const bool noInputChannel =
- info->inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL);
+ info->inputConfig.test(WindowInfo::InputConfig::NO_INPUT_CHANNEL);
const bool canReceiveInput =
!info->inputConfig.test(WindowInfo::InputConfig::NOT_TOUCHABLE) ||
!info->inputConfig.test(WindowInfo::InputConfig::NOT_FOCUSABLE);
@@ -4632,7 +4630,7 @@
const WindowInfo& info = *window->getInfo();
// Ensure all tokens are null if the window has feature NO_INPUT_CHANNEL
- const bool noInputWindow = info.inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL);
+ const bool noInputWindow = info.inputConfig.test(WindowInfo::InputConfig::NO_INPUT_CHANNEL);
if (noInputWindow && window->getToken() != nullptr) {
ALOGE("%s has feature NO_INPUT_WINDOW, but a non-null token. Clearing",
window->getName().c_str());
@@ -5209,8 +5207,6 @@
windowInfo->applicationInfo.name.c_str(),
toString(windowInfo->applicationInfo.token).c_str());
dump += dumpRegion(windowInfo->touchableRegion);
- dump += StringPrintf(", inputFeatures=%s",
- windowInfo->inputFeatures.string().c_str());
dump += StringPrintf(", ownerPid=%d, ownerUid=%d, dispatchingTimeout=%" PRId64
"ms, hasToken=%s, "
"touchOcclusionMode=%s\n",
@@ -6248,13 +6244,14 @@
bool InputDispatcher::shouldDropInput(
const EventEntry& entry, const sp<android::gui::WindowInfoHandle>& windowHandle) const {
- if (windowHandle->getInfo()->inputFeatures.test(WindowInfo::Feature::DROP_INPUT) ||
- (windowHandle->getInfo()->inputFeatures.test(WindowInfo::Feature::DROP_INPUT_IF_OBSCURED) &&
+ if (windowHandle->getInfo()->inputConfig.test(WindowInfo::InputConfig::DROP_INPUT) ||
+ (windowHandle->getInfo()->inputConfig.test(
+ WindowInfo::InputConfig::DROP_INPUT_IF_OBSCURED) &&
isWindowObscuredLocked(windowHandle))) {
- ALOGW("Dropping %s event targeting %s as requested by input feature %s on display "
- "%" PRId32 ".",
+ ALOGW("Dropping %s event targeting %s as requested by the input configuration {%s} on "
+ "display %" PRId32 ".",
ftl::enum_string(entry.type).c_str(), windowHandle->getName().c_str(),
- windowHandle->getInfo()->inputFeatures.string().c_str(),
+ windowHandle->getInfo()->inputConfig.string().c_str(),
windowHandle->getInfo()->displayId);
return true;
}
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index b3f51ee..b3fea74 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -991,7 +991,7 @@
mInfo.ownerPid = INJECTOR_PID;
mInfo.ownerUid = INJECTOR_UID;
mInfo.displayId = displayId;
- mInfo.inputConfig = WindowInfo::InputConfig::NONE;
+ mInfo.inputConfig = WindowInfo::InputConfig::DEFAULT;
}
sp<FakeWindowHandle> clone(
@@ -1035,6 +1035,24 @@
mInfo.setInputConfig(WindowInfo::InputConfig::WATCH_OUTSIDE_TOUCH, watchOutside);
}
+ void setSpy(bool spy) { mInfo.setInputConfig(WindowInfo::InputConfig::SPY, spy); }
+
+ void setInterceptsStylus(bool interceptsStylus) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::INTERCEPTS_STYLUS, interceptsStylus);
+ }
+
+ void setDropInput(bool dropInput) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::DROP_INPUT, dropInput);
+ }
+
+ void setDropInputIfObscured(bool dropInputIfObscured) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::DROP_INPUT_IF_OBSCURED, dropInputIfObscured);
+ }
+
+ void setNoInputChannel(bool noInputChannel) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::NO_INPUT_CHANNEL, noInputChannel);
+ }
+
void setAlpha(float alpha) { mInfo.alpha = alpha; }
void setTouchOcclusionMode(TouchOcclusionMode mode) { mInfo.touchOcclusionMode = mode; }
@@ -1065,8 +1083,6 @@
mInfo.setInputConfig(WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER, hasWallpaper);
}
- void setInputFeatures(Flags<WindowInfo::Feature> features) { mInfo.inputFeatures = features; }
-
void setTrustedOverlay(bool trustedOverlay) {
mInfo.setInputConfig(WindowInfo::InputConfig::TRUSTED_OVERLAY, trustedOverlay);
}
@@ -1219,7 +1235,7 @@
void assertNoEvents() {
if (mInputReceiver == nullptr &&
- mInfo.inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL)) {
+ mInfo.inputConfig.test(WindowInfo::InputConfig::NO_INPUT_CHANNEL)) {
return; // Can't receive events if the window does not have input channel
}
ASSERT_NE(nullptr, mInputReceiver)
@@ -4301,7 +4317,7 @@
new FakeWindowHandle(mApplication, mDispatcher, "Spy", ADISPLAY_ID_DEFAULT);
spy->setTrustedOverlay(true);
spy->setFocusable(false);
- spy->setInputFeatures(WindowInfo::Feature::SPY);
+ spy->setSpy(true);
spy->setDispatchingTimeout(30ms);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, mWindow}}});
return spy;
@@ -5094,7 +5110,7 @@
"Window without input channel", ADISPLAY_ID_DEFAULT,
std::make_optional<sp<IBinder>>(nullptr) /*token*/);
- mNoInputWindow->setInputFeatures(WindowInfo::Feature::NO_INPUT_CHANNEL);
+ mNoInputWindow->setNoInputChannel(true);
mNoInputWindow->setFrame(Rect(0, 0, 100, 100));
// It's perfectly valid for this window to not have an associated input channel
@@ -5136,7 +5152,7 @@
"Window with input channel and NO_INPUT_CHANNEL",
ADISPLAY_ID_DEFAULT);
- mNoInputWindow->setInputFeatures(WindowInfo::Feature::NO_INPUT_CHANNEL);
+ mNoInputWindow->setNoInputChannel(true);
mNoInputWindow->setFrame(Rect(0, 0, 100, 100));
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mNoInputWindow, mBottomWindow}}});
@@ -6051,7 +6067,7 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Test window", ADISPLAY_ID_DEFAULT);
- window->setInputFeatures(WindowInfo::Feature::DROP_INPUT);
+ window->setDropInput(true);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
window->setFocusable(true);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
@@ -6070,7 +6086,7 @@
window->assertNoEvents();
// With the flag cleared, the window should get input
- window->setInputFeatures({});
+ window->setDropInput(false);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
@@ -6096,7 +6112,7 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Test window", ADISPLAY_ID_DEFAULT);
- window->setInputFeatures(WindowInfo::Feature::DROP_INPUT_IF_OBSCURED);
+ window->setDropInputIfObscured(true);
window->setOwnerInfo(222, 222);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
window->setFocusable(true);
@@ -6116,7 +6132,7 @@
window->assertNoEvents();
// With the flag cleared, the window should get input
- window->setInputFeatures({});
+ window->setDropInputIfObscured(false);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {obscuringWindow, window}}});
keyArgs = generateKeyArgs(AKEY_EVENT_ACTION_UP, ADISPLAY_ID_DEFAULT);
@@ -6142,7 +6158,7 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Test window", ADISPLAY_ID_DEFAULT);
- window->setInputFeatures(WindowInfo::Feature::DROP_INPUT_IF_OBSCURED);
+ window->setDropInputIfObscured(true);
window->setOwnerInfo(222, 222);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
window->setFocusable(true);
@@ -6251,7 +6267,7 @@
name += std::to_string(mSpyCount++);
sp<FakeWindowHandle> spy =
new FakeWindowHandle(application, mDispatcher, name.c_str(), ADISPLAY_ID_DEFAULT);
- spy->setInputFeatures(WindowInfo::Feature::SPY);
+ spy->setSpy(true);
spy->setTrustedOverlay(true);
return spy;
}
@@ -6699,7 +6715,7 @@
overlay->setFocusable(false);
overlay->setOwnerInfo(111, 111);
overlay->setTouchable(false);
- overlay->setInputFeatures(WindowInfo::Feature::INTERCEPTS_STYLUS);
+ overlay->setInterceptsStylus(true);
overlay->setTrustedOverlay(true);
std::shared_ptr<FakeApplicationHandle> application =
@@ -6765,7 +6781,7 @@
TEST_F(InputDispatcherStylusInterceptorTest, SpyWindowStylusInterceptor) {
auto [overlay, window] = setupStylusOverlayScenario();
- overlay->setInputFeatures(overlay->getInfo()->inputFeatures | WindowInfo::Feature::SPY);
+ overlay->setSpy(true);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {overlay, window}}});
sendStylusEvent(AMOTION_EVENT_ACTION_DOWN);
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 533acfd..2653d8c 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -2251,14 +2251,14 @@
}
void Layer::handleDropInputMode(gui::WindowInfo& info) const {
- if (mDrawingState.inputInfo.inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL)) {
+ if (mDrawingState.inputInfo.inputConfig.test(WindowInfo::InputConfig::NO_INPUT_CHANNEL)) {
return;
}
// Check if we need to drop input unconditionally
gui::DropInputMode dropInputMode = getDropInputMode();
if (dropInputMode == gui::DropInputMode::ALL) {
- info.inputFeatures |= WindowInfo::Feature::DROP_INPUT;
+ info.inputConfig |= WindowInfo::InputConfig::DROP_INPUT;
ALOGV("Dropping input for %s as requested by policy.", getDebugName());
return;
}
@@ -2271,7 +2271,7 @@
// Check if the parent has set an alpha on the layer
sp<Layer> parent = mDrawingParent.promote();
if (parent && parent->getAlpha() != 1.0_hf) {
- info.inputFeatures |= WindowInfo::Feature::DROP_INPUT;
+ info.inputConfig |= WindowInfo::InputConfig::DROP_INPUT;
ALOGV("Dropping input for %s as requested by policy because alpha=%f", getDebugName(),
static_cast<float>(getAlpha()));
}
@@ -2279,7 +2279,7 @@
// Check if the parent has cropped the buffer
Rect bufferSize = getCroppedBufferSize(getDrawingState());
if (!bufferSize.isValid()) {
- info.inputFeatures |= WindowInfo::Feature::DROP_INPUT_IF_OBSCURED;
+ info.inputConfig |= WindowInfo::InputConfig::DROP_INPUT_IF_OBSCURED;
return;
}
@@ -2291,7 +2291,7 @@
bool croppedByParent = bufferInScreenSpace != Rect{mScreenBounds};
if (croppedByParent) {
- info.inputFeatures |= WindowInfo::Feature::DROP_INPUT;
+ info.inputConfig |= WindowInfo::InputConfig::DROP_INPUT;
ALOGV("Dropping input for %s as requested by policy because buffer is cropped by parent",
getDebugName());
} else {
@@ -2299,7 +2299,7 @@
// input if the window is obscured. This check should be done in surfaceflinger but the
// logic currently resides in inputflinger. So pass the if_obscured check to input to only
// drop input events if the window is obscured.
- info.inputFeatures |= WindowInfo::Feature::DROP_INPUT_IF_OBSCURED;
+ info.inputConfig |= WindowInfo::InputConfig::DROP_INPUT_IF_OBSCURED;
}
}
@@ -2308,7 +2308,7 @@
mDrawingState.inputInfo.name = getName();
mDrawingState.inputInfo.ownerUid = mOwnerUid;
mDrawingState.inputInfo.ownerPid = mOwnerPid;
- mDrawingState.inputInfo.inputFeatures = WindowInfo::Feature::NO_INPUT_CHANNEL;
+ mDrawingState.inputInfo.inputConfig |= WindowInfo::InputConfig::NO_INPUT_CHANNEL;
mDrawingState.inputInfo.displayId = getLayerStack().id;
}
@@ -2336,7 +2336,7 @@
// If the window will be blacked out on a display because the display does not have the secure
// flag and the layer has the secure flag set, then drop input.
if (!displayIsSecure && isSecure()) {
- info.inputFeatures |= WindowInfo::Feature::DROP_INPUT;
+ info.inputConfig |= WindowInfo::InputConfig::DROP_INPUT;
}
auto cropLayer = mDrawingState.touchableRegionCrop.promote();