Loading include/input/InputTransport.h +10 −1 Original line number Diff line number Diff line Loading @@ -300,6 +300,15 @@ public: void copyTo(android::os::InputChannelCore& outChannel) const; /** * Similar to "copyTo", but it takes ownership of the provided InputChannel (and after this is * called, it destroys it). * @param from the InputChannel that should be converted to InputChannelCore * @param outChannel the pre-allocated InputChannelCore to which to transfer the 'from' channel */ static void moveChannel(std::unique_ptr<InputChannel> from, android::os::InputChannelCore& outChannel); /** * The connection token is used to identify the input connection, i.e. * the pair of input channels that were created simultaneously. Input channels Loading Loading @@ -333,7 +342,7 @@ public: ~InputPublisher(); /* Gets the underlying input channel. */ inline std::shared_ptr<InputChannel> getChannel() const { return mChannel; } inline InputChannel& getChannel() const { return *mChannel; } /* Publishes a key event to the input channel. * Loading libs/input/InputTransport.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -584,6 +584,13 @@ void InputChannel::copyTo(android::os::InputChannelCore& outChannel) const { outChannel.token = getConnectionToken(); } void InputChannel::moveChannel(std::unique_ptr<InputChannel> from, android::os::InputChannelCore& outChannel) { outChannel.name = from->getName(); outChannel.fd = android::os::ParcelFileDescriptor(std::move(from->fd)); outChannel.token = from->getConnectionToken(); } sp<IBinder> InputChannel::getConnectionToken() const { return token; } Loading @@ -591,7 +598,7 @@ sp<IBinder> InputChannel::getConnectionToken() const { // --- InputPublisher --- InputPublisher::InputPublisher(const std::shared_ptr<InputChannel>& channel) : mChannel(channel), mInputVerifier(channel->getName()) {} : mChannel(channel), mInputVerifier(mChannel->getName()) {} InputPublisher::~InputPublisher() { } Loading libs/input/tests/InputPublisherAndConsumer_test.cpp +3 −10 Original line number Diff line number Diff line Loading @@ -220,7 +220,6 @@ void waitUntilInputAvailable(const InputConsumer& inputConsumer) { class InputPublisherAndConsumerTest : public testing::Test { protected: std::shared_ptr<InputChannel> mServerChannel, mClientChannel; std::unique_ptr<InputPublisher> mPublisher; std::unique_ptr<InputConsumer> mConsumer; PreallocatedInputEventFactory mEventFactory; Loading @@ -230,11 +229,9 @@ protected: status_t result = InputChannel::openInputChannelPair("channel name", serverChannel, clientChannel); ASSERT_EQ(OK, result); mServerChannel = std::move(serverChannel); mClientChannel = std::move(clientChannel); mPublisher = std::make_unique<InputPublisher>(mServerChannel); mConsumer = std::make_unique<InputConsumer>(mClientChannel); mPublisher = std::make_unique<InputPublisher>(std::move(serverChannel)); mConsumer = std::make_unique<InputConsumer>(std::move(clientChannel)); } void publishAndConsumeKeyEvent(); Loading @@ -254,11 +251,7 @@ private: }; TEST_F(InputPublisherAndConsumerTest, GetChannel_ReturnsTheChannel) { ASSERT_NE(nullptr, mPublisher->getChannel()); ASSERT_NE(nullptr, mConsumer->getChannel()); EXPECT_EQ(mServerChannel.get(), mPublisher->getChannel().get()); EXPECT_EQ(mClientChannel.get(), mConsumer->getChannel().get()); ASSERT_EQ(mPublisher->getChannel()->getConnectionToken(), ASSERT_EQ(mPublisher->getChannel().getConnectionToken(), mConsumer->getChannel()->getConnectionToken()); } Loading services/inputflinger/InputManager.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ binder::Status InputManager::createInputChannel(const std::string& name, return binder::Status::fromExceptionCode(exceptionCodeFromStatusT(channel.error().code()), channel.error().message().c_str()); } (*channel)->copyTo(*outChannel); InputChannel::moveChannel(std::move(*channel), *outChannel); return binder::Status::ok(); } Loading services/inputflinger/dispatcher/Connection.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ namespace android::inputdispatcher { Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, Connection::Connection(std::unique_ptr<InputChannel> inputChannel, bool monitor, const IdGenerator& idGenerator) : status(Status::NORMAL), monitor(monitor), inputPublisher(inputChannel), inputPublisher(std::move(inputChannel)), inputState(idGenerator) {} sp<IBinder> Connection::getToken() const { return inputPublisher.getChannel()->getConnectionToken(); return inputPublisher.getChannel().getConnectionToken(); }; } // namespace android::inputdispatcher Loading
include/input/InputTransport.h +10 −1 Original line number Diff line number Diff line Loading @@ -300,6 +300,15 @@ public: void copyTo(android::os::InputChannelCore& outChannel) const; /** * Similar to "copyTo", but it takes ownership of the provided InputChannel (and after this is * called, it destroys it). * @param from the InputChannel that should be converted to InputChannelCore * @param outChannel the pre-allocated InputChannelCore to which to transfer the 'from' channel */ static void moveChannel(std::unique_ptr<InputChannel> from, android::os::InputChannelCore& outChannel); /** * The connection token is used to identify the input connection, i.e. * the pair of input channels that were created simultaneously. Input channels Loading Loading @@ -333,7 +342,7 @@ public: ~InputPublisher(); /* Gets the underlying input channel. */ inline std::shared_ptr<InputChannel> getChannel() const { return mChannel; } inline InputChannel& getChannel() const { return *mChannel; } /* Publishes a key event to the input channel. * Loading
libs/input/InputTransport.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -584,6 +584,13 @@ void InputChannel::copyTo(android::os::InputChannelCore& outChannel) const { outChannel.token = getConnectionToken(); } void InputChannel::moveChannel(std::unique_ptr<InputChannel> from, android::os::InputChannelCore& outChannel) { outChannel.name = from->getName(); outChannel.fd = android::os::ParcelFileDescriptor(std::move(from->fd)); outChannel.token = from->getConnectionToken(); } sp<IBinder> InputChannel::getConnectionToken() const { return token; } Loading @@ -591,7 +598,7 @@ sp<IBinder> InputChannel::getConnectionToken() const { // --- InputPublisher --- InputPublisher::InputPublisher(const std::shared_ptr<InputChannel>& channel) : mChannel(channel), mInputVerifier(channel->getName()) {} : mChannel(channel), mInputVerifier(mChannel->getName()) {} InputPublisher::~InputPublisher() { } Loading
libs/input/tests/InputPublisherAndConsumer_test.cpp +3 −10 Original line number Diff line number Diff line Loading @@ -220,7 +220,6 @@ void waitUntilInputAvailable(const InputConsumer& inputConsumer) { class InputPublisherAndConsumerTest : public testing::Test { protected: std::shared_ptr<InputChannel> mServerChannel, mClientChannel; std::unique_ptr<InputPublisher> mPublisher; std::unique_ptr<InputConsumer> mConsumer; PreallocatedInputEventFactory mEventFactory; Loading @@ -230,11 +229,9 @@ protected: status_t result = InputChannel::openInputChannelPair("channel name", serverChannel, clientChannel); ASSERT_EQ(OK, result); mServerChannel = std::move(serverChannel); mClientChannel = std::move(clientChannel); mPublisher = std::make_unique<InputPublisher>(mServerChannel); mConsumer = std::make_unique<InputConsumer>(mClientChannel); mPublisher = std::make_unique<InputPublisher>(std::move(serverChannel)); mConsumer = std::make_unique<InputConsumer>(std::move(clientChannel)); } void publishAndConsumeKeyEvent(); Loading @@ -254,11 +251,7 @@ private: }; TEST_F(InputPublisherAndConsumerTest, GetChannel_ReturnsTheChannel) { ASSERT_NE(nullptr, mPublisher->getChannel()); ASSERT_NE(nullptr, mConsumer->getChannel()); EXPECT_EQ(mServerChannel.get(), mPublisher->getChannel().get()); EXPECT_EQ(mClientChannel.get(), mConsumer->getChannel().get()); ASSERT_EQ(mPublisher->getChannel()->getConnectionToken(), ASSERT_EQ(mPublisher->getChannel().getConnectionToken(), mConsumer->getChannel()->getConnectionToken()); } Loading
services/inputflinger/InputManager.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ binder::Status InputManager::createInputChannel(const std::string& name, return binder::Status::fromExceptionCode(exceptionCodeFromStatusT(channel.error().code()), channel.error().message().c_str()); } (*channel)->copyTo(*outChannel); InputChannel::moveChannel(std::move(*channel), *outChannel); return binder::Status::ok(); } Loading
services/inputflinger/dispatcher/Connection.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -20,15 +20,15 @@ namespace android::inputdispatcher { Connection::Connection(const std::shared_ptr<InputChannel>& inputChannel, bool monitor, Connection::Connection(std::unique_ptr<InputChannel> inputChannel, bool monitor, const IdGenerator& idGenerator) : status(Status::NORMAL), monitor(monitor), inputPublisher(inputChannel), inputPublisher(std::move(inputChannel)), inputState(idGenerator) {} sp<IBinder> Connection::getToken() const { return inputPublisher.getChannel()->getConnectionToken(); return inputPublisher.getChannel().getConnectionToken(); }; } // namespace android::inputdispatcher