Skip to content

Commit 0a94f46

Browse files
author
Arpit Singh
committed
[4/n InputDispatcher refactor] Make findTouchedForegroundWindow static
Bug: 367661487 Bug: 245989146 Test: atest inputflinger_tests Flag: EXEMPT refactor Change-Id: I121cfa10077d158b79fc61d71ccb559e3ee537c5
1 parent a923bd4 commit 0a94f46

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5931,10 +5931,11 @@ bool InputDispatcher::transferTouchGesture(const sp<IBinder>& fromToken, const s
59315931
* Return null if there are no windows touched on that display, or if more than one foreground
59325932
* window is being touched.
59335933
*/
5934-
sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindowLocked(
5935-
ui::LogicalDisplayId displayId) const {
5936-
auto stateIt = mTouchStatesByDisplay.find(displayId);
5937-
if (stateIt == mTouchStatesByDisplay.end()) {
5934+
sp<WindowInfoHandle> InputDispatcher::findTouchedForegroundWindow(
5935+
const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay,
5936+
ui::LogicalDisplayId displayId) {
5937+
const auto stateIt = touchStatesByDisplay.find(displayId);
5938+
if (stateIt == touchStatesByDisplay.end()) {
59385939
ALOGI("No touch state on display %s", displayId.toString().c_str());
59395940
return nullptr;
59405941
}
@@ -5970,7 +5971,7 @@ bool InputDispatcher::transferTouchOnDisplay(const sp<IBinder>& destChannelToken
59705971
return false;
59715972
}
59725973

5973-
sp<WindowInfoHandle> from = findTouchedForegroundWindowLocked(displayId);
5974+
sp<WindowInfoHandle> from = findTouchedForegroundWindow(mTouchStatesByDisplay, displayId);
59745975
if (from == nullptr) {
59755976
ALOGE("Could not find a source window in %s for %p", __func__, destChannelToken.get());
59765977
return false;

services/inputflinger/dispatcher/InputDispatcher.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ class InputDispatcher : public android::InputDispatcherInterface {
260260
ui::LogicalDisplayId displayId, float x, float y, bool isStylus,
261261
DeviceId deviceId) const REQUIRES(mLock);
262262

263-
sp<android::gui::WindowInfoHandle> findTouchedForegroundWindowLocked(
264-
ui::LogicalDisplayId displayId) const REQUIRES(mLock);
263+
static sp<android::gui::WindowInfoHandle> findTouchedForegroundWindow(
264+
const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay,
265+
ui::LogicalDisplayId displayId);
265266

266267
std::shared_ptr<Connection> getConnectionLocked(const sp<IBinder>& inputConnectionToken) const
267268
REQUIRES(mLock);

0 commit comments

Comments
 (0)