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

Commit 58cfc60c authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Add pid to monitor

The dispatcher will now have pid information of each monitor. This
information will be used to raise ANRs.

Bug: 175593831
Test: atest inputflinger_tests
Change-Id: Ief3bbe36e06ac7c36039f08739fc10b3c2291530
parent fc4d0494
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -4827,7 +4827,7 @@ base::Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputChannel(
}
}


base::Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(
base::Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(
        int32_t displayId, bool isGestureMonitor, const std::string& name) {
        int32_t displayId, bool isGestureMonitor, const std::string& name, int32_t pid) {
    std::shared_ptr<InputChannel> serverChannel;
    std::shared_ptr<InputChannel> serverChannel;
    std::unique_ptr<InputChannel> clientChannel;
    std::unique_ptr<InputChannel> clientChannel;
    status_t result = openInputChannelPair(name, serverChannel, clientChannel);
    status_t result = openInputChannelPair(name, serverChannel, clientChannel);
@@ -4851,7 +4851,7 @@ base::Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(


        auto& monitorsByDisplay =
        auto& monitorsByDisplay =
                isGestureMonitor ? mGestureMonitorsByDisplay : mGlobalMonitorsByDisplay;
                isGestureMonitor ? mGestureMonitorsByDisplay : mGlobalMonitorsByDisplay;
        monitorsByDisplay[displayId].emplace_back(serverChannel);
        monitorsByDisplay[displayId].emplace_back(serverChannel, pid);


        mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this);
        mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, handleReceiveCallback, this);
    }
    }
+4 −2
Original line number Original line Diff line number Diff line
@@ -123,8 +123,10 @@ public:
    virtual base::Result<std::unique_ptr<InputChannel>> createInputChannel(
    virtual base::Result<std::unique_ptr<InputChannel>> createInputChannel(
            const std::string& name) override;
            const std::string& name) override;
    virtual void setFocusedWindow(const FocusRequest&) override;
    virtual void setFocusedWindow(const FocusRequest&) override;
    virtual base::Result<std::unique_ptr<InputChannel>> createInputMonitor(
    virtual base::Result<std::unique_ptr<InputChannel>> createInputMonitor(int32_t displayId,
            int32_t displayId, bool isGestureMonitor, const std::string& name) override;
                                                                           bool isGestureMonitor,
                                                                           const std::string& name,
                                                                           int32_t pid) override;
    virtual status_t removeInputChannel(const sp<IBinder>& connectionToken) override;
    virtual status_t removeInputChannel(const sp<IBinder>& connectionToken) override;
    virtual status_t pilferPointers(const sp<IBinder>& token) override;
    virtual status_t pilferPointers(const sp<IBinder>& token) override;
    virtual void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) override;
    virtual void requestPointerCapture(const sp<IBinder>& windowToken, bool enabled) override;
+2 −1
Original line number Original line Diff line number Diff line
@@ -19,7 +19,8 @@
namespace android::inputdispatcher {
namespace android::inputdispatcher {


// --- Monitor ---
// --- Monitor ---
Monitor::Monitor(const std::shared_ptr<InputChannel>& inputChannel) : inputChannel(inputChannel) {}
Monitor::Monitor(const std::shared_ptr<InputChannel>& inputChannel, int32_t pid)
      : inputChannel(inputChannel), pid(pid) {}


// --- TouchedMonitor ---
// --- TouchedMonitor ---
TouchedMonitor::TouchedMonitor(const Monitor& monitor, float xOffset, float yOffset)
TouchedMonitor::TouchedMonitor(const Monitor& monitor, float xOffset, float yOffset)
+3 −1
Original line number Original line Diff line number Diff line
@@ -24,7 +24,9 @@ namespace android::inputdispatcher {
struct Monitor {
struct Monitor {
    std::shared_ptr<InputChannel> inputChannel; // never null
    std::shared_ptr<InputChannel> inputChannel; // never null


    explicit Monitor(const std::shared_ptr<InputChannel>& inputChannel);
    int32_t pid;

    explicit Monitor(const std::shared_ptr<InputChannel>& inputChannel, int32_t pid);
};
};


// For tracking the offsets we need to apply when adding gesture monitor targets.
// For tracking the offsets we need to apply when adding gesture monitor targets.
+4 −2
Original line number Original line Diff line number Diff line
@@ -172,8 +172,10 @@ public:
     *
     *
     * This method may be called on any thread (usually by the input manager).
     * This method may be called on any thread (usually by the input manager).
     */
     */
    virtual base::Result<std::unique_ptr<InputChannel>> createInputMonitor(
    virtual base::Result<std::unique_ptr<InputChannel>> createInputMonitor(int32_t displayId,
            int32_t displayId, bool gestureMonitor, const std::string& name) = 0;
                                                                           bool gestureMonitor,
                                                                           const std::string& name,
                                                                           int32_t pid) = 0;


    /* Removes input channels that will no longer receive input events.
    /* Removes input channels that will no longer receive input events.
     *
     *
Loading