Implement Debug for a few Binder Rust types
Test: mmma system/security/keystore2
Change-Id: I6d5413366dd258a1cef887908f98bfb130103943
diff --git a/libs/binder/rust/src/binder.rs b/libs/binder/rust/src/binder.rs
index d55eafe..9cfa589 100644
--- a/libs/binder/rust/src/binder.rs
+++ b/libs/binder/rust/src/binder.rs
@@ -581,5 +581,11 @@
parcel.write(&this.map($crate::Interface::as_binder))
}
}
+
+ impl std::fmt::Debug for dyn $interface {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.pad(stringify!($interface))
+ }
+ }
};
}
diff --git a/libs/binder/rust/src/parcel/file_descriptor.rs b/libs/binder/rust/src/parcel/file_descriptor.rs
index 8a89ab0..20e9178 100644
--- a/libs/binder/rust/src/parcel/file_descriptor.rs
+++ b/libs/binder/rust/src/parcel/file_descriptor.rs
@@ -26,6 +26,7 @@
use std::os::unix::io::{AsRawFd, FromRawFd};
/// Rust version of the Java class android.os.ParcelFileDescriptor
+#[derive(Debug)]
pub struct ParcelFileDescriptor(File);
impl ParcelFileDescriptor {
diff --git a/libs/binder/rust/src/proxy.rs b/libs/binder/rust/src/proxy.rs
index 13e5619..5602c96 100644
--- a/libs/binder/rust/src/proxy.rs
+++ b/libs/binder/rust/src/proxy.rs
@@ -28,6 +28,7 @@
use std::convert::TryInto;
use std::ffi::{c_void, CString};
+use std::fmt;
use std::os::unix::io::AsRawFd;
use std::ptr;
@@ -37,6 +38,12 @@
/// is untyped; typed interface access is implemented by the AIDL compiler.
pub struct SpIBinder(*mut sys::AIBinder);
+impl fmt::Debug for SpIBinder {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.pad("SpIBinder")
+ }
+}
+
/// # Safety
///
/// An `SpIBinder` is a handle to a C++ IBinder, which is thread-safe