Add static_asserts for the size of InputMessage
Inside InputTransport.cpp, we are reading and writing InputMessages.
This is done in the following way:
read
::recv(getFd(), msg, sizeof(InputMessage), MSG_DONTWAIT);
write
::send(getFd(), &cleanMsg, msgLength, MSG_DONTWAIT | MSG_NOSIGNAL);
We are sending a variable-length message across the socket, and
receiving a maximum of sizeof(InputMessage) when reading it.
In this CL, we are adding asserts on the _maximum_ length of the message
that we would send across the socket. Since we typically only have a few
pointers at most, while MAX_POINTERS=16, in reality the communication
between system_server and app will use much less data.
However, it's still useful to add these asserts to understand the
worst-case scenario of message transfer.
Bug: 167946763
Test: m StructLayout_test
Change-Id: I281ecea62b392dea56936d031ab9c4ee18add93f
diff --git a/include/input/Input.h b/include/input/Input.h
index f4147a0..55ebb90 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -164,7 +164,7 @@
* (We want at least 10 but some touch controllers obstensibly configured for 10 pointers
* will occasionally emit 11. There is not much harm making this constant bigger.)
*/
-#define MAX_POINTERS 16
+static constexpr size_t MAX_POINTERS = 16;
/*
* Maximum number of samples supported per motion event.
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index edcb615..5f9a37d 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -500,24 +500,6 @@
status_t sendTimeline(int32_t inputEventId,
std::array<nsecs_t, GraphicsTimeline::SIZE> timeline);
- /* Returns true if there is a deferred event waiting.
- *
- * Should be called after calling consume() to determine whether the consumer
- * has a deferred event to be processed. Deferred events are somewhat special in
- * that they have already been removed from the input channel. If the input channel
- * becomes empty, the client may need to do extra work to ensure that it processes
- * the deferred event despite the fact that the input channel's file descriptor
- * is not readable.
- *
- * One option is simply to call consume() in a loop until it returns WOULD_BLOCK.
- * This guarantees that all deferred events will be processed.
- *
- * Alternately, the caller can call hasDeferredEvent() to determine whether there is
- * a deferred event waiting and then ensure that its event loop wakes up at least
- * one more time to consume the deferred event.
- */
- bool hasDeferredEvent() const;
-
/* Returns true if there is a pending batch.
*
* Should be called after calling consume() with consumeBatches == false to determine