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

Commit 26209e4e authored by Alan Stokes's avatar Alan Stokes
Browse files

Implement IntoRawFd for ParcelFileDescriptor.

This allows ownership of the fd to be taken, which otherwise currently
doesn`t seem to be possible.

Bug: 200129208
Test: Tested via compos_verify_key
Change-Id: I3ca1145f878f6a172d905c13fced151af3c98236
parent 963b7bba
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ use crate::error::{status_result, Result, StatusCode};
use crate::sys;

use std::fs::File;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};

/// Rust version of the Java class android.os.ParcelFileDescriptor
#[derive(Debug)]
@@ -54,6 +54,12 @@ impl AsRawFd for ParcelFileDescriptor {
    }
}

impl IntoRawFd for ParcelFileDescriptor {
    fn into_raw_fd(self) -> RawFd {
        self.0.into_raw_fd()
    }
}

impl Serialize for ParcelFileDescriptor {
    fn serialize(&self, parcel: &mut Parcel) -> Result<()> {
        let fd = self.0.as_raw_fd();