diff options
| author | 2020-10-02 16:21:54 +0000 | |
|---|---|---|
| committer | 2020-10-02 16:21:54 +0000 | |
| commit | 00633648701baed9d13ab47c676ad0eccb021a7c (patch) | |
| tree | 03a3fb2f557d46c001205f37ff3933f12cef8288 | |
| parent | 11c276ec69142d9868f6bd163982427809276e5f (diff) | |
| parent | 3281437213dd9d8dce1e12f9141b71104f198738 (diff) | |
Merge "Changes to UNEXPECTED_NULL handling in libbinder_rs."
| -rw-r--r-- | libs/binder/rust/src/binder.rs | 12 | ||||
| -rw-r--r-- | libs/binder/rust/src/proxy.rs | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/libs/binder/rust/src/binder.rs b/libs/binder/rust/src/binder.rs index 81a5f02e3e..6d0a369b7a 100644 --- a/libs/binder/rust/src/binder.rs +++ b/libs/binder/rust/src/binder.rs @@ -532,7 +532,17 @@ macro_rules! declare_binder_interface { } fn on_transact(&self, code: $crate::TransactionCode, data: &$crate::Parcel, reply: &mut $crate::Parcel) -> $crate::Result<()> { - $on_transact(&*self.0, code, data, reply) + match $on_transact(&*self.0, code, data, reply) { + // The C++ backend converts UNEXPECTED_NULL into an exception + Err($crate::StatusCode::UNEXPECTED_NULL) => { + let status = $crate::Status::new_exception( + $crate::ExceptionCode::NULL_POINTER, + None, + ); + reply.write(&status) + }, + result => result + } } fn get_class() -> $crate::InterfaceClass { diff --git a/libs/binder/rust/src/proxy.rs b/libs/binder/rust/src/proxy.rs index 82212d8120..5002fc6d83 100644 --- a/libs/binder/rust/src/proxy.rs +++ b/libs/binder/rust/src/proxy.rs @@ -352,7 +352,10 @@ impl SerializeArray for Option<&SpIBinder> {} impl Deserialize for SpIBinder { fn deserialize(parcel: &Parcel) -> Result<SpIBinder> { - parcel.read_binder().transpose().unwrap() + parcel + .read_binder() + .transpose() + .unwrap_or(Err(StatusCode::UNEXPECTED_NULL)) } } |