Introduce WindowInfo::InputConfig flag to control input behavior
Instead of re-using layoutParams flags and layoutParam types and having
redundant information in WindowInfo, we add a new InputConfig flag that
the native input pipeline will use for all input window configurations.
This also reduces WindowInfo's size by converting booleans into flags.
Bug: 216806304
Test: atest libgui_test
Test: atest inputflinger_tests
Change-Id: If0354cc2cfc84986f7f0d48cd9348be1ff82293d
diff --git a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
index 41e9ce2..cd20a64 100644
--- a/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
+++ b/services/inputflinger/benchmarks/InputDispatcher_benchmarks.cpp
@@ -193,7 +193,6 @@
void updateInfo() {
mInfo.token = mClientChannel->getConnectionToken();
mInfo.name = "FakeWindowHandle";
- mInfo.type = WindowInfo::Type::APPLICATION;
mInfo.dispatchingTimeout = DISPATCHING_TIMEOUT;
mInfo.frameLeft = mFrame.left;
mInfo.frameTop = mFrame.top;
@@ -202,10 +201,6 @@
mInfo.globalScaleFactor = 1.0;
mInfo.touchableRegion.clear();
mInfo.addTouchableRegion(mFrame);
- mInfo.visible = true;
- mInfo.focusable = true;
- mInfo.hasWallpaper = false;
- mInfo.paused = false;
mInfo.ownerPid = INJECTOR_PID;
mInfo.ownerUid = INJECTOR_UID;
mInfo.displayId = ADISPLAY_ID_DEFAULT;
diff --git a/services/inputflinger/dispatcher/FocusResolver.cpp b/services/inputflinger/dispatcher/FocusResolver.cpp
index 600f02b..a02b3e8 100644
--- a/services/inputflinger/dispatcher/FocusResolver.cpp
+++ b/services/inputflinger/dispatcher/FocusResolver.cpp
@@ -148,11 +148,11 @@
continue;
}
windowFound = true;
- if (window->getInfo()->visible) {
+ if (!window->getInfo()->inputConfig.test(gui::WindowInfo::InputConfig::NOT_VISIBLE)) {
// Check if at least a single window is visible.
visibleWindowFound = true;
}
- if (!window->getInfo()->focusable) {
+ if (window->getInfo()->inputConfig.test(gui::WindowInfo::InputConfig::NOT_FOCUSABLE)) {
// Check if all windows with the window token are focusable.
allWindowsAreFocusable = false;
break;
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 6c321bc..001c50f 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -500,16 +500,17 @@
// Returns true if the given window can accept pointer events at the given display location.
bool windowAcceptsTouchAt(const WindowInfo& windowInfo, int32_t displayId, int32_t x, int32_t y,
bool isStylus) {
- if (windowInfo.displayId != displayId || !windowInfo.visible) {
+ const auto inputConfig = windowInfo.inputConfig;
+ if (windowInfo.displayId != displayId ||
+ inputConfig.test(WindowInfo::InputConfig::NOT_VISIBLE)) {
return false;
}
- const auto flags = windowInfo.flags;
const bool windowCanInterceptTouch = isStylus && windowInfo.interceptsStylus();
- if (flags.test(WindowInfo::Flag::NOT_TOUCHABLE) && !windowCanInterceptTouch) {
+ if (inputConfig.test(WindowInfo::InputConfig::NOT_TOUCHABLE) && !windowCanInterceptTouch) {
return false;
}
- const bool isModalWindow = !flags.test(WindowInfo::Flag::NOT_FOCUSABLE) &&
- !flags.test(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ const bool isModalWindow = !inputConfig.test(WindowInfo::InputConfig::NOT_FOCUSABLE) &&
+ !inputConfig.test(WindowInfo::InputConfig::NOT_TOUCH_MODAL);
if (!isModalWindow && !windowInfo.touchableRegionContainsPoint(x, y)) {
return false;
}
@@ -1047,7 +1048,8 @@
return windowHandle;
}
- if (addOutsideTargets && info.flags.test(WindowInfo::Flag::WATCH_OUTSIDE_TOUCH)) {
+ if (addOutsideTargets &&
+ info.inputConfig.test(WindowInfo::InputConfig::WATCH_OUTSIDE_TOUCH)) {
touchState->addOrUpdateWindow(windowHandle, InputTarget::FLAG_DISPATCH_AS_OUTSIDE,
BitSet32(0));
}
@@ -1900,7 +1902,8 @@
return InputEventInjectionResult::PERMISSION_DENIED;
}
- if (focusedWindowHandle->getInfo()->paused) {
+ if (focusedWindowHandle->getInfo()->inputConfig.test(
+ WindowInfo::InputConfig::PAUSE_DISPATCHING)) {
ALOGI("Waiting because %s is paused", focusedWindowHandle->getName().c_str());
return InputEventInjectionResult::PENDING;
}
@@ -2101,7 +2104,7 @@
for (const sp<WindowInfoHandle>& windowHandle : newTouchedWindows) {
const WindowInfo& info = *windowHandle->getInfo();
- if (info.paused) {
+ if (info.inputConfig.test(WindowInfo::InputConfig::PAUSE_DISPATCHING)) {
ALOGI("Not sending touch event to %s because it is paused",
windowHandle->getName().c_str());
continue;
@@ -2324,13 +2327,16 @@
if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
sp<WindowInfoHandle> foregroundWindowHandle =
tempTouchState.getFirstForegroundWindowHandle();
- if (foregroundWindowHandle && foregroundWindowHandle->getInfo()->hasWallpaper) {
+ if (foregroundWindowHandle &&
+ foregroundWindowHandle->getInfo()->inputConfig.test(
+ WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER)) {
const std::vector<sp<WindowInfoHandle>>& windowHandles =
getWindowHandlesLocked(displayId);
for (const sp<WindowInfoHandle>& windowHandle : windowHandles) {
const WindowInfo* info = windowHandle->getInfo();
if (info->displayId == displayId &&
- windowHandle->getInfo()->type == WindowInfo::Type::WALLPAPER) {
+ windowHandle->getInfo()->inputConfig.test(
+ WindowInfo::InputConfig::IS_WALLPAPER)) {
tempTouchState
.addOrUpdateWindow(windowHandle,
InputTarget::FLAG_WINDOW_IS_OBSCURED |
@@ -2599,9 +2605,10 @@
}
auto info = windowHandle->getInfo();
auto otherInfo = otherHandle->getInfo();
- if (!otherInfo->visible) {
+ if (otherInfo->inputConfig.test(WindowInfo::InputConfig::NOT_VISIBLE)) {
return false;
- } else if (otherInfo->alpha == 0 && otherInfo->flags.test(WindowInfo::Flag::NOT_TOUCHABLE)) {
+ } else if (otherInfo->alpha == 0 &&
+ otherInfo->inputConfig.test(WindowInfo::InputConfig::NOT_TOUCHABLE)) {
// Those act as if they were invisible, so we don't need to flag them.
// We do want to potentially flag touchable windows even if they have 0
// opacity, since they can consume touches and alter the effects of the
@@ -2613,7 +2620,7 @@
// If ownerUid is the same we don't generate occlusion events as there
// is no security boundary within an uid.
return false;
- } else if (otherInfo->trustedOverlay) {
+ } else if (otherInfo->inputConfig.test(gui::WindowInfo::InputConfig::TRUSTED_OVERLAY)) {
return false;
} else if (otherInfo->displayId != info->displayId) {
return false;
@@ -2694,17 +2701,17 @@
std::string InputDispatcher::dumpWindowForTouchOcclusion(const WindowInfo* info,
bool isTouchedWindow) const {
return StringPrintf(INDENT2
- "* %stype=%s, package=%s/%" PRId32 ", id=%" PRId32 ", mode=%s, alpha=%.2f, "
+ "* %spackage=%s/%" PRId32 ", id=%" PRId32 ", mode=%s, alpha=%.2f, "
"frame=[%" PRId32 ",%" PRId32 "][%" PRId32 ",%" PRId32
- "], touchableRegion=%s, window={%s}, flags={%s}, inputFeatures={%s}, "
+ "], touchableRegion=%s, window={%s}, inputConfig={%s}, inputFeatures={%s}, "
"hasToken=%s, applicationInfo.name=%s, applicationInfo.token=%s\n",
- isTouchedWindow ? "[TOUCHED] " : "", ftl::enum_string(info->type).c_str(),
- 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->flags.string().c_str(), info->inputFeatures.string().c_str(),
- toString(info->token != nullptr), info->applicationInfo.name.c_str(),
+ 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->applicationInfo.token).c_str());
}
@@ -4572,8 +4579,9 @@
if (getInputChannelLocked(handle->getToken()) == nullptr) {
const bool noInputChannel =
info->inputFeatures.test(WindowInfo::Feature::NO_INPUT_CHANNEL);
- const bool canReceiveInput = !info->flags.test(WindowInfo::Flag::NOT_TOUCHABLE) ||
- !info->flags.test(WindowInfo::Flag::NOT_FOCUSABLE);
+ const bool canReceiveInput =
+ !info->inputConfig.test(WindowInfo::InputConfig::NOT_TOUCHABLE) ||
+ !info->inputConfig.test(WindowInfo::InputConfig::NOT_FOCUSABLE);
if (canReceiveInput && !noInputChannel) {
ALOGV("Window handle %s has no registered input channel",
handle->getName().c_str());
@@ -4644,12 +4652,16 @@
}
// Ensure all spy windows are trusted overlays
- LOG_ALWAYS_FATAL_IF(info.isSpy() && !info.trustedOverlay,
+ LOG_ALWAYS_FATAL_IF(info.isSpy() &&
+ !info.inputConfig.test(
+ WindowInfo::InputConfig::TRUSTED_OVERLAY),
"%s has feature SPY, but is not a trusted overlay.",
window->getName().c_str());
// Ensure all stylus interceptors are trusted overlays
- LOG_ALWAYS_FATAL_IF(info.interceptsStylus() && !info.trustedOverlay,
+ LOG_ALWAYS_FATAL_IF(info.interceptsStylus() &&
+ !info.inputConfig.test(
+ WindowInfo::InputConfig::TRUSTED_OVERLAY),
"%s has feature INTERCEPTS_STYLUS, but is not a trusted overlay.",
window->getName().c_str());
}
@@ -4699,7 +4711,8 @@
// Since we are about to drop the touch, cancel the events for the wallpaper as
// well.
if (touchedWindow.targetFlags & InputTarget::FLAG_FOREGROUND &&
- touchedWindow.windowHandle->getInfo()->hasWallpaper) {
+ touchedWindow.windowHandle->getInfo()->inputConfig.test(
+ gui::WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER)) {
sp<WindowInfoHandle> wallpaper = state.getWallpaperWindow();
if (wallpaper != nullptr) {
sp<Connection> wallpaperConnection =
@@ -5194,34 +5207,27 @@
const WindowInfo* windowInfo = windowHandle->getInfo();
dump += StringPrintf(INDENT3 "%zu: name='%s', id=%" PRId32 ", displayId=%d, "
- "paused=%s, focusable=%s, "
- "hasWallpaper=%s, visible=%s, alpha=%.2f, "
- "flags=%s, type=%s, "
+ "inputConfig=%s, alpha=%.2f, "
"frame=[%d,%d][%d,%d], globalScale=%f, "
"applicationInfo.name=%s, "
"applicationInfo.token=%s, "
"touchableRegion=",
i, windowInfo->name.c_str(), windowInfo->id,
- windowInfo->displayId, toString(windowInfo->paused),
- toString(windowInfo->focusable),
- toString(windowInfo->hasWallpaper),
- toString(windowInfo->visible), windowInfo->alpha,
- windowInfo->flags.string().c_str(),
- ftl::enum_string(windowInfo->type).c_str(),
- windowInfo->frameLeft, windowInfo->frameTop,
- windowInfo->frameRight, windowInfo->frameBottom,
- windowInfo->globalScaleFactor,
+ windowInfo->displayId,
+ windowInfo->inputConfig.string().c_str(),
+ windowInfo->alpha, windowInfo->frameLeft,
+ windowInfo->frameTop, windowInfo->frameRight,
+ windowInfo->frameBottom, windowInfo->globalScaleFactor,
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, trustedOverlay=%s, hasToken=%s, "
+ "ms, hasToken=%s, "
"touchOcclusionMode=%s\n",
windowInfo->ownerPid, windowInfo->ownerUid,
millis(windowInfo->dispatchingTimeout),
- toString(windowInfo->trustedOverlay),
toString(windowInfo->token != nullptr),
toString(windowInfo->touchOcclusionMode).c_str());
windowInfo->transform.dump(dump, "transform", INDENT4);
diff --git a/services/inputflinger/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index b63fe10..61e78cc 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -100,7 +100,8 @@
for (const TouchedWindow& window : windows) {
if (window.targetFlags & InputTarget::FLAG_FOREGROUND) {
if (haveSlipperyForegroundWindow ||
- !window.windowHandle->getInfo()->flags.test(WindowInfo::Flag::SLIPPERY)) {
+ !window.windowHandle->getInfo()->inputConfig.test(
+ WindowInfo::InputConfig::SLIPPERY)) {
return false;
}
haveSlipperyForegroundWindow = true;
@@ -112,7 +113,8 @@
sp<WindowInfoHandle> TouchState::getWallpaperWindow() const {
for (size_t i = 0; i < windows.size(); i++) {
const TouchedWindow& window = windows[i];
- if (window.windowHandle->getInfo()->type == WindowInfo::Type::WALLPAPER) {
+ if (window.windowHandle->getInfo()->inputConfig.test(
+ gui::WindowInfo::InputConfig::IS_WALLPAPER)) {
return window.windowHandle;
}
}
diff --git a/services/inputflinger/tests/FocusResolver_test.cpp b/services/inputflinger/tests/FocusResolver_test.cpp
index 662be80..ffce9f6 100644
--- a/services/inputflinger/tests/FocusResolver_test.cpp
+++ b/services/inputflinger/tests/FocusResolver_test.cpp
@@ -37,12 +37,16 @@
bool visible) {
mInfo.token = token;
mInfo.name = name;
- mInfo.visible = visible;
- mInfo.focusable = focusable;
+ setFocusable(focusable);
+ setVisible(visible);
}
- void setFocusable(bool focusable) { mInfo.focusable = focusable; }
- void setVisible(bool visible) { mInfo.visible = visible; }
+ void setFocusable(bool focusable) {
+ mInfo.setInputConfig(gui::WindowInfo::InputConfig::NOT_FOCUSABLE, !focusable);
+ }
+ void setVisible(bool visible) {
+ mInfo.setInputConfig(gui::WindowInfo::InputConfig::NOT_VISIBLE, !visible);
+ }
};
TEST(FocusResolverTest, SetFocusedWindow) {
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index 872882e..8b95f28 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -986,7 +986,6 @@
mInfo.token = *token;
mInfo.id = sId++;
mInfo.name = name;
- mInfo.type = WindowInfo::Type::APPLICATION;
mInfo.dispatchingTimeout = DISPATCHING_TIMEOUT;
mInfo.alpha = 1.0;
mInfo.frameLeft = 0;
@@ -997,14 +996,14 @@
mInfo.globalScaleFactor = 1.0;
mInfo.touchableRegion.clear();
mInfo.addTouchableRegion(Rect(0, 0, WIDTH, HEIGHT));
- mInfo.visible = true;
- mInfo.focusable = false;
- mInfo.hasWallpaper = false;
- mInfo.paused = false;
mInfo.ownerPid = INJECTOR_PID;
mInfo.ownerUid = INJECTOR_UID;
mInfo.displayId = displayId;
- mInfo.trustedOverlay = false;
+ setVisible(true);
+ setFocusable(false);
+ setDupTouchToWallpaper(false);
+ setPaused(false);
+ setTrustedOverlay(false);
}
sp<FakeWindowHandle> clone(
@@ -1016,15 +1015,41 @@
return handle;
}
- void setFocusable(bool focusable) { mInfo.focusable = focusable; }
+ void setTouchable(bool touchable) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCHABLE, !touchable);
+ }
- void setVisible(bool visible) { mInfo.visible = visible; }
+ void setFocusable(bool focusable) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::NOT_FOCUSABLE, !focusable);
+ }
+
+ void setVisible(bool visible) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::NOT_VISIBLE, !visible);
+ }
void setDispatchingTimeout(std::chrono::nanoseconds timeout) {
mInfo.dispatchingTimeout = timeout;
}
- void setPaused(bool paused) { mInfo.paused = paused; }
+ void setPaused(bool paused) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::PAUSE_DISPATCHING, paused);
+ }
+
+ void setTouchModal(bool touchModal) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::NOT_TOUCH_MODAL, !touchModal);
+ }
+
+ void setSplitTouch(bool splitTouch) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::SPLIT_TOUCH, splitTouch);
+ }
+
+ void setSlippery(bool slippery) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::SLIPPERY, slippery);
+ }
+
+ void setWatchOutsideTouch(bool watchOutside) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::WATCH_OUTSIDE_TOUCH, watchOutside);
+ }
void setAlpha(float alpha) { mInfo.alpha = alpha; }
@@ -1048,17 +1073,19 @@
void setTouchableRegion(const Region& region) { mInfo.touchableRegion = region; }
- void setType(WindowInfo::Type type) { mInfo.type = type; }
+ void setIsWallpaper(bool isWallpaper) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::IS_WALLPAPER, isWallpaper);
+ }
- void setHasWallpaper(bool hasWallpaper) { mInfo.hasWallpaper = hasWallpaper; }
-
- void addFlags(Flags<WindowInfo::Flag> flags) { mInfo.flags |= flags; }
-
- void setFlags(Flags<WindowInfo::Flag> flags) { mInfo.flags = flags; }
+ void setDupTouchToWallpaper(bool hasWallpaper) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER, hasWallpaper);
+ }
void setInputFeatures(Flags<WindowInfo::Feature> features) { mInfo.inputFeatures = features; }
- void setTrustedOverlay(bool trustedOverlay) { mInfo.trustedOverlay = trustedOverlay; }
+ void setTrustedOverlay(bool trustedOverlay) {
+ mInfo.setInputConfig(WindowInfo::InputConfig::TRUSTED_OVERLAY, trustedOverlay);
+ }
void setWindowTransform(float dsdx, float dtdx, float dtdy, float dsdy) {
mInfo.transform.set(dsdx, dtdx, dtdy, dsdy);
@@ -1551,7 +1578,7 @@
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
- window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ window->setTouchModal(false);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -1574,7 +1601,7 @@
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
window->setFrame(Rect(0, 0, 100, 100));
- window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ window->setTouchModal(false);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {window}}});
@@ -1609,17 +1636,17 @@
* Two windows: A top window, and a wallpaper behind the window.
* Touch goes to the top window, and then top window disappears. Ensure that wallpaper window
* gets ACTION_CANCEL.
- * 1. foregroundWindow <-- has wallpaper (hasWallpaper=true)
- * 2. wallpaperWindow <-- is wallpaper (type=InputWindowInfo::Type::WALLPAPER)
+ * 1. foregroundWindow <-- dup touch to wallpaper
+ * 2. wallpaperWindow <-- is wallpaper
*/
TEST_F(InputDispatcherTest, WhenForegroundWindowDisappears_WallpaperTouchIsCanceled) {
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> foregroundWindow =
new FakeWindowHandle(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
- foregroundWindow->setHasWallpaper(true);
+ foregroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaperWindow =
new FakeWindowHandle(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
- wallpaperWindow->setType(WindowInfo::Type::WALLPAPER);
+ wallpaperWindow->setIsWallpaper(true);
constexpr int expectedWallpaperFlags =
AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED | AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
@@ -1660,10 +1687,10 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> foregroundWindow =
new FakeWindowHandle(application, mDispatcher, "Foreground", ADISPLAY_ID_DEFAULT);
- foregroundWindow->setHasWallpaper(true);
+ foregroundWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaperWindow =
new FakeWindowHandle(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
- wallpaperWindow->setType(WindowInfo::Type::WALLPAPER);
+ wallpaperWindow->setIsWallpaper(true);
constexpr int expectedWallpaperFlags =
AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED | AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
@@ -1704,11 +1731,11 @@
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
- window->setHasWallpaper(true);
+ window->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaperWindow =
new FakeWindowHandle(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
- wallpaperWindow->setType(WindowInfo::Type::WALLPAPER);
+ wallpaperWindow->setIsWallpaper(true);
constexpr int expectedWallpaperFlags =
AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED | AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
@@ -1762,19 +1789,21 @@
sp<FakeWindowHandle> leftWindow =
new FakeWindowHandle(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
leftWindow->setFrame(Rect(0, 0, 200, 200));
- leftWindow->setFlags(WindowInfo::Flag::SPLIT_TOUCH | WindowInfo::Flag::NOT_TOUCH_MODAL);
- leftWindow->setHasWallpaper(true);
+ leftWindow->setTouchModal(false);
+ leftWindow->setSplitTouch(true);
+ leftWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> rightWindow =
new FakeWindowHandle(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
rightWindow->setFrame(Rect(200, 0, 400, 200));
- rightWindow->setFlags(WindowInfo::Flag::SPLIT_TOUCH | WindowInfo::Flag::NOT_TOUCH_MODAL);
- rightWindow->setHasWallpaper(true);
+ rightWindow->setTouchModal(false);
+ rightWindow->setSplitTouch(true);
+ rightWindow->setDupTouchToWallpaper(true);
sp<FakeWindowHandle> wallpaperWindow =
new FakeWindowHandle(application, mDispatcher, "Wallpaper", ADISPLAY_ID_DEFAULT);
wallpaperWindow->setFrame(Rect(0, 0, 400, 200));
- wallpaperWindow->setType(WindowInfo::Type::WALLPAPER);
+ wallpaperWindow->setIsWallpaper(true);
constexpr int expectedWallpaperFlags =
AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED | AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
@@ -1848,11 +1877,11 @@
sp<FakeWindowHandle> windowLeft =
new FakeWindowHandle(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
windowLeft->setFrame(Rect(0, 0, 600, 800));
- windowLeft->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowLeft->setTouchModal(false);
sp<FakeWindowHandle> windowRight =
new FakeWindowHandle(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
windowRight->setFrame(Rect(600, 0, 1200, 800));
- windowRight->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowRight->setTouchModal(false);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -1959,7 +1988,7 @@
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Window", ADISPLAY_ID_DEFAULT);
window->setFrame(Rect(0, 0, 1200, 800));
- window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ window->setTouchModal(false);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -2041,11 +2070,11 @@
sp<FakeWindowHandle> windowLeft =
new FakeWindowHandle(application, mDispatcher, "Left", ADISPLAY_ID_DEFAULT);
windowLeft->setFrame(Rect(0, 0, 600, 800));
- windowLeft->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowLeft->setTouchModal(false);
sp<FakeWindowHandle> windowRight =
new FakeWindowHandle(application, mDispatcher, "Right", ADISPLAY_ID_DEFAULT);
windowRight->setFrame(Rect(600, 0, 1200, 800));
- windowRight->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ windowRight->setTouchModal(false);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -2151,14 +2180,14 @@
// Add two windows to the display. Their frames are represented in the display space.
sp<FakeWindowHandle> firstWindow =
new FakeWindowHandle(application, mDispatcher, "First Window", ADISPLAY_ID_DEFAULT);
- firstWindow->addFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ firstWindow->setTouchModal(false);
firstWindow->setFrame(Rect(0, 0, 100, 200), displayTransform);
addWindow(firstWindow);
sp<FakeWindowHandle> secondWindow =
new FakeWindowHandle(application, mDispatcher, "Second Window",
ADISPLAY_ID_DEFAULT);
- secondWindow->addFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ secondWindow->setTouchModal(false);
secondWindow->setFrame(Rect(100, 200, 200, 400), displayTransform);
addWindow(secondWindow);
return {std::move(firstWindow), std::move(secondWindow)};
@@ -2379,13 +2408,15 @@
sp<FakeWindowHandle> firstWindow =
new FakeWindowHandle(application, mDispatcher, "First Window", ADISPLAY_ID_DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
- firstWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ firstWindow->setTouchModal(false);
+ firstWindow->setSplitTouch(true);
// Create a non touch modal window that supports split touch
sp<FakeWindowHandle> secondWindow =
new FakeWindowHandle(application, mDispatcher, "Second Window", ADISPLAY_ID_DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
- secondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ secondWindow->setTouchModal(false);
+ secondWindow->setSplitTouch(true);
// Add the windows to the dispatcher
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow}}});
@@ -2451,13 +2482,15 @@
sp<FakeWindowHandle> firstWindow =
new FakeWindowHandle(application, mDispatcher, "First Window", ADISPLAY_ID_DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
- firstWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ firstWindow->setTouchModal(false);
+ firstWindow->setSplitTouch(true);
// Create a non touch modal window that supports split touch
sp<FakeWindowHandle> secondWindow =
new FakeWindowHandle(application, mDispatcher, "Second Window", ADISPLAY_ID_DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
- secondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ secondWindow->setTouchModal(false);
+ secondWindow->setSplitTouch(true);
// Add the windows to the dispatcher
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow}}});
@@ -2522,26 +2555,26 @@
sp<FakeWindowHandle> firstWindowInPrimary =
new FakeWindowHandle(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT);
firstWindowInPrimary->setFrame(Rect(0, 0, 100, 100));
- firstWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ firstWindowInPrimary->setTouchModal(false);
sp<FakeWindowHandle> secondWindowInPrimary =
new FakeWindowHandle(application, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT);
secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100));
- secondWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ secondWindowInPrimary->setTouchModal(false);
sp<FakeWindowHandle> mirrorWindowInPrimary =
firstWindowInPrimary->clone(application, mDispatcher, ADISPLAY_ID_DEFAULT);
mirrorWindowInPrimary->setFrame(Rect(0, 100, 100, 200));
- mirrorWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ mirrorWindowInPrimary->setTouchModal(false);
sp<FakeWindowHandle> firstWindowInSecondary =
firstWindowInPrimary->clone(application, mDispatcher, SECOND_DISPLAY_ID);
firstWindowInSecondary->setFrame(Rect(0, 0, 100, 100));
- firstWindowInSecondary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ firstWindowInSecondary->setTouchModal(false);
sp<FakeWindowHandle> secondWindowInSecondary =
secondWindowInPrimary->clone(application, mDispatcher, SECOND_DISPLAY_ID);
secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100));
- secondWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ secondWindowInPrimary->setTouchModal(false);
// Update window info, let it find window handle of second display first.
mDispatcher->setInputWindows(
@@ -2586,26 +2619,26 @@
sp<FakeWindowHandle> firstWindowInPrimary =
new FakeWindowHandle(application, mDispatcher, "D_1_W1", ADISPLAY_ID_DEFAULT);
firstWindowInPrimary->setFrame(Rect(0, 0, 100, 100));
- firstWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ firstWindowInPrimary->setTouchModal(false);
sp<FakeWindowHandle> secondWindowInPrimary =
new FakeWindowHandle(application, mDispatcher, "D_1_W2", ADISPLAY_ID_DEFAULT);
secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100));
- secondWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ secondWindowInPrimary->setTouchModal(false);
sp<FakeWindowHandle> mirrorWindowInPrimary =
firstWindowInPrimary->clone(application, mDispatcher, ADISPLAY_ID_DEFAULT);
mirrorWindowInPrimary->setFrame(Rect(0, 100, 100, 200));
- mirrorWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ mirrorWindowInPrimary->setTouchModal(false);
sp<FakeWindowHandle> firstWindowInSecondary =
firstWindowInPrimary->clone(application, mDispatcher, SECOND_DISPLAY_ID);
firstWindowInSecondary->setFrame(Rect(0, 0, 100, 100));
- firstWindowInSecondary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ firstWindowInSecondary->setTouchModal(false);
sp<FakeWindowHandle> secondWindowInSecondary =
secondWindowInPrimary->clone(application, mDispatcher, SECOND_DISPLAY_ID);
secondWindowInPrimary->setFrame(Rect(100, 0, 200, 100));
- secondWindowInPrimary->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ secondWindowInPrimary->setTouchModal(false);
// Update window info, let it find window handle of second display first.
mDispatcher->setInputWindows(
@@ -2703,13 +2736,15 @@
sp<FakeWindowHandle> firstWindow =
new FakeWindowHandle(application, mDispatcher, "First Window", ADISPLAY_ID_DEFAULT);
firstWindow->setFrame(Rect(0, 0, 600, 400));
- firstWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ firstWindow->setTouchModal(false);
+ firstWindow->setSplitTouch(true);
// Create second non touch modal window that supports split touch
sp<FakeWindowHandle> secondWindow =
new FakeWindowHandle(application, mDispatcher, "Second Window", ADISPLAY_ID_DEFAULT);
secondWindow->setFrame(Rect(0, 400, 600, 800));
- secondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ secondWindow->setTouchModal(false);
+ secondWindow->setSplitTouch(true);
// Add the windows to the dispatcher
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {firstWindow, secondWindow}}});
@@ -3376,7 +3411,8 @@
sp<FakeWindowHandle> slipperyExitWindow =
new FakeWindowHandle(application, mDispatcher, "Top", ADISPLAY_ID_DEFAULT);
- slipperyExitWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SLIPPERY);
+ slipperyExitWindow->setTouchModal(false);
+ slipperyExitWindow->setSlippery(true);
// Make sure this one overlaps the bottom window
slipperyExitWindow->setFrame(Rect(25, 25, 75, 75));
// Change the owner uid/pid of the window so that it is considered to be occluding the bottom
@@ -3984,12 +4020,12 @@
mUnfocusedWindow->setFrame(Rect(0, 0, 30, 30));
// Adding FLAG_NOT_TOUCH_MODAL to ensure taps outside this window are not sent to this
// window.
- mUnfocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ mUnfocusedWindow->setTouchModal(false);
mFocusedWindow =
new FakeWindowHandle(application, mDispatcher, "Second", ADISPLAY_ID_DEFAULT);
mFocusedWindow->setFrame(Rect(50, 50, 100, 100));
- mFocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ mFocusedWindow->setTouchModal(false);
// Set focused application.
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
@@ -4098,12 +4134,14 @@
ADISPLAY_ID_DEFAULT);
// Adding FLAG_NOT_TOUCH_MODAL otherwise all taps will go to the top most window.
// We also need FLAG_SPLIT_TOUCH or we won't be able to get touches for both windows.
- mWindow1->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ mWindow1->setTouchModal(false);
+ mWindow1->setSplitTouch(true);
mWindow1->setFrame(Rect(0, 0, 100, 100));
mWindow2 = new FakeWindowHandle(application, mDispatcher, "Fake Window 2",
ADISPLAY_ID_DEFAULT, mWindow1->getToken());
- mWindow2->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ mWindow2->setTouchModal(false);
+ mWindow2->setSplitTouch(true);
mWindow2->setFrame(Rect(100, 100, 200, 200));
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mWindow1, mWindow2}}});
@@ -4302,7 +4340,7 @@
mWindow->setFocusable(true);
// Adding FLAG_NOT_TOUCH_MODAL to ensure taps outside this window are not sent to this
// window.
- mWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ mWindow->setTouchModal(false);
// Set focused application.
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
@@ -4753,15 +4791,16 @@
// Adding FLAG_NOT_TOUCH_MODAL to ensure taps outside this window are not sent to this
// window.
// Adding FLAG_WATCH_OUTSIDE_TOUCH to receive ACTION_OUTSIDE when another window is tapped
- mUnfocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL |
- WindowInfo::Flag::WATCH_OUTSIDE_TOUCH |
- WindowInfo::Flag::SPLIT_TOUCH);
+ mUnfocusedWindow->setTouchModal(false);
+ mUnfocusedWindow->setSplitTouch(true);
+ mUnfocusedWindow->setWatchOutsideTouch(true);
mFocusedWindow =
new FakeWindowHandle(mApplication, mDispatcher, "Focused", ADISPLAY_ID_DEFAULT);
mFocusedWindow->setDispatchingTimeout(30ms);
mFocusedWindow->setFrame(Rect(50, 50, 100, 100));
- mFocusedWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ mFocusedWindow->setTouchModal(false);
+ mFocusedWindow->setSplitTouch(true);
// Set focused application.
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApplication);
@@ -5495,7 +5534,7 @@
sp<FakeWindowHandle> getOccludingWindow(int32_t uid, std::string name, TouchOcclusionMode mode,
float alpha = 1.0f) {
sp<FakeWindowHandle> window = getWindow(uid, name);
- window->setFlags(WindowInfo::Flag::NOT_TOUCHABLE);
+ window->setTouchable(false);
window->setTouchOcclusionMode(mode);
window->setAlpha(alpha);
return window;
@@ -5609,7 +5648,7 @@
WindowWithZeroOpacityAndWatchOutside_ReceivesOutsideEvent) {
const sp<FakeWindowHandle>& w =
getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, 0.0f);
- w->addFlags(WindowInfo::Flag::WATCH_OUTSIDE_TOUCH);
+ w->setWatchOutsideTouch(true);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}});
touch();
@@ -5620,7 +5659,7 @@
TEST_F(InputDispatcherUntrustedTouchesTest, OutsideEvent_HasZeroCoordinates) {
const sp<FakeWindowHandle>& w =
getOccludingWindow(APP_B_UID, "B", TouchOcclusionMode::BLOCK_UNTRUSTED, 0.0f);
- w->addFlags(WindowInfo::Flag::WATCH_OUTSIDE_TOUCH);
+ w->setWatchOutsideTouch(true);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {w, mTouchWindow}}});
touch();
@@ -5870,11 +5909,11 @@
mApp = std::make_shared<FakeApplicationHandle>();
mWindow = new FakeWindowHandle(mApp, mDispatcher, "TestWindow", ADISPLAY_ID_DEFAULT);
mWindow->setFrame(Rect(0, 0, 100, 100));
- mWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ mWindow->setTouchModal(false);
mSecondWindow = new FakeWindowHandle(mApp, mDispatcher, "TestWindow2", ADISPLAY_ID_DEFAULT);
mSecondWindow->setFrame(Rect(100, 0, 200, 100));
- mSecondWindow->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ mSecondWindow->setTouchModal(false);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, mApp);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {mWindow, mSecondWindow}}});
@@ -6129,7 +6168,7 @@
ADISPLAY_ID_DEFAULT);
obscuringWindow->setFrame(Rect(0, 0, 50, 50));
obscuringWindow->setOwnerInfo(111, 111);
- obscuringWindow->setFlags(WindowInfo::Flag::NOT_TOUCHABLE);
+ obscuringWindow->setTouchable(false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Test window", ADISPLAY_ID_DEFAULT);
@@ -6175,7 +6214,7 @@
ADISPLAY_ID_DEFAULT);
obscuringWindow->setFrame(Rect(0, 0, 50, 50));
obscuringWindow->setOwnerInfo(111, 111);
- obscuringWindow->setFlags(WindowInfo::Flag::NOT_TOUCHABLE);
+ obscuringWindow->setTouchable(false);
std::shared_ptr<FakeApplicationHandle> application = std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Test window", ADISPLAY_ID_DEFAULT);
@@ -6257,7 +6296,7 @@
class InputDispatcherSpyWindowTest : public InputDispatcherTest {
public:
- sp<FakeWindowHandle> createSpy(const Flags<WindowInfo::Flag> flags) {
+ sp<FakeWindowHandle> createSpy() {
std::shared_ptr<FakeApplicationHandle> application =
std::make_shared<FakeApplicationHandle>();
std::string name = "Fake Spy ";
@@ -6266,7 +6305,7 @@
new FakeWindowHandle(application, mDispatcher, name.c_str(), ADISPLAY_ID_DEFAULT);
spy->setInputFeatures(WindowInfo::Feature::SPY);
spy->setTrustedOverlay(true);
- spy->addFlags(flags);
+ spy->setTouchModal(false);
return spy;
}
@@ -6275,8 +6314,9 @@
std::make_shared<FakeApplicationHandle>();
sp<FakeWindowHandle> window =
new FakeWindowHandle(application, mDispatcher, "Fake Window", ADISPLAY_ID_DEFAULT);
- window->addFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
window->setFocusable(true);
+ window->setTouchModal(false);
+ window->setSplitTouch(true);
return window;
}
@@ -6291,7 +6331,7 @@
TEST_F(InputDispatcherSpyWindowDeathTest, UntrustedSpy_AbortsDispatcher) {
ScopedSilentDeath _silentDeath;
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spy = createSpy();
spy->setTrustedOverlay(false);
ASSERT_DEATH(mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy}}}),
".* not a trusted overlay");
@@ -6301,7 +6341,7 @@
* Input injection into a display with a spy window but no foreground windows should succeed.
*/
TEST_F(InputDispatcherSpyWindowTest, NoForegroundWindow) {
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spy = createSpy();
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy}}});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -6324,9 +6364,9 @@
*/
TEST_F(InputDispatcherSpyWindowTest, ReceivesInputInOrder) {
auto window = createForeground();
- auto spy1 = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
- auto spy2 = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
- auto spy3 = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spy1 = createSpy();
+ auto spy2 = createSpy();
+ auto spy3 = createSpy();
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy1, spy2, window, spy3}}});
const std::vector<sp<FakeWindowHandle>> channels{spy1, spy2, window, spy3};
const size_t numChannels = channels.size();
@@ -6377,7 +6417,8 @@
*/
TEST_F(InputDispatcherSpyWindowTest, NotTouchable) {
auto window = createForeground();
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCHABLE);
+ auto spy = createSpy();
+ spy->setTouchable(false);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -6394,7 +6435,7 @@
*/
TEST_F(InputDispatcherSpyWindowTest, TouchableRegion) {
auto window = createForeground();
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spy = createSpy();
spy->setTouchableRegion(Region{{0, 0, 20, 20}});
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
@@ -6425,8 +6466,10 @@
*/
TEST_F(InputDispatcherSpyWindowTest, ModalWindow) {
auto window = createForeground();
- auto spy = createSpy(static_cast<WindowInfo::Flag>(0));
- // This spy window does not have the NOT_TOUCH_MODAL flag set.
+ auto spy = createSpy();
+ // Our current policy dictates that modal windows must be focusable.
+ spy->setFocusable(true);
+ spy->setTouchModal(true);
spy->setFrame(Rect{0, 0, 20, 20});
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
@@ -6445,7 +6488,9 @@
TEST_F(InputDispatcherSpyWindowTest, WatchOutsideTouches) {
auto window = createForeground();
window->setOwnerInfo(12, 34);
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::WATCH_OUTSIDE_TOUCH);
+ auto spy = createSpy();
+ spy->setWatchOutsideTouch(true);
+ spy->setTouchModal(false);
spy->setOwnerInfo(56, 78);
spy->setFrame(Rect{0, 0, 20, 20});
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
@@ -6465,8 +6510,8 @@
*/
TEST_F(InputDispatcherSpyWindowTest, PilferPointers) {
auto window = createForeground();
- auto spy1 = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
- auto spy2 = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spy1 = createSpy();
+ auto spy2 = createSpy();
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy1, spy2, window}}});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -6498,7 +6543,7 @@
*/
TEST_F(InputDispatcherSpyWindowTest, CanPilferAfterWindowIsRemovedMidStream) {
auto window = createForeground();
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spy = createSpy();
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
ASSERT_EQ(InputEventInjectionResult::SUCCEEDED,
@@ -6522,9 +6567,9 @@
* the spy, but not to any other windows.
*/
TEST_F(InputDispatcherSpyWindowTest, ContinuesToReceiveGestureAfterPilfer) {
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
+ auto spy = createSpy();
+ spy->setTouchModal(false);
auto window = createForeground();
- window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
@@ -6590,7 +6635,7 @@
windowLeft->setFrame({0, 0, 100, 200});
auto windowRight = createForeground();
windowRight->setFrame({100, 0, 200, 200});
- auto spy = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spy = createSpy();
spy->setFrame({0, 0, 200, 200});
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, windowLeft, windowRight}}});
@@ -6625,7 +6670,7 @@
TEST_F(InputDispatcherSpyWindowTest, ReceivesSecondPointerAsDown) {
auto window = createForeground();
window->setFrame({0, 0, 200, 200});
- auto spyRight = createSpy(WindowInfo::Flag::NOT_TOUCH_MODAL);
+ auto spyRight = createSpy();
spyRight->setFrame({100, 0, 200, 200});
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spyRight, window}}});
@@ -6659,14 +6704,15 @@
*/
TEST_F(InputDispatcherSpyWindowTest, SplitIfNoForegroundWindowTouched) {
// Create a touch modal spy that spies on the entire display.
- // This spy window does not set the SPLIT_TOUCH flag. However, we still expect to split touches
+ // This spy window does not set split touch. However, we still expect to split touches
// because a foreground window has not disabled splitting.
- auto spy = createSpy(static_cast<WindowInfo::Flag>(0));
+ auto spy = createSpy();
+ spy->setTouchModal(true);
+ spy->setSplitTouch(false);
// Create a non touch modal window that supports split touch.
auto window = createForeground();
window->setFrame(Rect(0, 0, 100, 100));
- window->setFlags(WindowInfo::Flag::NOT_TOUCH_MODAL | WindowInfo::Flag::SPLIT_TOUCH);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {spy, window}}});
@@ -6704,7 +6750,7 @@
* do not receive key events.
*/
TEST_F(InputDispatcherSpyWindowTest, UnfocusableSpyDoesNotReceiveKeyEvents) {
- auto spy = createSpy(static_cast<WindowInfo::Flag>(0));
+ auto spy = createSpy();
spy->setFocusable(false);
auto window = createForeground();
@@ -6733,7 +6779,8 @@
ADISPLAY_ID_DEFAULT);
overlay->setFocusable(false);
overlay->setOwnerInfo(111, 111);
- overlay->setFlags(WindowInfo::Flag::NOT_TOUCHABLE | WindowInfo::Flag::SPLIT_TOUCH);
+ overlay->setTouchable(false);
+ overlay->setSplitTouch(true);
overlay->setInputFeatures(WindowInfo::Feature::INTERCEPTS_STYLUS);
overlay->setTrustedOverlay(true);
@@ -6744,7 +6791,7 @@
ADISPLAY_ID_DEFAULT);
window->setFocusable(true);
window->setOwnerInfo(222, 222);
- window->setFlags(WindowInfo::Flag::SPLIT_TOUCH);
+ window->setSplitTouch(true);
mDispatcher->setFocusedApplication(ADISPLAY_ID_DEFAULT, application);
mDispatcher->setInputWindows({{ADISPLAY_ID_DEFAULT, {overlay, window}}});