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

Commit 64b5bc46 authored by Yiming Jing's avatar Yiming Jing
Browse files

Implement the clone trait for ParcelableHolder

For the parity with the C++/NDK implementation, make the Rust
ParcelableHolder cloneable.

Bug: 210093811
Fix: 285042738
Test: m
Test: declare a cloneable Parcelable with a ParcelableHolder and then
check if build succeeds
Change-Id: Iac161ec01007045cf1bee0632e56494e76f9c04a
parent 7c853f50
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -161,6 +161,15 @@ impl ParcelableHolder {
    }
}

impl Clone for ParcelableHolder {
    fn clone(&self) -> ParcelableHolder {
        ParcelableHolder {
            data: Mutex::new(self.data.lock().unwrap().clone()),
            stability: self.stability,
        }
    }
}

impl Serialize for ParcelableHolder {
    fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<(), StatusCode> {
        parcel.write(&NON_NULL_PARCELABLE_FLAG)?;