Support "pointer" capture for touchpads

In N, pointer capture was added such that the input events from
devices such as mice could be captured directly without UI
interaction for applications such as games.

At present, pointer capture is only supported on cursor input
devices (mice, trackballs), but games and similar applications
could also easily want to use a touchpad in a similar fashion.

This patch adds support for "pointer" capture on touchpads.

Changes:

If pointer capture is enabled, disable pointer mode for pointer
devices, causing them to fall back on a raw, unscaled mode. Android
already reports events from such devices via onGenericMotionEvent().

Android assumes that all pointer devices have an associated display,
so a condition was added to viewport calculation to fall back on a
non display viewport (raw dimensions) if the device is operating in
unscaled mode.

Added pointer capture mode changes to reconfiguration condition
check.

Added InputReader test demonstrating the concept.

Test: Connect a touchpad.  Request pointer capture for a focused
      view in an app and the touchpad events should come out over
      onGenericMotionEvent(MotionEvent).

Test: atest inputflinger_tests:MultiTouchInputMapperTest#Process_TouchpadCapture
Test: atest inputflinger_tests:MultiTouchInputMapperTest#WhenCapturedAndNotCaptured_GetSources

Bug: 38511270
Change-Id: I387708aad2d8bbe1e921fcb177f687af948dd052
diff --git a/services/inputflinger/reader/mapper/TouchInputMapper.cpp b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
index 15d5288..51a1c39 100644
--- a/services/inputflinger/reader/mapper/TouchInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchInputMapper.cpp
@@ -379,6 +379,7 @@
     if (!changes ||
         (changes &
          (InputReaderConfiguration::CHANGE_DISPLAY_INFO |
+          InputReaderConfiguration::CHANGE_POINTER_CAPTURE |
           InputReaderConfiguration::CHANGE_POINTER_GESTURE_ENABLEMENT |
           InputReaderConfiguration::CHANGE_SHOW_TOUCHES |
           InputReaderConfiguration::CHANGE_EXTERNAL_STYLUS_PRESENCE))) {
@@ -562,7 +563,7 @@
  * 4. Otherwise, use a non-display viewport.
  */
 std::optional<DisplayViewport> TouchInputMapper::findViewport() {
-    if (mParameters.hasAssociatedDisplay) {
+    if (mParameters.hasAssociatedDisplay && mDeviceMode != DeviceMode::UNSCALED) {
         const std::optional<uint8_t> displayPort = getDeviceContext().getAssociatedDisplayPort();
         if (displayPort) {
             // Find the viewport that contains the same port
@@ -620,7 +621,7 @@
 
     // Determine device mode.
     if (mParameters.deviceType == Parameters::DeviceType::POINTER &&
-        mConfig.pointerGesturesEnabled) {
+        mConfig.pointerGesturesEnabled && !mConfig.pointerCapture) {
         mSource = AINPUT_SOURCE_MOUSE;
         mDeviceMode = DeviceMode::POINTER;
         if (hasStylus()) {