Skip to content

Commit 94bfc4b

Browse files
author
Arpit Singh
committed
[1/n InputDispatcher refactor] Rename getWindowHandleLocked
There are two overloded methods with name getWindowHandleLocked one of which is actually used to get the updated value of the same WindowHandle if exists. This CL renames the method to avoid confusion: From: sp<WindowInfoHandle> getWindowHandle( const sp<WindowInfoHandle>&handle); To: sp<android::gui::WindowInfoHandle> getUpdatedWindowHandle( const sp<android::gui::WindowInfoHandle>& handle); Bug: 367661487 Bug: 245989146 Test: atest inputflinger_tests Flag: EXEMPT refactor Change-Id: Id038603636ea3643b5301d187fe07ed02fcea839
1 parent def8ff1 commit 94bfc4b

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5218,8 +5218,7 @@ sp<WindowInfoHandle> InputDispatcher::getWindowHandleLocked(
52185218
return nullptr;
52195219
}
52205220

5221-
sp<WindowInfoHandle> InputDispatcher::getWindowHandleLocked(
5222-
const sp<WindowInfoHandle>& windowHandle) const {
5221+
bool InputDispatcher::isWindowPresentLocked(const sp<WindowInfoHandle>& windowHandle) const {
52235222
for (const auto& [displayId, windowHandles] : mWindowHandlesByDisplay) {
52245223
for (const sp<WindowInfoHandle>& handle : windowHandles) {
52255224
if (handle->getId() == windowHandle->getId() &&
@@ -5230,11 +5229,11 @@ sp<WindowInfoHandle> InputDispatcher::getWindowHandleLocked(
52305229
windowHandle->getName().c_str(), displayId.toString().c_str(),
52315230
windowHandle->getInfo()->displayId.toString().c_str());
52325231
}
5233-
return handle;
5232+
return true;
52345233
}
52355234
}
52365235
}
5237-
return nullptr;
5236+
return false;
52385237
}
52395238

52405239
sp<WindowInfoHandle> InputDispatcher::getFocusedWindowHandleLocked(
@@ -5429,7 +5428,7 @@ void InputDispatcher::setInputWindowsLocked(
54295428
TouchState& state = it->second;
54305429
for (size_t i = 0; i < state.windows.size();) {
54315430
TouchedWindow& touchedWindow = state.windows[i];
5432-
if (getWindowHandleLocked(touchedWindow.windowHandle) != nullptr) {
5431+
if (isWindowPresentLocked(touchedWindow.windowHandle)) {
54335432
i++;
54345433
continue;
54355434
}
@@ -5495,7 +5494,7 @@ void InputDispatcher::setInputWindowsLocked(
54955494
// Otherwise, they might stick around until the window handle is destroyed
54965495
// which might not happen until the next GC.
54975496
for (const sp<WindowInfoHandle>& oldWindowHandle : oldWindowHandles) {
5498-
if (getWindowHandleLocked(oldWindowHandle) == nullptr) {
5497+
if (!isWindowPresentLocked(oldWindowHandle)) {
54995498
if (DEBUG_FOCUS) {
55005499
ALOGD("Window went away: %s", oldWindowHandle->getName().c_str());
55015500
}

services/inputflinger/dispatcher/InputDispatcher.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ class InputDispatcher : public android::InputDispatcherInterface {
384384
sp<android::gui::WindowInfoHandle> getWindowHandleLocked(
385385
const sp<IBinder>& windowHandleToken,
386386
std::optional<ui::LogicalDisplayId> displayId = {}) const REQUIRES(mLock);
387-
sp<android::gui::WindowInfoHandle> getWindowHandleLocked(
388-
const sp<android::gui::WindowInfoHandle>& windowHandle) const REQUIRES(mLock);
387+
bool isWindowPresentLocked(const sp<android::gui::WindowInfoHandle>& windowHandle) const
388+
REQUIRES(mLock);
389389
sp<android::gui::WindowInfoHandle> getFocusedWindowHandleLocked(
390390
ui::LogicalDisplayId displayId) const REQUIRES(mLock);
391391
bool canWindowReceiveMotionLocked(const sp<android::gui::WindowInfoHandle>& window,

0 commit comments

Comments
 (0)