summaryrefslogtreecommitdiff
path: root/libs/input/PointerControllerContext.cpp
diff options
context:
space:
mode:
author Linnan Li <lilinnan@xiaomi.corp-partner.google.com> 2024-05-05 19:17:05 +0800
committer Siarhei Vishniakou <svv@google.com> 2024-05-09 11:55:45 -0700
commit0defadf2c5504374d0e0377aa9accd33907d53cd (patch)
treeb09624bed4cc227a32ab61fe0e305fcc252c9555 /libs/input/PointerControllerContext.cpp
parent119272db6ddba3b4751aa77d81c90eae7c99d5f9 (diff)
Use a strongly typed LogicalDisplayId for displayId(1/n)
Currently, we use int32_t for displayId, which is not a safe type, and it may also lead to misdefinition of types. Here, we introduce LogicalDisplayId as a strong type for displayId and move all contents of constants.h into LogicalDisplayId.h. Bug: 339106983 Test: atest inputflinger_tests Test: atest InputTests Test: presubmit Change-Id: I1c348d7f08524471391b21eaba938501506a7772 Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
Diffstat (limited to 'libs/input/PointerControllerContext.cpp')
-rw-r--r--libs/input/PointerControllerContext.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libs/input/PointerControllerContext.cpp b/libs/input/PointerControllerContext.cpp
index 15c35176afce..747eb8e5ad1b 100644
--- a/libs/input/PointerControllerContext.cpp
+++ b/libs/input/PointerControllerContext.cpp
@@ -138,12 +138,12 @@ int PointerControllerContext::LooperCallback::handleEvent(int /* fd */, int even
return 1; // keep the callback
}
-void PointerControllerContext::addAnimationCallback(int32_t displayId,
+void PointerControllerContext::addAnimationCallback(ui::LogicalDisplayId displayId,
std::function<bool(nsecs_t)> callback) {
mAnimator.addCallback(displayId, callback);
}
-void PointerControllerContext::removeAnimationCallback(int32_t displayId) {
+void PointerControllerContext::removeAnimationCallback(ui::LogicalDisplayId displayId) {
mAnimator.removeCallback(displayId);
}
@@ -161,14 +161,14 @@ void PointerControllerContext::PointerAnimator::initializeDisplayEventReceiver()
}
}
-void PointerControllerContext::PointerAnimator::addCallback(int32_t displayId,
+void PointerControllerContext::PointerAnimator::addCallback(ui::LogicalDisplayId displayId,
std::function<bool(nsecs_t)> callback) {
std::scoped_lock lock(mLock);
mLocked.callbacks[displayId] = callback;
startAnimationLocked();
}
-void PointerControllerContext::PointerAnimator::removeCallback(int32_t displayId) {
+void PointerControllerContext::PointerAnimator::removeCallback(ui::LogicalDisplayId displayId) {
std::scoped_lock lock(mLock);
auto it = mLocked.callbacks.find(displayId);
if (it == mLocked.callbacks.end()) {