Support multiple internal and external viewports
The policy is still effectively the same by selecting the first display,
but this lets devices which are configured with a specific unique ID to
see the viewport that should be associated with it.
Bug: 116824030
Bug: 171549575
Test: atest InputReader_test
Change-Id: I3f78a122a3a8dce9c8dac3c88f3d51f29afa367c
diff --git a/include/input/DisplayViewport.h b/include/input/DisplayViewport.h
index 334fe34..b90d57e 100644
--- a/include/input/DisplayViewport.h
+++ b/include/input/DisplayViewport.h
@@ -19,6 +19,7 @@
#include <android-base/stringprintf.h>
#include <input/Input.h>
+#include <input/NamedEnum.h>
#include <cinttypes>
#include <optional>
@@ -44,18 +45,6 @@
VIRTUAL = 3,
};
-static const char* viewportTypeToString(ViewportType type) {
- switch (type) {
- case ViewportType::INTERNAL:
- return "INTERNAL";
- case ViewportType::EXTERNAL:
- return "EXTERNAL";
- case ViewportType::VIRTUAL:
- return "VIRTUAL";
- }
- return "UNKNOWN";
-}
-
/*
* Describes how coordinates are mapped on a physical display.
* See com.android.server.display.DisplayViewport.
@@ -142,7 +131,7 @@
"physicalFrame=[%d, %d, %d, %d], "
"deviceSize=[%d, %d], "
"isActive=[%d]",
- viewportTypeToString(type), displayId, uniqueId.c_str(),
+ NamedEnum::string(type).c_str(), displayId, uniqueId.c_str(),
physicalPort ? StringPrintf("%" PRIu8, *physicalPort).c_str()
: "<none>",
orientation, logicalLeft, logicalTop, logicalRight, logicalBottom,