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

Commit edd1360a authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceFlinger: Send all BufferedLayers to InputFlinger

Currently if an InputWindow is obscured by a window with
FLAG_NO_INPUT_CHANNEL or a Surface with no window (and input) at all
then InputDispatcher will not be aware of the window and it will
fail to generate FLAG_(PARTIALLY)_OCLUDED for windows underneath. To fix
this we make sure we generate an InputWindow for every buffered
element on the screen and make them all known to InputDispatcher.

Bug: 152064592
Test: ObscuredInputTests
Change-Id: I90a813be9b650dceb0a20ffbf33aa27f95d38771
parent 9adccca5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3653,7 +3653,8 @@ void InputDispatcher::updateWindowHandlesForDisplayLocked(
            continue;
        }

        if (oldHandlesById.find(handle->getId()) != oldHandlesById.end()) {
        if ((oldHandlesById.find(handle->getId()) != oldHandlesById.end()) &&
                (oldHandlesById.at(handle->getId())->getToken() == handle->getToken())) {
            const sp<InputWindowHandle>& oldHandle = oldHandlesById.at(handle->getId());
            oldHandle->updateFrom(handle);
            newHandles.push_back(oldHandle);
+5 −0
Original line number Diff line number Diff line
@@ -148,6 +148,11 @@ private:
    virtual status_t updateActiveBuffer() = 0;
    virtual status_t updateFrameNumber(nsecs_t latchTime) = 0;

    // We generate InputWindowHandles for all buffered layers regardless of whether they
    // have an InputChannel. This is to enable the InputDispatcher to do PID based occlusion
    // detection.
    bool needsInputInfo() const override { return true; }

protected:
    struct BufferInfo {
        nsecs_t mDesiredPresentTime;
+11 −1
Original line number Diff line number Diff line
@@ -2323,6 +2323,16 @@ bool Layer::isRemovedFromCurrentState() const {
}

InputWindowInfo Layer::fillInputInfo() {
    if (!hasInputInfo()) {
        mDrawingState.inputInfo.name = getName();
        mDrawingState.inputInfo.ownerUid = mCallingUid;
        mDrawingState.inputInfo.ownerPid = mCallingPid;
        mDrawingState.inputInfo.inputFeatures =
            InputWindowInfo::INPUT_FEATURE_NO_INPUT_CHANNEL;
        mDrawingState.inputInfo.layoutParamsFlags = InputWindowInfo::FLAG_NOT_TOUCH_MODAL;
        mDrawingState.inputInfo.displayId = getLayerStack();
    }

    InputWindowInfo info = mDrawingState.inputInfo;
    info.id = sequence;

@@ -2404,7 +2414,7 @@ sp<Layer> Layer::getClonedRoot() {
    return mDrawingParent.promote()->getClonedRoot();
}

bool Layer::hasInput() const {
bool Layer::hasInputInfo() const {
    return mDrawingState.inputInfo.token != nullptr;
}

+11 −1
Original line number Diff line number Diff line
@@ -947,7 +947,17 @@ public:
    void setInputInfo(const InputWindowInfo& info);

    InputWindowInfo fillInputInfo();
    bool hasInput() const;
    /**
     * Returns whether this layer has an explicitly set input-info.
     */
    bool hasInputInfo() const;
    /**
     * Return whether this layer needs an input info. For most layer types
     * this is only true if they explicitly set an input-info but BufferLayer
     * overrides this so we can generate input-info for Buffered layers that don't
     * have them (for input occlusion detection checks).
     */
    virtual bool needsInputInfo() const { return hasInputInfo(); }

protected:
    compositionengine::OutputLayer* findOutputLayerForDisplay(const DisplayDevice*) const;
+1 −1
Original line number Diff line number Diff line
@@ -2885,7 +2885,7 @@ void SurfaceFlinger::updateInputWindowInfo() {
    std::vector<InputWindowInfo> inputHandles;

    mDrawingState.traverseInReverseZOrder([&](Layer* layer) {
        if (layer->hasInput()) {
        if (layer->needsInputInfo()) {
            // When calculating the screen bounds we ignore the transparent region since it may
            // result in an unwanted offset.
            inputHandles.push_back(layer->fillInputInfo());