Rewrite input transport using sockets.

Since we will not longer be modifying events in place, we don't need
to use an ashmem region for input.  Simplified the code to instead
use a socket of type SOCK_SEQPACKET.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I05909075ed8b61b93900913e44c6db84857340d8
diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp
index fce432b..5377425 100644
--- a/core/jni/android_view_InputChannel.cpp
+++ b/core/jni/android_view_InputChannel.cpp
@@ -199,32 +199,16 @@
         bool isInitialized = parcel->readInt32();
         if (isInitialized) {
             String8 name = parcel->readString8();
-            int32_t parcelAshmemFd = parcel->readFileDescriptor();
-            int32_t ashmemFd = dup(parcelAshmemFd);
-            if (ashmemFd < 0) {
-                ALOGE("Error %d dup ashmem fd %d.", errno, parcelAshmemFd);
-            }
-            int32_t parcelReceivePipeFd = parcel->readFileDescriptor();
-            int32_t receivePipeFd = dup(parcelReceivePipeFd);
-            if (receivePipeFd < 0) {
-                ALOGE("Error %d dup receive pipe fd %d.", errno, parcelReceivePipeFd);
-            }
-            int32_t parcelSendPipeFd = parcel->readFileDescriptor();
-            int32_t sendPipeFd = dup(parcelSendPipeFd);
-            if (sendPipeFd < 0) {
-                ALOGE("Error %d dup send pipe fd %d.", errno, parcelSendPipeFd);
-            }
-            if (ashmemFd < 0 || receivePipeFd < 0 || sendPipeFd < 0) {
-                if (ashmemFd >= 0) ::close(ashmemFd);
-                if (receivePipeFd >= 0) ::close(receivePipeFd);
-                if (sendPipeFd >= 0) ::close(sendPipeFd);
+            int32_t rawFd = parcel->readFileDescriptor();
+            int32_t dupFd = dup(rawFd);
+            if (rawFd < 0) {
+                ALOGE("Error %d dup channel fd %d.", errno, rawFd);
                 jniThrowRuntimeException(env,
                         "Could not read input channel file descriptors from parcel.");
                 return;
             }
 
-            InputChannel* inputChannel = new InputChannel(name, ashmemFd,
-                    receivePipeFd, sendPipeFd);
+            InputChannel* inputChannel = new InputChannel(name, dupFd);
             NativeInputChannel* nativeInputChannel = new NativeInputChannel(inputChannel);
 
             android_view_InputChannel_setNativeInputChannel(env, obj, nativeInputChannel);
@@ -243,9 +227,7 @@
 
             parcel->writeInt32(1);
             parcel->writeString8(inputChannel->getName());
-            parcel->writeDupFileDescriptor(inputChannel->getAshmemFd());
-            parcel->writeDupFileDescriptor(inputChannel->getReceivePipeFd());
-            parcel->writeDupFileDescriptor(inputChannel->getSendPipeFd());
+            parcel->writeDupFileDescriptor(inputChannel->getFd());
         } else {
             parcel->writeInt32(0);
         }