applypatch: Use unique_fd to avoid leaking FDs.

Add unique_fd that calls ota_close() instead of the default closer.

Test: recovery_component_test passes.
Test: Apply a package that calls apply_patch().

Change-Id: I0c19921731757934f76cf7d5215916673a8f2777
diff --git a/otafault/ota_io.h b/otafault/ota_io.h
index 84187a7..e119eef 100644
--- a/otafault/ota_io.h
+++ b/otafault/ota_io.h
@@ -26,6 +26,8 @@
 #include <stdio.h>
 #include <sys/stat.h>
 
+#include <android-base/unique_fd.h>
+
 #define OTAIO_CACHE_FNAME "/cache/saved.file"
 
 void ota_set_fault_files();
@@ -50,4 +52,12 @@
 
 int ota_fsync(int fd);
 
+struct OtaCloser {
+  static void Close(int fd) {
+    ota_close(fd);
+  }
+};
+
+using unique_fd = android::base::unique_fd_impl<OtaCloser>;
+
 #endif