Use enum class for InputMessage type
Using enum class helps with type safety, and allows compile-time
detection of missing switch/case statements.
Bug: 70668286
Test: compile-time only
Change-Id: I5ae95cfbf2b38330fa34eca1c9f444a90190cd25
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index c056c97..1822e4a 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -60,14 +60,14 @@
* in StructLayout_test should be made.
*/
struct InputMessage {
- enum {
- TYPE_KEY = 1,
- TYPE_MOTION = 2,
- TYPE_FINISHED = 3,
+ enum class Type : uint32_t {
+ KEY,
+ MOTION,
+ FINISHED,
};
struct Header {
- uint32_t type;
+ Type type; // 4 bytes
// We don't need this field in order to align the body below but we
// leave it here because InputMessage::size() and other functions
// compute the size of this structure as sizeof(Header) + sizeof(Body).