Renamed and moved InputWindow and related files
In preparation for the hierarchy listener interface, moved the
InputWindow structs into libgui and have libinput dependant on libgui.
Also renamed InputWindow to exclude Input since it will be used for more
generic purposes.
Test: Builds and flashes
Bug: 188792659
Change-Id: I24262cbc14d409c00273de0024a672394a959e5f
Merged-In: I24262cbc14d409c00273de0024a672394a959e5f
diff --git a/services/inputflinger/dispatcher/DragState.cpp b/services/inputflinger/dispatcher/DragState.cpp
index 2e2df43..e1844a4 100644
--- a/services/inputflinger/dispatcher/DragState.cpp
+++ b/services/inputflinger/dispatcher/DragState.cpp
@@ -16,9 +16,7 @@
#include "DragState.h"
#include <android-base/stringprintf.h>
-#include <input/InputWindow.h>
-using android::InputWindowHandle;
using android::base::StringPrintf;
namespace android::inputdispatcher {
diff --git a/services/inputflinger/dispatcher/DragState.h b/services/inputflinger/dispatcher/DragState.h
index 06453d8..b3c5709 100644
--- a/services/inputflinger/dispatcher/DragState.h
+++ b/services/inputflinger/dispatcher/DragState.h
@@ -17,22 +17,22 @@
#ifndef _UI_INPUT_INPUTDISPATCHER_DRAGSTATE_H
#define _UI_INPUT_INPUTDISPATCHER_DRAGSTATE_H
+#include <gui/WindowInfo.h>
#include <utils/RefBase.h>
#include <string>
namespace android {
-class InputWindowHandle;
-
namespace inputdispatcher {
+
struct DragState {
- DragState(const sp<android::InputWindowHandle>& windowHandle) : dragWindow(windowHandle) {}
+ DragState(const sp<android::gui::WindowInfoHandle>& windowHandle) : dragWindow(windowHandle) {}
void dump(std::string& dump, const char* prefix = "");
// The window being dragged.
- const sp<InputWindowHandle> dragWindow;
+ const sp<android::gui::WindowInfoHandle> dragWindow;
// The last drag hover window which could receive the drag event.
- sp<InputWindowHandle> dragHoverWindowHandle;
+ sp<android::gui::WindowInfoHandle> dragHoverWindowHandle;
// Indicates the if received first event to check for button state.
bool isStartDrag = false;
// Indicate if the stylus button is down at the start of the drag.
diff --git a/services/inputflinger/dispatcher/Entry.h b/services/inputflinger/dispatcher/Entry.h
index ebbd8e9..89d7659 100644
--- a/services/inputflinger/dispatcher/Entry.h
+++ b/services/inputflinger/dispatcher/Entry.h
@@ -20,8 +20,8 @@
#include "InjectionState.h"
#include "InputTarget.h"
+#include <gui/InputApplication.h>
#include <input/Input.h>
-#include <input/InputApplication.h>
#include <stdint.h>
#include <utils/Timers.h>
#include <functional>
diff --git a/services/inputflinger/dispatcher/FocusResolver.cpp b/services/inputflinger/dispatcher/FocusResolver.cpp
index fb19435..4a75773 100644
--- a/services/inputflinger/dispatcher/FocusResolver.cpp
+++ b/services/inputflinger/dispatcher/FocusResolver.cpp
@@ -27,12 +27,15 @@
#include <android-base/stringprintf.h>
#include <binder/Binder.h>
-#include <input/InputWindow.h>
-#include <input/NamedEnum.h>
+#include <ftl/NamedEnum.h>
+#include <gui/WindowInfo.h>
#include <log/log.h>
#include "FocusResolver.h"
+using android::gui::FocusRequest;
+using android::gui::WindowInfoHandle;
+
namespace android::inputdispatcher {
sp<IBinder> FocusResolver::getFocusedWindowToken(int32_t displayId) const {
@@ -52,7 +55,7 @@
* we will check if the previous focus request is eligible to receive focus.
*/
std::optional<FocusResolver::FocusChanges> FocusResolver::setInputWindows(
- int32_t displayId, const std::vector<sp<InputWindowHandle>>& windows) {
+ int32_t displayId, const std::vector<sp<WindowInfoHandle>>& windows) {
std::string removeFocusReason;
// Check if the currently focused window is still focusable.
@@ -87,7 +90,7 @@
}
std::optional<FocusResolver::FocusChanges> FocusResolver::setFocusedWindow(
- const FocusRequest& request, const std::vector<sp<InputWindowHandle>>& windows) {
+ const FocusRequest& request, const std::vector<sp<WindowInfoHandle>>& windows) {
const int32_t displayId = request.displayId;
const sp<IBinder> currentFocus = getFocusedWindowToken(displayId);
if (currentFocus == request.token) {
@@ -136,11 +139,11 @@
}
FocusResolver::Focusability FocusResolver::isTokenFocusable(
- const sp<IBinder>& token, const std::vector<sp<InputWindowHandle>>& windows) {
+ const sp<IBinder>& token, const std::vector<sp<WindowInfoHandle>>& windows) {
bool allWindowsAreFocusable = true;
bool visibleWindowFound = false;
bool windowFound = false;
- for (const sp<InputWindowHandle>& window : windows) {
+ for (const sp<WindowInfoHandle>& window : windows) {
if (window->getToken() != token) {
continue;
}
diff --git a/services/inputflinger/dispatcher/FocusResolver.h b/services/inputflinger/dispatcher/FocusResolver.h
index afe16b3..1d6cd9a 100644
--- a/services/inputflinger/dispatcher/FocusResolver.h
+++ b/services/inputflinger/dispatcher/FocusResolver.h
@@ -20,9 +20,9 @@
#include <optional>
#include <unordered_map>
-#include <android/FocusRequest.h>
+#include <android/gui/FocusRequest.h>
#include <binder/Binder.h>
-#include <input/InputWindow.h>
+#include <gui/WindowInfo.h>
namespace android::inputdispatcher {
@@ -58,9 +58,10 @@
std::string reason;
};
std::optional<FocusResolver::FocusChanges> setInputWindows(
- int32_t displayId, const std::vector<sp<InputWindowHandle>>& windows);
+ int32_t displayId, const std::vector<sp<android::gui::WindowInfoHandle>>& windows);
std::optional<FocusResolver::FocusChanges> setFocusedWindow(
- const FocusRequest& request, const std::vector<sp<InputWindowHandle>>& windows);
+ const android::gui::FocusRequest& request,
+ const std::vector<sp<android::gui::WindowInfoHandle>>& windows);
// Display has been removed from the system, clean up old references.
void displayRemoved(int32_t displayId);
@@ -87,8 +88,9 @@
// we expect the focusability of the windows to match since its hard to reason why one window
// can receive focus events and the other cannot when both are backed by the same input channel.
//
- static Focusability isTokenFocusable(const sp<IBinder>& token,
- const std::vector<sp<InputWindowHandle>>& windows);
+ static Focusability isTokenFocusable(
+ const sp<IBinder>& token,
+ const std::vector<sp<android::gui::WindowInfoHandle>>& windows);
// Focus tracking for keys, trackball, etc. A window token can be associated with one or
// more InputWindowHandles. If a window is mirrored, the window and its mirror will share
@@ -99,7 +101,7 @@
// This map will store the focus request per display. When the input window handles are updated,
// the current request will be checked to see if it can be processed at that time.
- std::unordered_map<int32_t /* displayId */, FocusRequest> mFocusRequestByDisplay;
+ std::unordered_map<int32_t /* displayId */, android::gui::FocusRequest> mFocusRequestByDisplay;
// Last reason for not granting a focus request. This is used to add more debug information
// in the event logs.
@@ -108,7 +110,7 @@
std::optional<FocusResolver::FocusChanges> updateFocusedWindow(
int32_t displayId, const std::string& reason, const sp<IBinder>& token,
const std::string& tokenName = "");
- std::optional<FocusRequest> getFocusRequest(int32_t displayId);
+ std::optional<android::gui::FocusRequest> getFocusRequest(int32_t displayId);
};
} // namespace android::inputdispatcher
\ No newline at end of file
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 6b8cf74..abe59d3 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -56,7 +56,6 @@
#include <binder/IServiceManager.h>
#include <com/android/internal/compat/IPlatformCompatNative.h>
#include <input/InputDevice.h>
-#include <input/InputWindow.h>
#include <log/log.h>
#include <log/log_event_list.h>
#include <powermanager/PowerManager.h>
@@ -82,6 +81,10 @@
using android::base::HwTimeoutMultiplier;
using android::base::Result;
using android::base::StringPrintf;
+using android::gui::FocusRequest;
+using android::gui::TouchOcclusionMode;
+using android::gui::WindowInfo;
+using android::gui::WindowInfoHandle;
using android::os::BlockUntrustedTouchesMode;
using android::os::IInputConstants;
using android::os::InputEventInjectionResult;
@@ -292,7 +295,7 @@
return it != map.end() ? it->second : V{};
}
-static bool haveSameToken(const sp<InputWindowHandle>& first, const sp<InputWindowHandle>& second) {
+static bool haveSameToken(const sp<WindowInfoHandle>& first, const sp<WindowInfoHandle>& second) {
if (first == second) {
return true;
}
@@ -304,7 +307,7 @@
return first->getToken() == second->getToken();
}
-static bool haveSameApplicationToken(const InputWindowInfo* first, const InputWindowInfo* second) {
+static bool haveSameApplicationToken(const WindowInfo* first, const WindowInfo* second) {
if (first == nullptr || second == nullptr) {
return false;
}
@@ -626,7 +629,7 @@
return; // The focused application has changed.
}
- const sp<InputWindowHandle>& focusedWindowHandle =
+ const sp<WindowInfoHandle>& focusedWindowHandle =
getFocusedWindowHandleLocked(mAwaitedApplicationDisplayId);
if (focusedWindowHandle != nullptr) {
return; // We now have a focused window. No need for ANR.
@@ -675,7 +678,7 @@
}
std::chrono::nanoseconds InputDispatcher::getDispatchingTimeoutLocked(const sp<IBinder>& token) {
- sp<InputWindowHandle> window = getWindowHandleLocked(token);
+ sp<WindowInfoHandle> window = getWindowHandleLocked(token);
if (window != nullptr) {
return window->getDispatchingTimeout(DEFAULT_INPUT_DISPATCHING_TIMEOUT);
}
@@ -887,7 +890,7 @@
motionEntry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X));
int32_t y = static_cast<int32_t>(
motionEntry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y));
- sp<InputWindowHandle> touchedWindowHandle =
+ sp<WindowInfoHandle> touchedWindowHandle =
findTouchedWindowAtLocked(displayId, x, y, nullptr);
if (touchedWindowHandle != nullptr &&
touchedWindowHandle->getApplicationToken() !=
@@ -992,29 +995,29 @@
}
}
-sp<InputWindowHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t displayId, int32_t x,
- int32_t y, TouchState* touchState,
- bool addOutsideTargets,
- bool addPortalWindows,
- bool ignoreDragWindow) {
+sp<WindowInfoHandle> InputDispatcher::findTouchedWindowAtLocked(int32_t displayId, int32_t x,
+ int32_t y, TouchState* touchState,
+ bool addOutsideTargets,
+ bool addPortalWindows,
+ bool ignoreDragWindow) {
if ((addPortalWindows || addOutsideTargets) && touchState == nullptr) {
LOG_ALWAYS_FATAL(
"Must provide a valid touch state if adding portal windows or outside targets");
}
// Traverse windows from front to back to find touched window.
- const std::vector<sp<InputWindowHandle>>& windowHandles = getWindowHandlesLocked(displayId);
- for (const sp<InputWindowHandle>& windowHandle : windowHandles) {
+ const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(displayId);
+ for (const sp<WindowInfoHandle>& windowHandle : windowHandles) {
if (ignoreDragWindow && haveSameToken(windowHandle, mDragState->dragWindow)) {
continue;
}
- const InputWindowInfo* windowInfo = windowHandle->getInfo();
+ const WindowInfo* windowInfo = windowHandle->getInfo();
if (windowInfo->displayId == displayId) {
auto flags = windowInfo->flags;
if (windowInfo->visible) {
- if (!flags.test(InputWindowInfo::Flag::NOT_TOUCHABLE)) {
- bool isTouchModal = !flags.test(InputWindowInfo::Flag::NOT_FOCUSABLE) &&
- !flags.test(InputWindowInfo::Flag::NOT_TOUCH_MODAL);
+ if (!flags.test(WindowInfo::Flag::NOT_TOUCHABLE)) {
+ bool isTouchModal = !flags.test(WindowInfo::Flag::NOT_FOCUSABLE) &&
+ !flags.test(WindowInfo::Flag::NOT_TOUCH_MODAL);
if (isTouchModal || windowInfo->touchableRegionContainsPoint(x, y)) {
int32_t portalToDisplayId = windowInfo->portalToDisplayId;
if (portalToDisplayId != ADISPLAY_ID_NONE &&
@@ -1031,7 +1034,7 @@
}
}
- if (addOutsideTargets && flags.test(InputWindowInfo::Flag::WATCH_OUTSIDE_TOUCH)) {
+ if (addOutsideTargets && flags.test(WindowInfo::Flag::WATCH_OUTSIDE_TOUCH)) {
touchState->addOrUpdateWindow(windowHandle,
InputTarget::FLAG_DISPATCH_AS_OUTSIDE,
BitSet32(0));
@@ -1043,13 +1046,13 @@
}
std::vector<TouchedMonitor> InputDispatcher::findTouchedGestureMonitorsLocked(
- int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const {
+ int32_t displayId, const std::vector<sp<WindowInfoHandle>>& portalWindows) const {
std::vector<TouchedMonitor> touchedMonitors;
std::vector<Monitor> monitors = getValueByKey(mGestureMonitorsByDisplay, displayId);
addGestureMonitors(monitors, touchedMonitors);
- for (const sp<InputWindowHandle>& portalWindow : portalWindows) {
- const InputWindowInfo* windowInfo = portalWindow->getInfo();
+ for (const sp<WindowInfoHandle>& portalWindow : portalWindows) {
+ const WindowInfo* windowInfo = portalWindow->getInfo();
monitors = getValueByKey(mGestureMonitorsByDisplay, windowInfo->portalToDisplayId);
addGestureMonitors(monitors, touchedMonitors, -windowInfo->frameLeft,
-windowInfo->frameTop);
@@ -1593,7 +1596,7 @@
// The event has gone through these portal windows, so we add monitoring targets of
// the corresponding displays as well.
for (size_t i = 0; i < state.portalWindows.size(); i++) {
- const InputWindowInfo* windowInfo = state.portalWindows[i]->getInfo();
+ const WindowInfo* windowInfo = state.portalWindows[i]->getInfo();
addGlobalMonitoringTargetsLocked(inputTargets, windowInfo->portalToDisplayId,
-windowInfo->frameLeft, -windowInfo->frameTop);
}
@@ -1611,7 +1614,7 @@
return true;
}
-void InputDispatcher::enqueueDragEventLocked(const sp<InputWindowHandle>& windowHandle,
+void InputDispatcher::enqueueDragEventLocked(const sp<WindowInfoHandle>& windowHandle,
bool isExiting, const MotionEntry& motionEntry) {
// If the window needs enqueue a drag event, the pointerCount should be 1 and the action should
// be AMOTION_EVENT_ACTION_MOVE, that could guarantee the first pointer is always valid.
@@ -1791,7 +1794,7 @@
std::string reason;
int32_t displayId = getTargetDisplayId(entry);
- sp<InputWindowHandle> focusedWindowHandle = getFocusedWindowHandleLocked(displayId);
+ sp<WindowInfoHandle> focusedWindowHandle = getFocusedWindowHandleLocked(displayId);
std::shared_ptr<InputApplicationHandle> focusedApplicationHandle =
getValueByKey(mFocusedApplicationHandlesByDisplay, displayId);
@@ -1918,8 +1921,8 @@
// Update the touch state as needed based on the properties of the touch event.
InputEventInjectionResult injectionResult = InputEventInjectionResult::PENDING;
InjectionPermission injectionPermission = INJECTION_PERMISSION_UNKNOWN;
- sp<InputWindowHandle> newHoverWindowHandle(mLastHoverWindowHandle);
- sp<InputWindowHandle> newTouchedWindowHandle;
+ sp<WindowInfoHandle> newHoverWindowHandle(mLastHoverWindowHandle);
+ sp<WindowInfoHandle> newTouchedWindowHandle;
// Copy current touch state into tempTouchState.
// This state will be used to update mTouchStatesByDisplay at the end of this function.
@@ -2112,7 +2115,7 @@
int32_t x = int32_t(entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X));
int32_t y = int32_t(entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y));
- sp<InputWindowHandle> oldTouchedWindowHandle =
+ sp<WindowInfoHandle> oldTouchedWindowHandle =
tempTouchState.getFirstForegroundWindowHandle();
newTouchedWindowHandle = findTouchedWindowAtLocked(displayId, x, y, &tempTouchState);
if (oldTouchedWindowHandle != newTouchedWindowHandle &&
@@ -2211,15 +2214,15 @@
// Check whether windows listening for outside touches are owned by the same UID. If it is
// set the policy flag that we will not reveal coordinate information to this window.
if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
- sp<InputWindowHandle> foregroundWindowHandle =
+ sp<WindowInfoHandle> foregroundWindowHandle =
tempTouchState.getFirstForegroundWindowHandle();
if (foregroundWindowHandle) {
const int32_t foregroundWindowUid = foregroundWindowHandle->getInfo()->ownerUid;
for (const TouchedWindow& touchedWindow : tempTouchState.windows) {
if (touchedWindow.targetFlags & InputTarget::FLAG_DISPATCH_AS_OUTSIDE) {
- sp<InputWindowHandle> inputWindowHandle = touchedWindow.windowHandle;
- if (inputWindowHandle->getInfo()->ownerUid != foregroundWindowUid) {
- tempTouchState.addOrUpdateWindow(inputWindowHandle,
+ sp<WindowInfoHandle> windowInfoHandle = touchedWindow.windowHandle;
+ if (windowInfoHandle->getInfo()->ownerUid != foregroundWindowUid) {
+ tempTouchState.addOrUpdateWindow(windowInfoHandle,
InputTarget::FLAG_ZERO_COORDS,
BitSet32(0));
}
@@ -2235,15 +2238,15 @@
// engine only supports touch events. We would need to add a mechanism similar
// to View.onGenericMotionEvent to enable wallpapers to handle these events.
if (maskedAction == AMOTION_EVENT_ACTION_DOWN) {
- sp<InputWindowHandle> foregroundWindowHandle =
+ sp<WindowInfoHandle> foregroundWindowHandle =
tempTouchState.getFirstForegroundWindowHandle();
if (foregroundWindowHandle && foregroundWindowHandle->getInfo()->hasWallpaper) {
- const std::vector<sp<InputWindowHandle>>& windowHandles =
+ const std::vector<sp<WindowInfoHandle>>& windowHandles =
getWindowHandlesLocked(displayId);
- for (const sp<InputWindowHandle>& windowHandle : windowHandles) {
- const InputWindowInfo* info = windowHandle->getInfo();
+ for (const sp<WindowInfoHandle>& windowHandle : windowHandles) {
+ const WindowInfo* info = windowHandle->getInfo();
if (info->displayId == displayId &&
- windowHandle->getInfo()->type == InputWindowInfo::Type::WALLPAPER) {
+ windowHandle->getInfo()->type == WindowInfo::Type::WALLPAPER) {
tempTouchState
.addOrUpdateWindow(windowHandle,
InputTarget::FLAG_WINDOW_IS_OBSCURED |
@@ -2362,7 +2365,7 @@
}
void InputDispatcher::finishDragAndDrop(int32_t displayId, float x, float y) {
- const sp<InputWindowHandle> dropWindow =
+ const sp<WindowInfoHandle> dropWindow =
findTouchedWindowAtLocked(displayId, x, y, nullptr /*touchState*/,
false /*addOutsideTargets*/, false /*addPortalWindows*/,
true /*ignoreDragWindow*/);
@@ -2397,7 +2400,7 @@
return;
}
- const sp<InputWindowHandle> hoverWindowHandle =
+ const sp<WindowInfoHandle> hoverWindowHandle =
findTouchedWindowAtLocked(entry.displayId, x, y, nullptr /*touchState*/,
false /*addOutsideTargets*/, false /*addPortalWindows*/,
true /*ignoreDragWindow*/);
@@ -2422,7 +2425,7 @@
}
}
-void InputDispatcher::addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle,
+void InputDispatcher::addWindowTargetLocked(const sp<WindowInfoHandle>& windowHandle,
int32_t targetFlags, BitSet32 pointerIds,
std::vector<InputTarget>& inputTargets) {
std::vector<InputTarget>::iterator it =
@@ -2432,7 +2435,7 @@
windowHandle->getToken();
});
- const InputWindowInfo* windowInfo = windowHandle->getInfo();
+ const WindowInfo* windowInfo = windowHandle->getInfo();
if (it == inputTargets.end()) {
InputTarget inputTarget;
@@ -2483,7 +2486,7 @@
inputTargets.push_back(target);
}
-bool InputDispatcher::checkInjectionPermission(const sp<InputWindowHandle>& windowHandle,
+bool InputDispatcher::checkInjectionPermission(const sp<WindowInfoHandle>& windowHandle,
const InjectionState* injectionState) {
if (injectionState &&
(windowHandle == nullptr ||
@@ -2508,8 +2511,8 @@
* another window handle. We only check a few preconditions. Actually
* checking the bounds is left to the caller.
*/
-static bool canBeObscuredBy(const sp<InputWindowHandle>& windowHandle,
- const sp<InputWindowHandle>& otherHandle) {
+static bool canBeObscuredBy(const sp<WindowInfoHandle>& windowHandle,
+ const sp<WindowInfoHandle>& otherHandle) {
// Compare by token so cloned layers aren't counted
if (haveSameToken(windowHandle, otherHandle)) {
return false;
@@ -2518,8 +2521,7 @@
auto otherInfo = otherHandle->getInfo();
if (!otherInfo->visible) {
return false;
- } else if (otherInfo->alpha == 0 &&
- otherInfo->flags.test(InputWindowInfo::Flag::NOT_TOUCHABLE)) {
+ } else if (otherInfo->alpha == 0 && otherInfo->flags.test(WindowInfo::Flag::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
@@ -2557,20 +2559,20 @@
* If neither of those is true, then it means the touch can be allowed.
*/
InputDispatcher::TouchOcclusionInfo InputDispatcher::computeTouchOcclusionInfoLocked(
- const sp<InputWindowHandle>& windowHandle, int32_t x, int32_t y) const {
- const InputWindowInfo* windowInfo = windowHandle->getInfo();
+ const sp<WindowInfoHandle>& windowHandle, int32_t x, int32_t y) const {
+ const WindowInfo* windowInfo = windowHandle->getInfo();
int32_t displayId = windowInfo->displayId;
- const std::vector<sp<InputWindowHandle>>& windowHandles = getWindowHandlesLocked(displayId);
+ const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(displayId);
TouchOcclusionInfo info;
info.hasBlockingOcclusion = false;
info.obscuringOpacity = 0;
info.obscuringUid = -1;
std::map<int32_t, float> opacityByUid;
- for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
+ for (const sp<WindowInfoHandle>& otherHandle : windowHandles) {
if (windowHandle == otherHandle) {
break; // All future windows are below us. Exit early.
}
- const InputWindowInfo* otherInfo = otherHandle->getInfo();
+ const WindowInfo* otherInfo = otherHandle->getInfo();
if (canBeObscuredBy(windowHandle, otherHandle) && otherInfo->frameContainsPoint(x, y) &&
!haveSameApplicationToken(windowInfo, otherInfo)) {
if (DEBUG_TOUCH_OCCLUSION) {
@@ -2609,7 +2611,7 @@
return info;
}
-std::string InputDispatcher::dumpWindowForTouchOcclusion(const InputWindowInfo* info,
+std::string InputDispatcher::dumpWindowForTouchOcclusion(const WindowInfo* info,
bool isTouchedWindow) const {
return StringPrintf(INDENT2
"* %stype=%s, package=%s/%" PRId32 ", id=%" PRId32 ", mode=%s, alpha=%.2f, "
@@ -2643,15 +2645,15 @@
return true;
}
-bool InputDispatcher::isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle,
+bool InputDispatcher::isWindowObscuredAtPointLocked(const sp<WindowInfoHandle>& windowHandle,
int32_t x, int32_t y) const {
int32_t displayId = windowHandle->getInfo()->displayId;
- const std::vector<sp<InputWindowHandle>>& windowHandles = getWindowHandlesLocked(displayId);
- for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
+ const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(displayId);
+ for (const sp<WindowInfoHandle>& otherHandle : windowHandles) {
if (windowHandle == otherHandle) {
break; // All future windows are below us. Exit early.
}
- const InputWindowInfo* otherInfo = otherHandle->getInfo();
+ const WindowInfo* otherInfo = otherHandle->getInfo();
if (canBeObscuredBy(windowHandle, otherHandle) &&
otherInfo->frameContainsPoint(x, y)) {
return true;
@@ -2660,15 +2662,15 @@
return false;
}
-bool InputDispatcher::isWindowObscuredLocked(const sp<InputWindowHandle>& windowHandle) const {
+bool InputDispatcher::isWindowObscuredLocked(const sp<WindowInfoHandle>& windowHandle) const {
int32_t displayId = windowHandle->getInfo()->displayId;
- const std::vector<sp<InputWindowHandle>>& windowHandles = getWindowHandlesLocked(displayId);
- const InputWindowInfo* windowInfo = windowHandle->getInfo();
- for (const sp<InputWindowHandle>& otherHandle : windowHandles) {
+ const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(displayId);
+ const WindowInfo* windowInfo = windowHandle->getInfo();
+ for (const sp<WindowInfoHandle>& otherHandle : windowHandles) {
if (windowHandle == otherHandle) {
break; // All future windows are below us. Exit early.
}
- const InputWindowInfo* otherInfo = otherHandle->getInfo();
+ const WindowInfo* otherInfo = otherHandle->getInfo();
if (canBeObscuredBy(windowHandle, otherHandle) &&
otherInfo->overlaps(windowInfo)) {
return true;
@@ -2678,8 +2680,7 @@
}
std::string InputDispatcher::getApplicationWindowLabel(
- const InputApplicationHandle* applicationHandle,
- const sp<InputWindowHandle>& windowHandle) {
+ const InputApplicationHandle* applicationHandle, const sp<WindowInfoHandle>& windowHandle) {
if (applicationHandle != nullptr) {
if (windowHandle != nullptr) {
return applicationHandle->getName() + " - " + windowHandle->getName();
@@ -2702,10 +2703,10 @@
return;
}
int32_t displayId = getTargetDisplayId(eventEntry);
- sp<InputWindowHandle> focusedWindowHandle = getFocusedWindowHandleLocked(displayId);
+ sp<WindowInfoHandle> focusedWindowHandle = getFocusedWindowHandleLocked(displayId);
if (focusedWindowHandle != nullptr) {
- const InputWindowInfo* info = focusedWindowHandle->getInfo();
- if (info->inputFeatures.test(InputWindowInfo::Feature::DISABLE_USER_ACTIVITY)) {
+ const WindowInfo* info = focusedWindowHandle->getInfo();
+ if (info->inputFeatures.test(WindowInfo::Feature::DISABLE_USER_ACTIVITY)) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("Not poking user activity: disabled by window '%s'.", info->name.c_str());
#endif
@@ -3476,10 +3477,10 @@
#endif
InputTarget target;
- sp<InputWindowHandle> windowHandle =
+ sp<WindowInfoHandle> windowHandle =
getWindowHandleLocked(connection->inputChannel->getConnectionToken());
if (windowHandle != nullptr) {
- const InputWindowInfo* windowInfo = windowHandle->getInfo();
+ const WindowInfo* windowInfo = windowHandle->getInfo();
target.setDefaultPointerTransform(windowInfo->transform);
target.globalScaleFactor = windowInfo->globalScaleFactor;
}
@@ -3543,10 +3544,10 @@
#endif
InputTarget target;
- sp<InputWindowHandle> windowHandle =
+ sp<WindowInfoHandle> windowHandle =
getWindowHandleLocked(connection->inputChannel->getConnectionToken());
if (windowHandle != nullptr) {
- const InputWindowInfo* windowInfo = windowHandle->getInfo();
+ const WindowInfo* windowInfo = windowHandle->getInfo();
target.setDefaultPointerTransform(windowInfo->transform);
target.globalScaleFactor = windowInfo->globalScaleFactor;
}
@@ -3872,9 +3873,9 @@
args->action, args->actionButton, args->flags, args->edgeFlags,
args->metaState, args->buttonState, args->classification, transform,
args->xPrecision, args->yPrecision, args->xCursorPosition,
- args->yCursorPosition, AMOTION_EVENT_INVALID_DISPLAY_SIZE,
- AMOTION_EVENT_INVALID_DISPLAY_SIZE, args->downTime, args->eventTime,
- args->pointerCount, args->pointerProperties, args->pointerCoords);
+ args->yCursorPosition, INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE,
+ args->downTime, args->eventTime, args->pointerCount,
+ args->pointerProperties, args->pointerCoords);
policyFlags |= POLICY_FLAG_FILTERED;
if (!mPolicy->filterInputEvent(&event, policyFlags)) {
@@ -4312,22 +4313,22 @@
}
}
-const std::vector<sp<InputWindowHandle>>& InputDispatcher::getWindowHandlesLocked(
+const std::vector<sp<WindowInfoHandle>>& InputDispatcher::getWindowHandlesLocked(
int32_t displayId) const {
- static const std::vector<sp<InputWindowHandle>> EMPTY_WINDOW_HANDLES;
+ static const std::vector<sp<WindowInfoHandle>> EMPTY_WINDOW_HANDLES;
auto it = mWindowHandlesByDisplay.find(displayId);
return it != mWindowHandlesByDisplay.end() ? it->second : EMPTY_WINDOW_HANDLES;
}
-sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked(
+sp<WindowInfoHandle> InputDispatcher::getWindowHandleLocked(
const sp<IBinder>& windowHandleToken) const {
if (windowHandleToken == nullptr) {
return nullptr;
}
for (auto& it : mWindowHandlesByDisplay) {
- const std::vector<sp<InputWindowHandle>>& windowHandles = it.second;
- for (const sp<InputWindowHandle>& windowHandle : windowHandles) {
+ const std::vector<sp<WindowInfoHandle>>& windowHandles = it.second;
+ for (const sp<WindowInfoHandle>& windowHandle : windowHandles) {
if (windowHandle->getToken() == windowHandleToken) {
return windowHandle;
}
@@ -4336,13 +4337,13 @@
return nullptr;
}
-sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked(const sp<IBinder>& windowHandleToken,
- int displayId) const {
+sp<WindowInfoHandle> InputDispatcher::getWindowHandleLocked(const sp<IBinder>& windowHandleToken,
+ int displayId) const {
if (windowHandleToken == nullptr) {
return nullptr;
}
- for (const sp<InputWindowHandle>& windowHandle : getWindowHandlesLocked(displayId)) {
+ for (const sp<WindowInfoHandle>& windowHandle : getWindowHandlesLocked(displayId)) {
if (windowHandle->getToken() == windowHandleToken) {
return windowHandle;
}
@@ -4350,11 +4351,11 @@
return nullptr;
}
-sp<InputWindowHandle> InputDispatcher::getWindowHandleLocked(
- const sp<InputWindowHandle>& windowHandle) const {
+sp<WindowInfoHandle> InputDispatcher::getWindowHandleLocked(
+ const sp<WindowInfoHandle>& windowHandle) const {
for (auto& it : mWindowHandlesByDisplay) {
- const std::vector<sp<InputWindowHandle>>& windowHandles = it.second;
- for (const sp<InputWindowHandle>& handle : windowHandles) {
+ const std::vector<sp<WindowInfoHandle>>& windowHandles = it.second;
+ for (const sp<WindowInfoHandle>& handle : windowHandles) {
if (handle->getId() == windowHandle->getId() &&
handle->getToken() == windowHandle->getToken()) {
if (windowHandle->getInfo()->displayId != it.first) {
@@ -4370,15 +4371,15 @@
return nullptr;
}
-sp<InputWindowHandle> InputDispatcher::getFocusedWindowHandleLocked(int displayId) const {
+sp<WindowInfoHandle> InputDispatcher::getFocusedWindowHandleLocked(int displayId) const {
sp<IBinder> focusedToken = mFocusResolver.getFocusedWindowToken(displayId);
return getWindowHandleLocked(focusedToken, displayId);
}
-bool InputDispatcher::hasResponsiveConnectionLocked(InputWindowHandle& windowHandle) const {
+bool InputDispatcher::hasResponsiveConnectionLocked(WindowInfoHandle& windowHandle) const {
sp<Connection> connection = getConnectionLocked(windowHandle.getToken());
const bool noInputChannel =
- windowHandle.getInfo()->inputFeatures.test(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
+ windowHandle.getInfo()->inputFeatures.test(WindowInfo::Feature::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());
@@ -4408,8 +4409,8 @@
}
void InputDispatcher::updateWindowHandlesForDisplayLocked(
- const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) {
- if (inputWindowHandles.empty()) {
+ const std::vector<sp<WindowInfoHandle>>& windowInfoHandles, int32_t displayId) {
+ if (windowInfoHandles.empty()) {
// Remove all handles on a display if there are no windows left.
mWindowHandlesByDisplay.erase(displayId);
return;
@@ -4417,26 +4418,26 @@
// Since we compare the pointer of input window handles across window updates, we need
// to make sure the handle object for the same window stays unchanged across updates.
- const std::vector<sp<InputWindowHandle>>& oldHandles = getWindowHandlesLocked(displayId);
- std::unordered_map<int32_t /*id*/, sp<InputWindowHandle>> oldHandlesById;
- for (const sp<InputWindowHandle>& handle : oldHandles) {
+ const std::vector<sp<WindowInfoHandle>>& oldHandles = getWindowHandlesLocked(displayId);
+ std::unordered_map<int32_t /*id*/, sp<WindowInfoHandle>> oldHandlesById;
+ for (const sp<WindowInfoHandle>& handle : oldHandles) {
oldHandlesById[handle->getId()] = handle;
}
- std::vector<sp<InputWindowHandle>> newHandles;
- for (const sp<InputWindowHandle>& handle : inputWindowHandles) {
+ std::vector<sp<WindowInfoHandle>> newHandles;
+ for (const sp<WindowInfoHandle>& handle : windowInfoHandles) {
if (!handle->updateInfo()) {
// handle no longer valid
continue;
}
- const InputWindowInfo* info = handle->getInfo();
+ const WindowInfo* info = handle->getInfo();
if ((getInputChannelLocked(handle->getToken()) == nullptr &&
info->portalToDisplayId == ADISPLAY_ID_NONE)) {
const bool noInputChannel =
- info->inputFeatures.test(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
- const bool canReceiveInput = !info->flags.test(InputWindowInfo::Flag::NOT_TOUCHABLE) ||
- !info->flags.test(InputWindowInfo::Flag::NOT_FOCUSABLE);
+ 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);
if (canReceiveInput && !noInputChannel) {
ALOGV("Window handle %s has no registered input channel",
handle->getName().c_str());
@@ -4452,7 +4453,7 @@
if ((oldHandlesById.find(handle->getId()) != oldHandlesById.end()) &&
(oldHandlesById.at(handle->getId())->getToken() == handle->getToken())) {
- const sp<InputWindowHandle>& oldHandle = oldHandlesById.at(handle->getId());
+ const sp<WindowInfoHandle>& oldHandle = oldHandlesById.at(handle->getId());
oldHandle->updateFrom(handle);
newHandles.push_back(oldHandle);
} else {
@@ -4465,7 +4466,7 @@
}
void InputDispatcher::setInputWindows(
- const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>& handlesPerDisplay) {
+ const std::unordered_map<int32_t, std::vector<sp<WindowInfoHandle>>>& handlesPerDisplay) {
{ // acquire lock
std::scoped_lock _l(mLock);
for (const auto& [displayId, handles] : handlesPerDisplay) {
@@ -4484,19 +4485,19 @@
* For removed handle, check if need to send a cancel event if already in touch.
*/
void InputDispatcher::setInputWindowsLocked(
- const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId) {
+ const std::vector<sp<WindowInfoHandle>>& windowInfoHandles, int32_t displayId) {
if (DEBUG_FOCUS) {
std::string windowList;
- for (const sp<InputWindowHandle>& iwh : inputWindowHandles) {
+ for (const sp<WindowInfoHandle>& iwh : windowInfoHandles) {
windowList += iwh->getName() + " ";
}
ALOGD("setInputWindows displayId=%" PRId32 " %s", displayId, windowList.c_str());
}
// Ensure all tokens are null if the window has feature NO_INPUT_CHANNEL
- for (const sp<InputWindowHandle>& window : inputWindowHandles) {
+ for (const sp<WindowInfoHandle>& window : windowInfoHandles) {
const bool noInputWindow =
- window->getInfo()->inputFeatures.test(InputWindowInfo::Feature::NO_INPUT_CHANNEL);
+ window->getInfo()->inputFeatures.test(WindowInfo::Feature::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());
@@ -4505,18 +4506,18 @@
}
// Copy old handles for release if they are no longer present.
- const std::vector<sp<InputWindowHandle>> oldWindowHandles = getWindowHandlesLocked(displayId);
+ const std::vector<sp<WindowInfoHandle>> oldWindowHandles = getWindowHandlesLocked(displayId);
// Save the old windows' orientation by ID before it gets updated.
std::unordered_map<int32_t, uint32_t> oldWindowOrientations;
- for (const sp<InputWindowHandle>& handle : oldWindowHandles) {
+ for (const sp<WindowInfoHandle>& handle : oldWindowHandles) {
oldWindowOrientations.emplace(handle->getId(),
handle->getInfo()->transform.getOrientation());
}
- updateWindowHandlesForDisplayLocked(inputWindowHandles, displayId);
+ updateWindowHandlesForDisplayLocked(windowInfoHandles, displayId);
- const std::vector<sp<InputWindowHandle>>& windowHandles = getWindowHandlesLocked(displayId);
+ const std::vector<sp<WindowInfoHandle>>& windowHandles = getWindowHandlesLocked(displayId);
if (mLastHoverWindowHandle &&
std::find(windowHandles.begin(), windowHandles.end(), mLastHoverWindowHandle) ==
windowHandles.end()) {
@@ -4565,8 +4566,8 @@
if (isPerWindowInputRotationEnabled()) {
// Determine if the orientation of any of the input windows have changed, and cancel all
// pointer events if necessary.
- for (const sp<InputWindowHandle>& oldWindowHandle : oldWindowHandles) {
- const sp<InputWindowHandle> newWindowHandle = getWindowHandleLocked(oldWindowHandle);
+ for (const sp<WindowInfoHandle>& oldWindowHandle : oldWindowHandles) {
+ const sp<WindowInfoHandle> newWindowHandle = getWindowHandleLocked(oldWindowHandle);
if (newWindowHandle != nullptr &&
newWindowHandle->getInfo()->transform.getOrientation() !=
oldWindowOrientations[oldWindowHandle->getId()]) {
@@ -4585,7 +4586,7 @@
// This ensures that unused input channels are released promptly.
// Otherwise, they might stick around until the window handle is destroyed
// which might not happen until the next GC.
- for (const sp<InputWindowHandle>& oldWindowHandle : oldWindowHandles) {
+ for (const sp<WindowInfoHandle>& oldWindowHandle : oldWindowHandles) {
if (getWindowHandleLocked(oldWindowHandle) == nullptr) {
if (DEBUG_FOCUS) {
ALOGD("Window went away: %s", oldWindowHandle->getName().c_str());
@@ -4595,7 +4596,7 @@
// check for window flags when windows are going away.
// TODO(b/157929241) : delete this. This is only needed temporarily
// in order to gather some data about the flag usage
- if (oldWindowHandle->getInfo()->flags.test(InputWindowInfo::Flag::SLIPPERY)) {
+ if (oldWindowHandle->getInfo()->flags.test(WindowInfo::Flag::SLIPPERY)) {
ALOGW("%s has FLAG_SLIPPERY. Please report this in b/157929241",
oldWindowHandle->getName().c_str());
if (mCompatService != nullptr) {
@@ -4785,8 +4786,8 @@
{ // acquire lock
std::scoped_lock _l(mLock);
- sp<InputWindowHandle> fromWindowHandle = getWindowHandleLocked(fromToken);
- sp<InputWindowHandle> toWindowHandle = getWindowHandleLocked(toToken);
+ sp<WindowInfoHandle> fromWindowHandle = getWindowHandleLocked(fromToken);
+ sp<WindowInfoHandle> toWindowHandle = getWindowHandleLocked(toToken);
if (fromWindowHandle == nullptr || toWindowHandle == nullptr) {
ALOGW("Cannot transfer focus because from or to window not found.");
return false;
@@ -4864,7 +4865,7 @@
{ // acquire lock
std::scoped_lock _l(mLock);
- sp<InputWindowHandle> toWindowHandle = getWindowHandleLocked(destChannelToken);
+ sp<WindowInfoHandle> toWindowHandle = getWindowHandleLocked(destChannelToken);
if (toWindowHandle == nullptr) {
ALOGW("Could not find window associated with token=%p", destChannelToken.get());
return false;
@@ -4931,7 +4932,7 @@
std::string windowName = "None";
if (mWindowTokenWithPointerCapture) {
- const sp<InputWindowHandle> captureWindowHandle =
+ const sp<WindowInfoHandle> captureWindowHandle =
getWindowHandleLocked(mWindowTokenWithPointerCapture);
windowName = captureWindowHandle ? captureWindowHandle->getName().c_str()
: "token has capture without window";
@@ -4987,7 +4988,7 @@
if (!state.portalWindows.empty()) {
dump += INDENT3 "Portal windows:\n";
for (size_t i = 0; i < state.portalWindows.size(); i++) {
- const sp<InputWindowHandle> portalWindowHandle = state.portalWindows[i];
+ const sp<WindowInfoHandle> portalWindowHandle = state.portalWindows[i];
dump += StringPrintf(INDENT4 "%zu: name='%s'\n", i,
portalWindowHandle->getName().c_str());
}
@@ -5004,13 +5005,13 @@
if (!mWindowHandlesByDisplay.empty()) {
for (auto& it : mWindowHandlesByDisplay) {
- const std::vector<sp<InputWindowHandle>> windowHandles = it.second;
+ const std::vector<sp<WindowInfoHandle>> windowHandles = it.second;
dump += StringPrintf(INDENT "Display: %" PRId32 "\n", it.first);
if (!windowHandles.empty()) {
dump += INDENT2 "Windows:\n";
for (size_t i = 0; i < windowHandles.size(); i++) {
- const sp<InputWindowHandle>& windowHandle = windowHandles[i];
- const InputWindowInfo* windowInfo = windowHandle->getInfo();
+ const sp<WindowInfoHandle>& windowHandle = windowHandles[i];
+ const WindowInfo* windowInfo = windowHandle->getInfo();
dump += StringPrintf(INDENT3 "%zu: name='%s', id=%" PRId32 ", displayId=%d, "
"portalToDisplayId=%d, paused=%s, focusable=%s, "
@@ -5391,7 +5392,7 @@
{ // acquire lock
std::scoped_lock _l(mLock);
if (DEBUG_FOCUS) {
- const sp<InputWindowHandle> windowHandle = getWindowHandleLocked(windowToken);
+ const sp<WindowInfoHandle> windowHandle = getWindowHandleLocked(windowToken);
ALOGI("Request to %s Pointer Capture from: %s.", enabled ? "enable" : "disable",
windowHandle != nullptr ? windowHandle->getName().c_str()
: "token without window");
@@ -5562,7 +5563,7 @@
postCommandLocked(std::move(commandEntry));
}
-void InputDispatcher::updateLastAnrStateLocked(const sp<InputWindowHandle>& window,
+void InputDispatcher::updateLastAnrStateLocked(const sp<WindowInfoHandle>& window,
const std::string& reason) {
const std::string windowLabel = getApplicationWindowLabel(nullptr, window);
updateLastAnrStateLocked(windowLabel, reason);
diff --git a/services/inputflinger/dispatcher/InputDispatcher.h b/services/inputflinger/dispatcher/InputDispatcher.h
index 9edf41c..87dd6ee 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.h
+++ b/services/inputflinger/dispatcher/InputDispatcher.h
@@ -37,10 +37,10 @@
#include <attestation/HmacKeyManager.h>
#include <com/android/internal/compat/IPlatformCompatNative.h>
+#include <gui/InputApplication.h>
+#include <gui/WindowInfo.h>
#include <input/Input.h>
-#include <input/InputApplication.h>
#include <input/InputTransport.h>
-#include <input/InputWindow.h>
#include <limits.h>
#include <stddef.h>
#include <ui/Region.h>
@@ -109,8 +109,9 @@
std::unique_ptr<VerifiedInputEvent> verifyInputEvent(const InputEvent& event) override;
- void setInputWindows(const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>&
- handlesPerDisplay) override;
+ void setInputWindows(
+ const std::unordered_map<int32_t, std::vector<sp<android::gui::WindowInfoHandle>>>&
+ handlesPerDisplay) override;
void setFocusedApplication(
int32_t displayId,
const std::shared_ptr<InputApplicationHandle>& inputApplicationHandle) override;
@@ -127,7 +128,7 @@
base::Result<std::unique_ptr<InputChannel>> createInputChannel(
const std::string& name) override;
- void setFocusedWindow(const FocusRequest&) override;
+ void setFocusedWindow(const android::gui::FocusRequest&) override;
base::Result<std::unique_ptr<InputChannel>> createInputMonitor(int32_t displayId,
bool isGestureMonitor,
const std::string& name,
@@ -190,8 +191,8 @@
void enqueueFocusEventLocked(const sp<IBinder>& windowToken, bool hasFocus,
const std::string& reason) REQUIRES(mLock);
// Enqueues a drag event.
- void enqueueDragEventLocked(const sp<InputWindowHandle>& windowToken, bool isExiting,
- const MotionEntry& motionEntry) REQUIRES(mLock);
+ void enqueueDragEventLocked(const sp<android::gui::WindowInfoHandle>& windowToken,
+ bool isExiting, const MotionEntry& motionEntry) REQUIRES(mLock);
// Adds an event to a queue of recent events for debugging purposes.
void addRecentEventLocked(std::shared_ptr<EventEntry> entry) REQUIRES(mLock);
@@ -208,11 +209,12 @@
// to transfer focus to a new application.
std::shared_ptr<EventEntry> mNextUnblockedEvent GUARDED_BY(mLock);
- sp<InputWindowHandle> findTouchedWindowAtLocked(int32_t displayId, int32_t x, int32_t y,
- TouchState* touchState,
- bool addOutsideTargets = false,
- bool addPortalWindows = false,
- bool ignoreDragWindow = false) REQUIRES(mLock);
+ sp<android::gui::WindowInfoHandle> findTouchedWindowAtLocked(int32_t displayId, int32_t x,
+ int32_t y, TouchState* touchState,
+ bool addOutsideTargets = false,
+ bool addPortalWindows = false,
+ bool ignoreDragWindow = false)
+ REQUIRES(mLock);
sp<Connection> getConnectionLocked(const sp<IBinder>& inputConnectionToken) const
REQUIRES(mLock);
@@ -314,33 +316,36 @@
float mMaximumObscuringOpacityForTouch GUARDED_BY(mLock);
android::os::BlockUntrustedTouchesMode mBlockUntrustedTouchesMode GUARDED_BY(mLock);
- std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>> mWindowHandlesByDisplay
- GUARDED_BY(mLock);
- void setInputWindowsLocked(const std::vector<sp<InputWindowHandle>>& inputWindowHandles,
- int32_t displayId) REQUIRES(mLock);
+ std::unordered_map<int32_t, std::vector<sp<android::gui::WindowInfoHandle>>>
+ mWindowHandlesByDisplay GUARDED_BY(mLock);
+ void setInputWindowsLocked(
+ const std::vector<sp<android::gui::WindowInfoHandle>>& inputWindowHandles,
+ int32_t displayId) REQUIRES(mLock);
// Get a reference to window handles by display, return an empty vector if not found.
- const std::vector<sp<InputWindowHandle>>& getWindowHandlesLocked(int32_t displayId) const
- REQUIRES(mLock);
- sp<InputWindowHandle> getWindowHandleLocked(const sp<IBinder>& windowHandleToken) const
- REQUIRES(mLock);
+ const std::vector<sp<android::gui::WindowInfoHandle>>& getWindowHandlesLocked(
+ int32_t displayId) const REQUIRES(mLock);
+ sp<android::gui::WindowInfoHandle> getWindowHandleLocked(
+ const sp<IBinder>& windowHandleToken) const REQUIRES(mLock);
// Same function as above, but faster. Since displayId is provided, this avoids the need
// to loop through all displays.
- sp<InputWindowHandle> getWindowHandleLocked(const sp<IBinder>& windowHandleToken,
- int displayId) const REQUIRES(mLock);
- sp<InputWindowHandle> getWindowHandleLocked(const sp<InputWindowHandle>& windowHandle) const
- REQUIRES(mLock);
+ sp<android::gui::WindowInfoHandle> getWindowHandleLocked(const sp<IBinder>& windowHandleToken,
+ int displayId) const REQUIRES(mLock);
+ sp<android::gui::WindowInfoHandle> getWindowHandleLocked(
+ const sp<android::gui::WindowInfoHandle>& windowHandle) const REQUIRES(mLock);
std::shared_ptr<InputChannel> getInputChannelLocked(const sp<IBinder>& windowToken) const
REQUIRES(mLock);
- sp<InputWindowHandle> getFocusedWindowHandleLocked(int displayId) const REQUIRES(mLock);
- bool hasResponsiveConnectionLocked(InputWindowHandle& windowHandle) const REQUIRES(mLock);
+ sp<android::gui::WindowInfoHandle> getFocusedWindowHandleLocked(int displayId) const
+ REQUIRES(mLock);
+ bool hasResponsiveConnectionLocked(android::gui::WindowInfoHandle& windowHandle) const
+ REQUIRES(mLock);
/*
* Validate and update InputWindowHandles for a given display.
*/
void updateWindowHandlesForDisplayLocked(
- const std::vector<sp<InputWindowHandle>>& inputWindowHandles, int32_t displayId)
- REQUIRES(mLock);
+ const std::vector<sp<android::gui::WindowInfoHandle>>& inputWindowHandles,
+ int32_t displayId) REQUIRES(mLock);
std::unordered_map<int32_t, TouchState> mTouchStatesByDisplay GUARDED_BY(mLock);
std::unique_ptr<DragState> mDragState GUARDED_BY(mLock);
@@ -471,7 +476,7 @@
AnrTracker mAnrTracker GUARDED_BY(mLock);
// Contains the last window which received a hover event.
- sp<InputWindowHandle> mLastHoverWindowHandle GUARDED_BY(mLock);
+ sp<android::gui::WindowInfoHandle> mLastHoverWindowHandle GUARDED_BY(mLock);
void cancelEventsForAnrLocked(const sp<Connection>& connection) REQUIRES(mLock);
nsecs_t getTimeSpentWaitingForApplicationLocked(nsecs_t currentTime) REQUIRES(mLock);
@@ -490,20 +495,21 @@
nsecs_t currentTime, const MotionEntry& entry, std::vector<InputTarget>& inputTargets,
nsecs_t* nextWakeupTime, bool* outConflictingPointerActions) REQUIRES(mLock);
std::vector<TouchedMonitor> findTouchedGestureMonitorsLocked(
- int32_t displayId, const std::vector<sp<InputWindowHandle>>& portalWindows) const
+ int32_t displayId,
+ const std::vector<sp<android::gui::WindowInfoHandle>>& portalWindows) const
REQUIRES(mLock);
std::vector<TouchedMonitor> selectResponsiveMonitorsLocked(
const std::vector<TouchedMonitor>& gestureMonitors) const REQUIRES(mLock);
- void addWindowTargetLocked(const sp<InputWindowHandle>& windowHandle, int32_t targetFlags,
- BitSet32 pointerIds, std::vector<InputTarget>& inputTargets)
- REQUIRES(mLock);
+ void addWindowTargetLocked(const sp<android::gui::WindowInfoHandle>& windowHandle,
+ int32_t targetFlags, BitSet32 pointerIds,
+ std::vector<InputTarget>& inputTargets) REQUIRES(mLock);
void addMonitoringTargetLocked(const Monitor& monitor, float xOffset, float yOffset,
std::vector<InputTarget>& inputTargets) REQUIRES(mLock);
void addGlobalMonitoringTargetsLocked(std::vector<InputTarget>& inputTargets, int32_t displayId,
float xOffset = 0, float yOffset = 0) REQUIRES(mLock);
void pokeUserActivityLocked(const EventEntry& eventEntry) REQUIRES(mLock);
- bool checkInjectionPermission(const sp<InputWindowHandle>& windowHandle,
+ bool checkInjectionPermission(const sp<android::gui::WindowInfoHandle>& windowHandle,
const InjectionState* injectionState);
// Enqueue a drag event if needed, and update the touch state.
// Uses findTouchedWindowTargetsLocked to make the decision
@@ -518,15 +524,18 @@
std::vector<std::string> debugInfo;
};
- TouchOcclusionInfo computeTouchOcclusionInfoLocked(const sp<InputWindowHandle>& windowHandle,
- int32_t x, int32_t y) const REQUIRES(mLock);
+ TouchOcclusionInfo computeTouchOcclusionInfoLocked(
+ const sp<android::gui::WindowInfoHandle>& windowHandle, int32_t x, int32_t y) const
+ REQUIRES(mLock);
bool isTouchTrustedLocked(const TouchOcclusionInfo& occlusionInfo) const REQUIRES(mLock);
- bool isWindowObscuredAtPointLocked(const sp<InputWindowHandle>& windowHandle, int32_t x,
- int32_t y) const REQUIRES(mLock);
- bool isWindowObscuredLocked(const sp<InputWindowHandle>& windowHandle) const REQUIRES(mLock);
- std::string dumpWindowForTouchOcclusion(const InputWindowInfo* info, bool isTouchWindow) const;
+ bool isWindowObscuredAtPointLocked(const sp<android::gui::WindowInfoHandle>& windowHandle,
+ int32_t x, int32_t y) const REQUIRES(mLock);
+ bool isWindowObscuredLocked(const sp<android::gui::WindowInfoHandle>& windowHandle) const
+ REQUIRES(mLock);
+ std::string dumpWindowForTouchOcclusion(const android::gui::WindowInfo* info,
+ bool isTouchWindow) const;
std::string getApplicationWindowLabel(const InputApplicationHandle* applicationHandle,
- const sp<InputWindowHandle>& windowHandle);
+ const sp<android::gui::WindowInfoHandle>& windowHandle);
// Manage the dispatch cycle for a single connection.
// These methods are deliberately not Interruptible because doing all of the work
@@ -605,8 +614,8 @@
void onAnrLocked(const sp<Connection>& connection) REQUIRES(mLock);
void onAnrLocked(std::shared_ptr<InputApplicationHandle> application) REQUIRES(mLock);
void onUntrustedTouchLocked(const std::string& obscuringPackage) REQUIRES(mLock);
- void updateLastAnrStateLocked(const sp<InputWindowHandle>& window, const std::string& reason)
- REQUIRES(mLock);
+ void updateLastAnrStateLocked(const sp<android::gui::WindowInfoHandle>& window,
+ const std::string& reason) REQUIRES(mLock);
void updateLastAnrStateLocked(const InputApplicationHandle& application,
const std::string& reason) REQUIRES(mLock);
void updateLastAnrStateLocked(const std::string& windowLabel, const std::string& reason)
diff --git a/services/inputflinger/dispatcher/InputTarget.h b/services/inputflinger/dispatcher/InputTarget.h
index 1c4980b..9c62b7e 100644
--- a/services/inputflinger/dispatcher/InputTarget.h
+++ b/services/inputflinger/dispatcher/InputTarget.h
@@ -17,6 +17,7 @@
#ifndef _UI_INPUT_INPUTDISPATCHER_INPUTTARGET_H
#define _UI_INPUT_INPUTDISPATCHER_INPUTTARGET_H
+#include <gui/constants.h>
#include <input/InputTransport.h>
#include <ui/Transform.h>
#include <utils/BitSet.h>
@@ -101,7 +102,7 @@
float globalScaleFactor = 1.0f;
// Display-size in its natural rotation. Used for compatibility transform of raw coordinates.
- int2 displaySize = {AMOTION_EVENT_INVALID_DISPLAY_SIZE, AMOTION_EVENT_INVALID_DISPLAY_SIZE};
+ int2 displaySize = {INVALID_DISPLAY_SIZE, INVALID_DISPLAY_SIZE};
// The subset of pointer ids to include in motion events dispatched to this input target
// if FLAG_SPLIT is set.
diff --git a/services/inputflinger/dispatcher/TouchState.cpp b/services/inputflinger/dispatcher/TouchState.cpp
index 81b3cf0..20b6ead 100644
--- a/services/inputflinger/dispatcher/TouchState.cpp
+++ b/services/inputflinger/dispatcher/TouchState.cpp
@@ -14,13 +14,14 @@
* limitations under the License.
*/
-#include <input/InputWindow.h>
+#include <gui/WindowInfo.h>
#include "InputTarget.h"
#include "TouchState.h"
-using android::InputWindowHandle;
+using android::gui::WindowInfo;
+using android::gui::WindowInfoHandle;
namespace android::inputdispatcher {
@@ -51,7 +52,7 @@
gestureMonitors = other.gestureMonitors;
}
-void TouchState::addOrUpdateWindow(const sp<InputWindowHandle>& windowHandle, int32_t targetFlags,
+void TouchState::addOrUpdateWindow(const sp<WindowInfoHandle>& windowHandle, int32_t targetFlags,
BitSet32 pointerIds) {
if (targetFlags & InputTarget::FLAG_SPLIT) {
split = true;
@@ -76,7 +77,7 @@
windows.push_back(touchedWindow);
}
-void TouchState::addPortalWindow(const sp<InputWindowHandle>& windowHandle) {
+void TouchState::addPortalWindow(const sp<android::gui::WindowInfoHandle>& windowHandle) {
size_t numWindows = portalWindows.size();
for (size_t i = 0; i < numWindows; i++) {
if (portalWindows[i] == windowHandle) {
@@ -121,7 +122,7 @@
portalWindows.clear();
}
-sp<InputWindowHandle> TouchState::getFirstForegroundWindowHandle() const {
+sp<WindowInfoHandle> TouchState::getFirstForegroundWindowHandle() const {
for (size_t i = 0; i < windows.size(); i++) {
const TouchedWindow& window = windows[i];
if (window.targetFlags & InputTarget::FLAG_FOREGROUND) {
@@ -137,7 +138,7 @@
for (const TouchedWindow& window : windows) {
if (window.targetFlags & InputTarget::FLAG_FOREGROUND) {
if (haveSlipperyForegroundWindow ||
- !window.windowHandle->getInfo()->flags.test(InputWindowInfo::Flag::SLIPPERY)) {
+ !window.windowHandle->getInfo()->flags.test(WindowInfo::Flag::SLIPPERY)) {
return false;
}
haveSlipperyForegroundWindow = true;
diff --git a/services/inputflinger/dispatcher/TouchState.h b/services/inputflinger/dispatcher/TouchState.h
index 623c6a8..a4e52b0 100644
--- a/services/inputflinger/dispatcher/TouchState.h
+++ b/services/inputflinger/dispatcher/TouchState.h
@@ -22,7 +22,9 @@
namespace android {
-class InputWindowHandle;
+namespace gui {
+class WindowInfoHandle;
+}
namespace inputdispatcher {
@@ -37,7 +39,7 @@
// This collects the portal windows that the touch has gone through. Each portal window
// targets a display (embedded display for most cases). With this info, we can add the
// monitoring channels of the displays touched.
- std::vector<sp<android::InputWindowHandle>> portalWindows;
+ std::vector<sp<android::gui::WindowInfoHandle>> portalWindows;
std::vector<TouchedMonitor> gestureMonitors;
@@ -45,14 +47,14 @@
~TouchState();
void reset();
void copyFrom(const TouchState& other);
- void addOrUpdateWindow(const sp<android::InputWindowHandle>& windowHandle, int32_t targetFlags,
- BitSet32 pointerIds);
- void addPortalWindow(const sp<android::InputWindowHandle>& windowHandle);
+ void addOrUpdateWindow(const sp<android::gui::WindowInfoHandle>& windowHandle,
+ int32_t targetFlags, BitSet32 pointerIds);
+ void addPortalWindow(const sp<android::gui::WindowInfoHandle>& windowHandle);
void addGestureMonitors(const std::vector<TouchedMonitor>& monitors);
void removeWindowByToken(const sp<IBinder>& token);
void filterNonAsIsTouchWindows();
void filterNonMonitors();
- sp<InputWindowHandle> getFirstForegroundWindowHandle() const;
+ sp<android::gui::WindowInfoHandle> getFirstForegroundWindowHandle() const;
bool isSlippery() const;
};
diff --git a/services/inputflinger/dispatcher/TouchedWindow.h b/services/inputflinger/dispatcher/TouchedWindow.h
index 8713aa3..4c31ec3 100644
--- a/services/inputflinger/dispatcher/TouchedWindow.h
+++ b/services/inputflinger/dispatcher/TouchedWindow.h
@@ -19,13 +19,15 @@
namespace android {
-class InputWindowHandle;
+namespace gui {
+class WindowInfoHandle;
+}
namespace inputdispatcher {
// Focus tracking for touch.
struct TouchedWindow {
- sp<android::InputWindowHandle> windowHandle;
+ sp<gui::WindowInfoHandle> windowHandle;
int32_t targetFlags;
BitSet32 pointerIds; // zero unless target flag FLAG_SPLIT is set
};
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
index 43428a0..80db035 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherInterface.h
@@ -19,18 +19,17 @@
#include <InputListener.h>
#include <android-base/result.h>
-#include <android/FocusRequest.h>
+#include <android/gui/FocusRequest.h>
#include <android/os/BlockUntrustedTouchesMode.h>
#include <android/os/ISetInputWindowsListener.h>
#include <android/os/InputEventInjectionResult.h>
#include <android/os/InputEventInjectionSync.h>
-#include <input/InputApplication.h>
+#include <gui/InputApplication.h>
+#include <gui/WindowInfo.h>
#include <input/InputDevice.h>
#include <input/InputTransport.h>
-#include <input/InputWindow.h>
#include <unordered_map>
-
namespace android {
/* Notifies the system about input events generated by the input reader.
@@ -91,7 +90,7 @@
* This method may be called on any thread (usually by the input manager).
*/
virtual void setInputWindows(
- const std::unordered_map<int32_t, std::vector<sp<InputWindowHandle>>>&
+ const std::unordered_map<int32_t, std::vector<sp<gui::WindowInfoHandle>>>&
handlesPerDisplay) = 0;
/* Sets the focused application on the given display.
@@ -162,7 +161,7 @@
/**
* Sets focus on the specified window.
*/
- virtual void setFocusedWindow(const FocusRequest&) = 0;
+ virtual void setFocusedWindow(const gui::FocusRequest&) = 0;
/**
* Creates an input channel that may be used as targets for input events.
diff --git a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
index 219f45a..ebfcbe1 100644
--- a/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
+++ b/services/inputflinger/dispatcher/include/InputDispatcherPolicyInterface.h
@@ -20,8 +20,8 @@
#include "InputDispatcherConfiguration.h"
#include <binder/IBinder.h>
+#include <gui/InputApplication.h>
#include <input/Input.h>
-#include <input/InputApplication.h>
#include <utils/RefBase.h>
namespace android {