Revert "Add support for unique_fds and vectors of file descriptors"

This reverts commit 9626d88882972d45576dcceedc037d2e9843196b.

Change-Id: I6121f388d17c6f2d0cf6f31bc42f0804dd72aba2
diff --git a/libs/binder/Android.mk b/libs/binder/Android.mk
index f06b9ca..ce29ea6 100644
--- a/libs/binder/Android.mk
+++ b/libs/binder/Android.mk
@@ -42,7 +42,7 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := libbinder
-LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libbase
+LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
 
 LOCAL_CLANG := true
 LOCAL_SANITIZE := integer
@@ -57,7 +57,7 @@
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := libbinder
-LOCAL_STATIC_LIBRARIES += libutils libbase
+LOCAL_STATIC_LIBRARIES += libutils
 LOCAL_SRC_FILES := $(sources)
 ifneq ($(TARGET_USES_64_BIT_BINDER),true)
 ifneq ($(TARGET_IS_64_BIT),true)
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index a7d27bd..c808948 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -82,8 +82,6 @@
 
 namespace android {
 
-using android::base::unique_fd;
-
 static pthread_mutex_t gParcelGlobalAllocSizeLock = PTHREAD_MUTEX_INITIALIZER;
 static size_t gParcelGlobalAllocSize = 0;
 static size_t gParcelGlobalAllocCount = 0;
@@ -1049,20 +1047,12 @@
         return -errno;
     }
     status_t err = writeFileDescriptor(dupFd, true /*takeOwnership*/);
-    if (err != OK) {
+    if (err) {
         close(dupFd);
     }
     return err;
 }
 
-status_t Parcel::writeUniqueFileDescriptor(const unique_fd& fd) {
-    return writeDupFileDescriptor(fd.get());
-}
-
-status_t Parcel::writeUniqueFileDescriptorVector(const std::vector<unique_fd>& val) {
-    return writeTypedVector(val, this, &Parcel::writeUniqueFileDescriptor);
-}
-
 status_t Parcel::writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob)
 {
     if (len > INT32_MAX) {
@@ -1674,36 +1664,16 @@
 int Parcel::readFileDescriptor() const
 {
     const flat_binder_object* flat = readObject(true);
-
-    if (flat && flat->type == BINDER_TYPE_FD) {
-        return flat->handle;
+    if (flat) {
+        switch (flat->type) {
+            case BINDER_TYPE_FD:
+                //ALOGI("Returning file descriptor %ld from parcel %p", flat->handle, this);
+                return flat->handle;
+        }
     }
-
     return BAD_TYPE;
 }
 
-status_t Parcel::readUniqueFileDescriptor(unique_fd* val) const
-{
-    int got = readFileDescriptor();
-
-    if (got == BAD_TYPE) {
-        return BAD_TYPE;
-    }
-
-    val->reset(dup(got));
-
-    if (val->get() < 0) {
-        return BAD_VALUE;
-    }
-
-    return OK;
-}
-
-
-status_t Parcel::readUniqueFileDescriptorVector(std::vector<unique_fd>* val) const {
-    return readTypedVector(val, this, &Parcel::readUniqueFileDescriptor);
-}
-
 status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const
 {
     int32_t blobType;