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/DisplayViewport.h b/include/input/DisplayViewport.h
index b0eceef..97c2ab8 100644
--- a/include/input/DisplayViewport.h
+++ b/include/input/DisplayViewport.h
@@ -19,7 +19,6 @@
 #include <android-base/stringprintf.h>
 #include <ftl/enum.h>
 #include <ftl/string.h>
-#include <gui/constants.h>
 #include <input/Input.h>
 #include <ui/Rotation.h>
 
@@ -47,7 +46,7 @@
  * See com.android.server.display.DisplayViewport.
  */
 struct DisplayViewport {
-    int32_t displayId; // -1 if invalid
+    ui::LogicalDisplayId displayId; // ADISPLAY_ID_NONE if invalid
     ui::Rotation orientation;
     int32_t logicalLeft;
     int32_t logicalTop;
@@ -67,7 +66,7 @@
     ViewportType type;
 
     DisplayViewport()
-          : displayId(ADISPLAY_ID_NONE),
+          : displayId(ui::ADISPLAY_ID_NONE),
             orientation(ui::ROTATION_0),
             logicalLeft(0),
             logicalTop(0),
@@ -99,12 +98,10 @@
         return !(*this == other);
     }
 
-    inline bool isValid() const {
-        return displayId >= 0;
-    }
+    inline bool isValid() const { return displayId.isValid(); }
 
     void setNonDisplayViewport(int32_t width, int32_t height) {
-        displayId = ADISPLAY_ID_NONE;
+        displayId = ui::ADISPLAY_ID_NONE;
         orientation = ui::ROTATION_0;
         logicalLeft = 0;
         logicalTop = 0;
@@ -123,12 +120,13 @@
     }
 
     std::string toString() const {
-        return StringPrintf("Viewport %s: displayId=%d, uniqueId=%s, port=%s, orientation=%d, "
+        return StringPrintf("Viewport %s: displayId=%s, uniqueId=%s, port=%s, orientation=%d, "
                             "logicalFrame=[%d, %d, %d, %d], "
                             "physicalFrame=[%d, %d, %d, %d], "
                             "deviceSize=[%d, %d], "
                             "isActive=[%d]",
-                            ftl::enum_string(type).c_str(), displayId, uniqueId.c_str(),
+                            ftl::enum_string(type).c_str(), displayId.toString().c_str(),
+                            uniqueId.c_str(),
                             physicalPort ? ftl::to_string(*physicalPort).c_str() : "<none>",
                             static_cast<int>(orientation), logicalLeft, logicalTop, logicalRight,
                             logicalBottom, physicalLeft, physicalTop, physicalRight, physicalBottom,