Pass unique_ptr of InputChannel to Connection
This gets us closer to the goal of storing unique_ptr of InputChannel
inside the InputPublisher.
In this CL, we are still allowing the "copy" and "dup" functions to
exist. Removing those requires significant refactoring on the Java side,
including the jni layer and object ownership models.
Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST
Bug: 161009324
Change-Id: If6f44d78c7fc9f3e12729068de1753847abf0ebb
diff --git a/services/inputflinger/dispatcher/Connection.cpp b/services/inputflinger/dispatcher/Connection.cpp
index c7963c0..9dee66f 100644
--- a/services/inputflinger/dispatcher/Connection.cpp
+++ b/services/inputflinger/dispatcher/Connection.cpp
@@ -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