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

Commit eeec678a authored by Arpit Singh's avatar Arpit Singh Committed by Android (Google) Code Review
Browse files

Revert "[11/n Dispatcher refactor] Move isTouchTrusted to WindowInfo"

Revert submission 31063667

Reason for revert: b/389024840

Reverted changes: /q/submissionid:31063667

Change-Id: I6e49f735d54317d86e309c31d1694c9ee75dc553
parent 60448cf0
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -954,6 +954,7 @@ InputDispatcher::InputDispatcher(InputDispatcherPolicyInterface& policy,
        mDispatchEnabled(false),
        mDispatchFrozen(false),
        mInputFilterEnabled(false),
        mMaximumObscuringOpacityForTouch(1.0f),
        mFocusedDisplayId(ui::LogicalDisplayId::DEFAULT),
        mWindowTokenWithPointerCapture(nullptr),
        mAwaitedApplicationDisplayId(ui::LogicalDisplayId::INVALID),
@@ -3163,8 +3164,8 @@ InputDispatcher::DispatcherWindowInfo::computeTouchOcclusionInfo(
    return info;
}

bool InputDispatcher::DispatcherWindowInfo::isTouchTrusted(
        const TouchOcclusionInfo& occlusionInfo) const {
bool InputDispatcher::isTouchTrustedLocked(
        const DispatcherWindowInfo::TouchOcclusionInfo& occlusionInfo) const {
    if (occlusionInfo.hasBlockingOcclusion) {
        ALOGW("Untrusted touch due to occlusion by %s/%s", occlusionInfo.obscuringPackage.c_str(),
              occlusionInfo.obscuringUid.toString().c_str());
@@ -5270,9 +5271,8 @@ std::string InputDispatcher::DispatcherWindowInfo::dumpDisplayAndWindowInfo() co
    return dump;
}

bool InputDispatcher::canWindowReceiveMotionLocked(
        const sp<android::gui::WindowInfoHandle>& window,
        const android::inputdispatcher::MotionEntry& motionEntry) const {
bool InputDispatcher::canWindowReceiveMotionLocked(const sp<WindowInfoHandle>& window,
                                                   const MotionEntry& motionEntry) const {
    const WindowInfo& info = *window->getInfo();

    // Skip spy window targets that are not valid for targeted injection.
@@ -5307,7 +5307,7 @@ bool InputDispatcher::canWindowReceiveMotionLocked(
    const auto [x, y] = resolveTouchedPosition(motionEntry);
    DispatcherWindowInfo::TouchOcclusionInfo occlusionInfo =
            mWindowInfos.computeTouchOcclusionInfo(window, x, y);
    if (!mWindowInfos.isTouchTrusted(occlusionInfo)) {
    if (!isTouchTrustedLocked(occlusionInfo)) {
        if (DEBUG_TOUCH_OCCLUSION) {
            ALOGD("Stack of obscuring windows during untrusted touch (%.1f, %.1f):", x, y);
            for (const auto& log : occlusionInfo.debugInfo) {
@@ -5751,8 +5751,13 @@ bool InputDispatcher::recentWindowsAreOwnedByLocked(gui::Pid pid, gui::Uid uid)
}

void InputDispatcher::setMaximumObscuringOpacityForTouch(float opacity) {
    if (opacity < 0 || opacity > 1) {
        LOG_ALWAYS_FATAL("Maximum obscuring opacity for touch should be >= 0 and <= 1");
        return;
    }

    std::scoped_lock lock(mLock);
    mWindowInfos.setMaximumObscuringOpacityForTouch(opacity);
    mMaximumObscuringOpacityForTouch = opacity;
}

std::tuple<const TouchState*, const TouchedWindow*, ui::LogicalDisplayId>
@@ -7357,11 +7362,4 @@ std::string InputDispatcher::ConnectionManager::dump(nsecs_t currentTime) const
    return dump;
}

void InputDispatcher::DispatcherWindowInfo::setMaximumObscuringOpacityForTouch(float opacity) {
    if (opacity < 0 || opacity > 1) {
        LOG_ALWAYS_FATAL("Maximum obscuring opacity for touch should be >= 0 and <= 1");
    }
    mMaximumObscuringOpacityForTouch = opacity;
}

} // namespace android::inputdispatcher
+3 −5
Original line number Diff line number Diff line
@@ -290,8 +290,6 @@ private:

        void removeDisplay(ui::LogicalDisplayId displayId);

        void setMaximumObscuringOpacityForTouch(float opacity);

        // Get a reference to window handles by display, return an empty vector if not found.
        const std::vector<sp<android::gui::WindowInfoHandle>>& getWindowHandlesForDisplay(
                ui::LogicalDisplayId displayId) const;
@@ -336,8 +334,6 @@ private:
        sp<android::gui::WindowInfoHandle> findWallpaperWindowBelow(
                const sp<android::gui::WindowInfoHandle>& windowHandle) const;

        bool isTouchTrusted(const TouchOcclusionInfo& occlusionInfo) const;

        std::string dumpDisplayAndWindowInfo() const;

    private:
@@ -346,7 +342,6 @@ private:
                mWindowHandlesByDisplay;
        std::unordered_map<ui::LogicalDisplayId /*displayId*/, android::gui::DisplayInfo>
                mDisplayInfos;
        float mMaximumObscuringOpacityForTouch{1.0f};
    };

    DispatcherWindowInfo mWindowInfos GUARDED_BY(mLock);
@@ -448,6 +443,7 @@ private:
    bool mDispatchEnabled GUARDED_BY(mLock);
    bool mDispatchFrozen GUARDED_BY(mLock);
    bool mInputFilterEnabled GUARDED_BY(mLock);
    float mMaximumObscuringOpacityForTouch GUARDED_BY(mLock);

    // This map is not really needed, but it helps a lot with debugging (dumpsys input).
    // In the java layer, touch mode states are spread across multiple DisplayContent objects,
@@ -650,6 +646,8 @@ private:
    void addDragEventLocked(const MotionEntry& entry) REQUIRES(mLock);
    void finishDragAndDrop(ui::LogicalDisplayId displayId, float x, float y) REQUIRES(mLock);

    bool isTouchTrustedLocked(const DispatcherWindowInfo::TouchOcclusionInfo& occlusionInfo) const
            REQUIRES(mLock);
    std::string getApplicationWindowLabel(const InputApplicationHandle* applicationHandle,
                                          const sp<android::gui::WindowInfoHandle>& windowHandle);