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

Commit 95ef3c43 authored by chaviw's avatar chaviw Committed by Chavi Weingarten
Browse files

Add synchronous transaction to wait for setInputWindow to complete (4/n)

Wait for callback from InputDispatcher before returning to client.

If the request to SF has the flag syncInputWindows, wait until the
callback setInputWindowsFinished has been called from InputDispatcher
before returning to the client.

Bug: 123041491
Test: Builds, runs
Change-Id: I9d3fb83442cf344c43449bb072a1c31b300b2879
parent 3209997d
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -2952,6 +2952,10 @@ void SurfaceFlinger::updateInputFlinger() {
    if (mVisibleRegionsDirty || mInputInfoChanged) {
        mInputInfoChanged = false;
        updateInputWindowInfo();
    } else if (mInputWindowCommands.syncInputWindows) {
        // If the caller requested to sync input windows, but there are no
        // changes to input windows, notify immediately.
        setInputWindowsFinished();
    }

    executeInputWindowCommands();
@@ -3681,13 +3685,16 @@ void SurfaceFlinger::applyTransactionState(const Vector<ComposerState>& states,
        if (flags & eAnimation) {
            mAnimTransactionPending = true;
        }
        while (mTransactionPending) {

        mPendingSyncInputWindows = mPendingInputWindowCommands.syncInputWindows;
        while (mTransactionPending || mPendingSyncInputWindows) {
            status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5));
            if (CC_UNLIKELY(err != NO_ERROR)) {
                // just in case something goes wrong in SF, return to the
                // called after a few seconds.
                ALOGW_IF(err == TIMED_OUT, "setTransactionState timed out!");
                mTransactionPending = false;
                mPendingSyncInputWindows = false;
                break;
            }
        }
@@ -5657,7 +5664,12 @@ status_t SurfaceFlinger::captureScreenImplLocked(const RenderArea& renderArea,
    return NO_ERROR;
}

void SurfaceFlinger::setInputWindowsFinished() {}
void SurfaceFlinger::setInputWindowsFinished() {
    Mutex::Autolock _l(mStateLock);

    mPendingSyncInputWindows = false;
    mTransactionCV.broadcast();
}

// ---------------------------------------------------------------------------

+1 −0
Original line number Diff line number Diff line
@@ -1125,6 +1125,7 @@ private:
    ui::DisplayPrimaries mInternalDisplayPrimaries;

    sp<SetInputWindowsListener> mSetInputWindowsListener;
    bool mPendingSyncInputWindows GUARDED_BY(mStateLock);
};
}; // namespace android