Proper duping / closing of FileDescriptors

While looking into another bug, I noticed that the file descriptors
do not get properly duped when converting to HidlMemory and that they
aren't explicitly closed when creating a temporary instance of
SharedMemory.

Test: Manual verification of ST functionality, which uses these
      utilities.
Fixes: 188931943
Change-Id: I76322c56c58be5db8f1a40eb20eb3b96552412f9
1 file changed