Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit ec60764d authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Store time in nanoseconds in KeyEvent

KeyEvent today stores time in milliseconds. That means that data is lost
when it gets sent from native to Java layers. The subsequent return
route, going from Java to native, cannot recover this data.

This causes the KeyEvents to have truncated event times when they are
inspected by InputDispatcher (for example, for injectInputEvent and
verifyInputEvent apis).

In the injectInputEvent, this is fine, because the public api to create
a KeyEvent does not allow the caller to provide nanoseconds.

For the verifyInputEvent, however, this is a problem. When the HMAC of
the provided KeyEvent is computed, it no longer matches the HMAC of the
original KeyEvent. That means that verification for KeyEvents is broken.

To fix this, we pass nanosecond values to Java layer. The fields are
already stored as 'long', so there's enough room for that. To maintain
the existing api behaviour, though, we need to convert to/from
milliseconds at the public api bondary. This specifically applies to
KeyEvent constructors, some of the 'obtain' apis, and
'getDownTime'/'getEventTime' apis.

Test: atest VerifyHardwareKeyEventTest
Bug: 194264616
Change-Id: I0c82a2f065bc947a0e48a26ae3ea5f4ef77f464f
parent 9967c7a2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment