Add hmac to InputEvent and scale to MotionEvent
We need to pass some additional data to the app to be able to construct
the MotionEvent.
For proper support of getRawX/getRawY, add the xScale and yScale to
MotionEvent.
For the verification of input events, add hmac to InputEvent.
Bug: 134977432
Bug: 140786233
Test: atest libinput_tests inputflinger_tests
Change-Id: Ia3400ebbd9698549aad4d97a3b789ab7e10f6b65
diff --git a/include/input/InputTransport.h b/include/input/InputTransport.h
index ae47438..06fd3bb 100644
--- a/include/input/InputTransport.h
+++ b/include/input/InputTransport.h
@@ -76,6 +76,9 @@
} header;
// Body *must* be 8 byte aligned.
+ // For keys and motions, rely on the fact that std::array takes up exactly as much space
+ // as the underlying data. This is not guaranteed by C++, but it simplifies the conversions.
+ static_assert(sizeof(std::array<uint8_t, 32>) == 32);
union Body {
struct Key {
uint32_t seq;
@@ -84,6 +87,7 @@
int32_t deviceId;
int32_t source;
int32_t displayId;
+ std::array<uint8_t, 32> hmac;
int32_t action;
int32_t flags;
int32_t keyCode;
@@ -103,6 +107,7 @@
int32_t deviceId;
int32_t source;
int32_t displayId;
+ std::array<uint8_t, 32> hmac;
int32_t action;
int32_t actionButton;
int32_t flags;
@@ -112,6 +117,8 @@
uint8_t empty2[3]; // 3 bytes to fill gap created by classification
int32_t edgeFlags;
nsecs_t downTime __attribute__((aligned(8)));
+ float xScale;
+ float yScale;
float xOffset;
float yOffset;
float xPrecision;
@@ -269,19 +276,10 @@
* Returns BAD_VALUE if seq is 0.
* Other errors probably indicate that the channel is broken.
*/
- status_t publishKeyEvent(
- uint32_t seq,
- int32_t deviceId,
- int32_t source,
- int32_t displayId,
- int32_t action,
- int32_t flags,
- int32_t keyCode,
- int32_t scanCode,
- int32_t metaState,
- int32_t repeatCount,
- nsecs_t downTime,
- nsecs_t eventTime);
+ status_t publishKeyEvent(uint32_t seq, int32_t deviceId, int32_t source, int32_t displayId,
+ std::array<uint8_t, 32> hmac, int32_t action, int32_t flags,
+ int32_t keyCode, int32_t scanCode, int32_t metaState,
+ int32_t repeatCount, nsecs_t downTime, nsecs_t eventTime);
/* Publishes a motion event to the input channel.
*
@@ -292,9 +290,10 @@
* Other errors probably indicate that the channel is broken.
*/
status_t publishMotionEvent(uint32_t seq, int32_t deviceId, int32_t source, int32_t displayId,
- int32_t action, int32_t actionButton, int32_t flags,
- int32_t edgeFlags, int32_t metaState, int32_t buttonState,
- MotionClassification classification, float xOffset, float yOffset,
+ std::array<uint8_t, 32> hmac, int32_t action, int32_t actionButton,
+ int32_t flags, int32_t edgeFlags, int32_t metaState,
+ int32_t buttonState, MotionClassification classification,
+ float xScale, float yScale, float xOffset, float yOffset,
float xPrecision, float yPrecision, float xCursorPosition,
float yCursorPosition, nsecs_t downTime, nsecs_t eventTime,
uint32_t pointerCount, const PointerProperties* pointerProperties,