Address Pointer Capture crash during rapid toggles
If an app has pointer capture enabled, and it rapidly toggles capture
off and on, there is a high likelihood for a system crash. We can
deterministically reproduce this case in the tests, so we address that
use case here.
Bug: 230850070
Test: atest inputflinger_tests
Change-Id: I1ecacf468d48b3def30fd5844d2e25128569e289
diff --git a/services/inputflinger/dispatcher/InputDispatcher.cpp b/services/inputflinger/dispatcher/InputDispatcher.cpp
index 1cc4589..5d8df5f 100644
--- a/services/inputflinger/dispatcher/InputDispatcher.cpp
+++ b/services/inputflinger/dispatcher/InputDispatcher.cpp
@@ -1421,8 +1421,10 @@
// Enable Pointer Capture.
if (haveWindowWithPointerCapture &&
(entry->pointerCaptureRequest == mCurrentPointerCaptureRequest)) {
- LOG_ALWAYS_FATAL("This request to enable Pointer Capture has already been dispatched "
- "to the window.");
+ // This can happen if pointer capture is disabled and re-enabled before we notify the
+ // app of the state change, so there is no need to notify the app.
+ ALOGI("Skipping dispatch of Pointer Capture being enabled: no state change.");
+ return;
}
if (!mCurrentPointerCaptureRequest.enable) {
// This can happen if a window requests capture and immediately releases capture.