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

Commit b5e890c5 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Automerger Merge Worker
Browse files

Merge "input: don't depend on unique_fd cast to int" into main am: 5f71d925

parents 1e529a6d 5f71d925
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ public:
                                                android::base::unique_fd fd, sp<IBinder> token);
    InputChannel() = default;
    InputChannel(const InputChannel& other)
          : mName(other.mName), mFd(::dup(other.mFd)), mToken(other.mToken){};
          : mName(other.mName), mFd(other.dupFd()), mToken(other.mToken){};
    InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token);
    ~InputChannel() override;
    /**
@@ -310,7 +310,7 @@ public:
        if (fstat(mFd.get(), &lhs) != 0) {
            return false;
        }
        if (fstat(inputChannel.getFd(), &rhs) != 0) {
        if (fstat(inputChannel.getFd().get(), &rhs) != 0) {
            return false;
        }
        // If file descriptors are pointing to same inode they are duplicated fds.
@@ -322,7 +322,7 @@ private:
    base::unique_fd dupFd() const;

    std::string mName;
    android::base::unique_fd mFd;
    base::unique_fd mFd;

    sp<IBinder> mToken;
};
+3 −3
Original line number Diff line number Diff line
@@ -424,7 +424,7 @@ status_t InputChannel::sendMessage(const InputMessage* msg) {
    msg->getSanitizedCopy(&cleanMsg);
    ssize_t nWrite;
    do {
        nWrite = ::send(getFd(), &cleanMsg, msgLength, MSG_DONTWAIT | MSG_NOSIGNAL);
        nWrite = ::send(getFd().get(), &cleanMsg, msgLength, MSG_DONTWAIT | MSG_NOSIGNAL);
    } while (nWrite == -1 && errno == EINTR);

    if (nWrite < 0) {
@@ -455,7 +455,7 @@ status_t InputChannel::sendMessage(const InputMessage* msg) {
status_t InputChannel::receiveMessage(InputMessage* msg) {
    ssize_t nRead;
    do {
        nRead = ::recv(getFd(), msg, sizeof(InputMessage), MSG_DONTWAIT);
        nRead = ::recv(getFd().get(), msg, sizeof(InputMessage), MSG_DONTWAIT);
    } while (nRead == -1 && errno == EINTR);

    if (nRead < 0) {
@@ -521,7 +521,7 @@ sp<IBinder> InputChannel::getConnectionToken() const {
}

base::unique_fd InputChannel::dupFd() const {
    android::base::unique_fd newFd(::dup(getFd()));
    base::unique_fd newFd(::dup(getFd().get()));
    if (!newFd.ok()) {
        ALOGE("Could not duplicate fd %i for channel %s: %s", getFd().get(), getName().c_str(),
              strerror(errno));
+5 −5
Original line number Diff line number Diff line
@@ -5837,7 +5837,7 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputChannel(const
    { // acquire lock
        std::scoped_lock _l(mLock);
        const sp<IBinder>& token = serverChannel->getConnectionToken();
        int fd = serverChannel->getFd();
        auto&& fd = serverChannel->getFd();
        std::shared_ptr<Connection> connection =
                std::make_shared<Connection>(std::move(serverChannel), /*monitor=*/false,
                                             mIdGenerator);
@@ -5850,7 +5850,7 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputChannel(const
        std::function<int(int events)> callback = std::bind(&InputDispatcher::handleReceiveCallback,
                                                            this, std::placeholders::_1, token);

        mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, sp<LooperEventCallback>::make(callback),
        mLooper->addFd(fd.get(), 0, ALOOPER_EVENT_INPUT, sp<LooperEventCallback>::make(callback),
                       nullptr);
    } // release lock

@@ -5880,7 +5880,7 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(int32_
        std::shared_ptr<Connection> connection =
                std::make_shared<Connection>(serverChannel, /*monitor=*/true, mIdGenerator);
        const sp<IBinder>& token = serverChannel->getConnectionToken();
        const int fd = serverChannel->getFd();
        auto&& fd = serverChannel->getFd();

        if (mConnectionsByToken.find(token) != mConnectionsByToken.end()) {
            ALOGE("Created a new connection, but the token %p is already known", token.get());
@@ -5891,7 +5891,7 @@ Result<std::unique_ptr<InputChannel>> InputDispatcher::createInputMonitor(int32_

        mGlobalMonitorsByDisplay[displayId].emplace_back(serverChannel, pid);

        mLooper->addFd(fd, 0, ALOOPER_EVENT_INPUT, sp<LooperEventCallback>::make(callback),
        mLooper->addFd(fd.get(), 0, ALOOPER_EVENT_INPUT, sp<LooperEventCallback>::make(callback),
                       nullptr);
    }

@@ -5930,7 +5930,7 @@ status_t InputDispatcher::removeInputChannelLocked(const sp<IBinder>& connection
        removeMonitorChannelLocked(connectionToken);
    }

    mLooper->removeFd(connection->inputChannel->getFd());
    mLooper->removeFd(connection->inputChannel->getFd().get());

    nsecs_t currentTime = now();
    abortBrokenDispatchCycleLocked(currentTime, connection, notify);