Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d17cd41 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Automerger Merge Worker
Browse files

Merge "Address Pointer Capture crash during rapid toggles" into tm-dev am:...

Merge "Address Pointer Capture crash during rapid toggles" into tm-dev am: 0f24a7c3 am: 810b0028 am: 689e8ad6 am: 0c2c4977

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/18142163



Change-Id: If6a9c6d9e451a1c944096ece5a4856272eb63c79
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 175dff2d 0c2c4977
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -1420,8 +1420,10 @@ void InputDispatcher::dispatchPointerCaptureChangedLocked(
        // Enable Pointer Capture.
        // Enable Pointer Capture.
        if (haveWindowWithPointerCapture &&
        if (haveWindowWithPointerCapture &&
            (entry->pointerCaptureRequest == mCurrentPointerCaptureRequest)) {
            (entry->pointerCaptureRequest == mCurrentPointerCaptureRequest)) {
            LOG_ALWAYS_FATAL("This request to enable Pointer Capture has already been dispatched "
            // This can happen if pointer capture is disabled and re-enabled before we notify the
                             "to the window.");
            // 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) {
        if (!mCurrentPointerCaptureRequest.enable) {
            // This can happen if a window requests capture and immediately releases capture.
            // This can happen if a window requests capture and immediately releases capture.
+19 −0
Original line number Original line Diff line number Diff line
@@ -5670,6 +5670,25 @@ TEST_F(InputDispatcherPointerCaptureTests, EnableRequestFollowsSequenceNumbers)
    mWindow->consumeCaptureEvent(true);
    mWindow->consumeCaptureEvent(true);
}
}


TEST_F(InputDispatcherPointerCaptureTests, RapidToggleRequests) {
    requestAndVerifyPointerCapture(mWindow, true);

    // App toggles pointer capture off and on.
    mDispatcher->requestPointerCapture(mWindow->getToken(), false);
    mFakePolicy->assertSetPointerCaptureCalled(false);

    mDispatcher->requestPointerCapture(mWindow->getToken(), true);
    auto enableRequest = mFakePolicy->assertSetPointerCaptureCalled(true);

    // InputReader notifies that the latest "enable" request was processed, while skipping over the
    // preceding "disable" request.
    notifyPointerCaptureChanged(enableRequest);

    // Since pointer capture was never disabled during the rapid toggle, the window does not receive
    // any notifications.
    mWindow->assertNoEvents();
}

class InputDispatcherUntrustedTouchesTest : public InputDispatcherTest {
class InputDispatcherUntrustedTouchesTest : public InputDispatcherTest {
protected:
protected:
    constexpr static const float MAXIMUM_OBSCURING_OPACITY = 0.8;
    constexpr static const float MAXIMUM_OBSCURING_OPACITY = 0.8;