Use a strongly typed LogicalDisplayId for displayId(2/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: m checkinput
Test: m libsurfaceflinger_unittest
Test: presubmit
Change-Id: If44e56f69553d095af5adb59b595e4a852ab32ce
Signed-off-by: Linnan Li <lilinnan@xiaomi.corp-partner.google.com>
diff --git a/include/input/InputEventBuilders.h b/include/input/InputEventBuilders.h
index c0c5e24..837e70e 100644
--- a/include/input/InputEventBuilders.h
+++ b/include/input/InputEventBuilders.h
@@ -18,7 +18,6 @@
#include <android/input.h>
#include <attestation/HmacKeyManager.h>
-#include <gui/constants.h>
#include <input/Input.h>
#include <utils/Timers.h> // for nsecs_t, systemTime
@@ -83,7 +82,7 @@
return *this;
}
- MotionEventBuilder& displayId(int32_t displayId) {
+ MotionEventBuilder& displayId(ui::LogicalDisplayId displayId) {
mDisplayId = displayId;
return *this;
}
@@ -159,7 +158,7 @@
int32_t mSource;
nsecs_t mDownTime;
nsecs_t mEventTime;
- int32_t mDisplayId{ADISPLAY_ID_DEFAULT};
+ ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT};
int32_t mActionButton{0};
int32_t mButtonState{0};
int32_t mFlags{0};
@@ -209,7 +208,7 @@
return *this;
}
- KeyEventBuilder& displayId(int32_t displayId) {
+ KeyEventBuilder& displayId(ui::LogicalDisplayId displayId) {
mDisplayId = displayId;
return *this;
}
@@ -248,7 +247,7 @@
uint32_t mSource;
nsecs_t mDownTime;
nsecs_t mEventTime;
- int32_t mDisplayId{ADISPLAY_ID_DEFAULT};
+ ui::LogicalDisplayId mDisplayId{ui::ADISPLAY_ID_DEFAULT};
uint32_t mPolicyFlags = DEFAULT_POLICY_FLAGS;
int32_t mFlags{0};
int32_t mKeyCode{AKEYCODE_UNKNOWN};