Expanded testing for joystick actions.

Currently, only a single button on one joystick model
is tested in CTS. Here we expand the testing to include
additional KeyEvents and MotionEvents for Asus Gamepad
as well as the Sony DualShock 4. The eventual goal
is to add testing for all buttons and sticks for all
joysticks for which we have key layouts, thus allowing
us to ensure that a certain joystick model is supported
by all Android devices.

Rename the resource and the test files to follow a "company_model"
convention, so that multiple joystick models by the same company will
be shown next to each other (in alphabetic order).

Also, add an input library for cts tests. It will contain useful code
that may be utilized by different CTS test modules. Currently, it only
contains HidDevice for a simpler interface to use /dev/uhid.
It could also be used for testing shortcuts, for example (if it emulates
a keyboard instead of a joystick).

Since the "KEYCODE_" prefix being optional in ag/4031155 is not in aosp
yet, add another temporary workaround here.

Add another temporary workaround SystemClock.sleep(500). Without this,
the test is currently flaking. Even though we are sure to only write the
events after UHID_OPEN has been received (and after device added
callback from input manager has been received), monitoring "getevent
-lt" during the test execution reveals that no events are actually
emitted from the virtual device in the case where the test fails. This
suggests that UHID_OPEN callback is not sufficient to ensure that
writing reports to /dev/uhid is safe.

Note: this is a cherry-pick of ag/2983529 with an additional
cherry-pick of ag/3800049

Test: atest AsusGamepadTestCase SonyDualshock4TestCase
Bug: 36069459
Bug: 111431828
Bug: 110270125
Change-Id: If0606b61feea9d4c293874d4c851b7611fbe2a9e
Merged-In: If0606b61feea9d4c293874d4c851b7611fbe2a9e
21 files changed