InputDispatcher: Call setPointerCapture when resetting Pointer Capture

In InputDispatcher, mFocusedWindowRequestedPointerCapture must be in
sync with the Pointer Capture state in InputReaderConfiguration.
InputDispatcher is responsible for updating the latter by calling
InputDispatcherPolicyInterface::setPointerCapture().

Before, if InputDispatcher received a pointerCaptureChanged notification
unexpectedly from Reader, Pointer Capture would be "reset" to the
disabled state without notifying the policy. In such a case, the Pointer
Capture state in the policy could be out of sync with that in
InputDispatcher. While Reader should never send such an unexpected
notification in Android, the policy should nevertheless be updated for
sake of correctness.

Bug: 141749603
Test: atest inputflinger_tests

Change-Id: Ida53ad980607bcc7b371b614bd89328842196862
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 5832109..284d0f1 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -1247,14 +1247,20 @@
         // Disable Pointer Capture
         token = mWindowTokenWithPointerCapture;
         mWindowTokenWithPointerCapture = nullptr;
-        mFocusedWindowRequestedPointerCapture = false;
+        if (mFocusedWindowRequestedPointerCapture) {
+            mFocusedWindowRequestedPointerCapture = false;
+            setPointerCaptureLocked(false);
+        }
     }
 
     auto channel = getInputChannelLocked(token);
     if (channel == nullptr) {
         // Window has gone away, clean up Pointer Capture state.
         mWindowTokenWithPointerCapture = nullptr;
-        mFocusedWindowRequestedPointerCapture = false;
+        if (mFocusedWindowRequestedPointerCapture) {
+            mFocusedWindowRequestedPointerCapture = false;
+            setPointerCaptureLocked(false);
+        }
         return;
     }
     InputTarget target;