Validate events before printing them

Before this patch, enabling the injection logs would cause a crash when
running inputflinger_tests. This happened because the events were
getting printed prior to getting checked for validity.

To fix this, move the check to the beginning of the function.

Test: m inputflinger_tests && $ANDROID_HOST_OUT/nativetest64/inputflinger_tests/inputflinger_tests
Bug: 274073185
Change-Id: I8c92e47133e0eea55186be049434bdfd5c0348ff
1 file changed