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

Commit 75223155 authored by Arpit Singh's avatar Arpit Singh
Browse files

Revert "[8/n InputDispatcher refactor] move input connections to a subclass"

This reverts commit 49586f42.

Reason for revert: b/389067592

Change-Id: Iccaf60f7143a337e055d43170b16543f41163360
parent 774d9375
Loading
Loading
Loading
Loading
+155 −196

File changed.

Preview size limit exceeded, changes collapsed.

+23 −42
Original line number Diff line number Diff line
@@ -260,6 +260,13 @@ private:
            const std::unordered_map<ui::LogicalDisplayId, TouchState>& touchStatesByDisplay,
            ui::LogicalDisplayId displayId);

    std::shared_ptr<Connection> getConnectionLocked(const sp<IBinder>& inputConnectionToken) const
            REQUIRES(mLock);

    std::string getConnectionNameLocked(const sp<IBinder>& connectionToken) const REQUIRES(mLock);

    void removeConnectionLocked(const std::shared_ptr<Connection>& connection) REQUIRES(mLock);

    status_t pilferPointersLocked(const sp<IBinder>& token) REQUIRES(mLock);

    template <typename T>
@@ -267,6 +274,17 @@ private:
        std::size_t operator()(const sp<T>& b) const { return std::hash<T*>{}(b.get()); }
    };

    // All registered connections mapped by input channel token.
    std::unordered_map<sp<IBinder>, std::shared_ptr<Connection>, StrongPointerHash<IBinder>>
            mConnectionsByToken GUARDED_BY(mLock);

    // Find a monitor pid by the provided token.
    std::optional<gui::Pid> findMonitorPidByTokenLocked(const sp<IBinder>& token) REQUIRES(mLock);

    // Input channels that will receive a copy of all input events sent to the provided display.
    std::unordered_map<ui::LogicalDisplayId, std::vector<Monitor>> mGlobalMonitorsByDisplay
            GUARDED_BY(mLock);

    const HmacKeyManager mHmacKeyManager;
    const std::array<uint8_t, 32> getSignature(const MotionEntry& motionEntry,
                                               const DispatchEntry& dispatchEntry) const;
@@ -399,48 +417,6 @@ private:

    DispatcherWindowInfo mWindowInfos GUARDED_BY(mLock);

    class ConnectionManager {
    public:
        ConnectionManager(sp<Looper> lopper);
        ~ConnectionManager();

        std::shared_ptr<Connection> getConnection(const sp<IBinder>& inputConnectionToken) const;

        // Find a monitor pid by the provided token.
        std::optional<gui::Pid> findMonitorPidByToken(const sp<IBinder>& token) const;
        void forEachGlobalMonitorConnection(
                std::function<void(const std::shared_ptr<Connection>&)> f) const;
        void forEachGlobalMonitorConnection(
                ui::LogicalDisplayId displayId,
                std::function<void(const std::shared_ptr<Connection>&)> f) const;

        void createGlobalInputMonitor(ui::LogicalDisplayId displayId,
                                      std::unique_ptr<InputChannel>&& inputChannel,
                                      const IdGenerator& idGenerator, gui::Pid pid);

        status_t removeInputChannel(const std::shared_ptr<Connection>& connection);
        void removeConnection(const std::shared_ptr<Connection>& connection);

        void createConnection(std::unique_ptr<InputChannel>&& inputChannel,
                              const IdGenerator& idGenerator);

        std::string dump(nsecs_t currentTime) const;

    private:
        sp<Looper> mLooper;

        // All registered connections mapped by input channel token.
        std::unordered_map<sp<IBinder>, std::shared_ptr<Connection>, StrongPointerHash<IBinder>>
                mConnectionsByToken;

        // Input channels that will receive a copy of all input events sent to the provided display.
        std::unordered_map<ui::LogicalDisplayId, std::vector<Monitor>> mGlobalMonitorsByDisplay;

        void removeMonitorChannel(const sp<IBinder>& connectionToken);
    };

    ConnectionManager mConnectionManager GUARDED_BY(mLock);

    void setInputWindowsLocked(
            const std::vector<sp<android::gui::WindowInfoHandle>>& inputWindowHandles,
            ui::LogicalDisplayId displayId) REQUIRES(mLock);
@@ -606,6 +582,8 @@ private:
                                  nsecs_t& nextWakeupTime) REQUIRES(mLock);
    base::Result<std::vector<InputTarget>, android::os::InputEventInjectionResult>
    findTouchedWindowTargetsLocked(nsecs_t currentTime, const MotionEntry& entry) REQUIRES(mLock);
    std::vector<Monitor> selectResponsiveMonitorsLocked(
            const std::vector<Monitor>& gestureMonitors) const REQUIRES(mLock);

    void addWindowTargetLocked(const sp<android::gui::WindowInfoHandle>& windowHandle,
                               InputTarget::DispatchMode dispatchMode,
@@ -711,9 +689,12 @@ private:

    // Dump state.
    void dumpDispatchStateLocked(std::string& dump) const REQUIRES(mLock);
    void dumpMonitors(std::string& dump, const std::vector<Monitor>& monitors) const;
    void logDispatchStateLocked() const REQUIRES(mLock);
    std::string dumpPointerCaptureStateLocked() const REQUIRES(mLock);

    // Registration.
    void removeMonitorChannelLocked(const sp<IBinder>& connectionToken) REQUIRES(mLock);
    status_t removeInputChannelLocked(const std::shared_ptr<Connection>& connection, bool notify)
            REQUIRES(mLock);