Use unique_ptr when creating InputChannel

InputChannel api will return unique_ptr, and it is up to the caller to
decide how to use that.

In most cases, the caller will proceed with making is a shared_ptr.

Bug: 142581626
Test: atest libinput_tests inputflinger_tests
Change-Id: Ice473a4c85241c63e3f4d6cdd30f8258ed7485e7
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 1bbddea..8dcc415 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -243,7 +243,7 @@
 
 // --- InputChannel ---
 
-std::shared_ptr<InputChannel> InputChannel::create(const std::string& name,
+std::unique_ptr<InputChannel> InputChannel::create(const std::string& name,
                                                    android::base::unique_fd fd, sp<IBinder> token) {
     const int result = fcntl(fd, F_SETFL, O_NONBLOCK);
     if (result != 0) {
@@ -252,7 +252,7 @@
         return nullptr;
     }
     // using 'new' to access a non-public constructor
-    return std::shared_ptr<InputChannel>(new InputChannel(name, std::move(fd), token));
+    return std::unique_ptr<InputChannel>(new InputChannel(name, std::move(fd), token));
 }
 
 InputChannel::InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token)
@@ -269,8 +269,8 @@
 }
 
 status_t InputChannel::openInputChannelPair(const std::string& name,
-                                            std::shared_ptr<InputChannel>& outServerChannel,
-                                            std::shared_ptr<InputChannel>& outClientChannel) {
+                                            std::unique_ptr<InputChannel>& outServerChannel,
+                                            std::unique_ptr<InputChannel>& outClientChannel) {
     int sockets[2];
     if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockets)) {
         status_t result = -errno;
@@ -376,7 +376,7 @@
     return OK;
 }
 
-std::shared_ptr<InputChannel> InputChannel::dup() const {
+std::unique_ptr<InputChannel> InputChannel::dup() const {
     android::base::unique_fd newFd(::dup(getFd()));
     if (!newFd.ok()) {
         ALOGE("Could not duplicate fd %i for channel %s: %s", getFd().get(), getName().c_str(),