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

Skip to content
Commit 1aa18e2f authored by Felipe Leme's avatar Felipe Leme
Browse files

Refactor KeyEvent constructors.

KeyEvent has about 10 fields and 10 constructors, and not all
constructors set all thse fields, which can cause issues (for
example, some constructors were setting the display id to
INVALID_DISPLAY, while others weren't - this was probably a mistake
introduced when the new constructors were added).

This CL defines 2 "canonical" constructors (one that only takes
individual parameters, another one that takes a KeyEvent) and
refactor the others to call one of them, which would make them less
error prone.

Notice that there are still some inconsistency on how some fields
are initially set (for example, mDeviceId is set to VIRTUAL_KEYBOARD
and source is set to SOURCE_KEYBOARD by some constructors but they're
left as 0 by others) - it's not the purpose of this CL to fix these
cases, but the new constructors (and unit tests) would make it easier
to do so in the future.

Test: atest android.view.KeyEventTest
Bug: 268103680

Change-Id: Ic5867212c827065fb14af164b5b90f767d05b10a
parent 921ecfe4
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