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
Loading
Please register or sign in to comment