Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b7ec941 authored by Ytai Ben-Tsvi's avatar Ytai Ben-Tsvi Committed by Ytai Ben-tsvi
Browse files

Avoid unnecessary dup

fileDescriptorToHidlMemory() does not take ownership of the
FileDescriptor, so no need to dup it.

Test: Manual verification of soundtrigger use-cases
Bug: 202424221
Change-Id: I43ab5c25f5b3abdec236c0a78a03a197ad2d0da2
Merged-In: I43ab5c25f5b3abdec236c0a78a03a197ad2d0da2
parent 3d4a7e57
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -429,15 +429,7 @@ class ConversionUtil {
    private static @NonNull
    HidlMemory parcelFileDescriptorToHidlMemory(@Nullable ParcelFileDescriptor data, int dataSize) {
        if (dataSize > 0) {
            // Extract a dup of the underlying FileDescriptor out of data.
            FileDescriptor fd = new FileDescriptor();
            try {
                ParcelFileDescriptor dup = data.dup();
                fd.setInt$(dup.detachFd());
                return HidlMemoryUtil.fileDescriptorToHidlMemory(fd, dataSize);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return HidlMemoryUtil.fileDescriptorToHidlMemory(data.getFileDescriptor(), dataSize);
        } else {
            return HidlMemoryUtil.fileDescriptorToHidlMemory(null, 0);
        }