Loading PREUPLOAD.cfg +2 −0 Original line number Diff line number Diff line [Builtin Hooks] rustfmt = true bpfmt = true clang_format = true [Builtin Hooks Options] rustfmt = --config-path=rustfmt.toml # Only turn on clang-format check for the following subfolders. clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp cmds/idlcli/ Loading libs/binder/rust/binder_tokio/lib.rs +9 −9 Original line number Diff line number Diff line Loading @@ -28,22 +28,22 @@ //! //! [`Tokio`]: crate::Tokio use binder::{BinderAsyncPool, BoxFuture, FromIBinder, StatusCode, Strong}; use binder::binder_impl::BinderAsyncRuntime; use binder::{BinderAsyncPool, BoxFuture, FromIBinder, StatusCode, Strong}; use std::future::Future; /// Retrieve an existing service for a particular interface, sleeping for a few /// seconds if it doesn't yet exist. pub async fn get_interface<T: FromIBinder + ?Sized + 'static>(name: &str) -> Result<Strong<T>, StatusCode> { pub async fn get_interface<T: FromIBinder + ?Sized + 'static>( name: &str, ) -> Result<Strong<T>, StatusCode> { if binder::is_handling_transaction() { // See comment in the BinderAsyncPool impl. return binder::get_interface::<T>(name); } let name = name.to_string(); let res = tokio::task::spawn_blocking(move || { binder::get_interface::<T>(&name) }).await; let res = tokio::task::spawn_blocking(move || binder::get_interface::<T>(&name)).await; // The `is_panic` branch is not actually reachable in Android as we compile // with `panic = abort`. Loading @@ -58,16 +58,16 @@ pub async fn get_interface<T: FromIBinder + ?Sized + 'static>(name: &str) -> Res /// Retrieve an existing service for a particular interface, or start it if it /// is configured as a dynamic service and isn't yet started. pub async fn wait_for_interface<T: FromIBinder + ?Sized + 'static>(name: &str) -> Result<Strong<T>, StatusCode> { pub async fn wait_for_interface<T: FromIBinder + ?Sized + 'static>( name: &str, ) -> Result<Strong<T>, StatusCode> { if binder::is_handling_transaction() { // See comment in the BinderAsyncPool impl. return binder::wait_for_interface::<T>(name); } let name = name.to_string(); let res = tokio::task::spawn_blocking(move || { binder::wait_for_interface::<T>(&name) }).await; let res = tokio::task::spawn_blocking(move || binder::wait_for_interface::<T>(&name)).await; // The `is_panic` branch is not actually reachable in Android as we compile // with `panic = abort`. Loading libs/binder/rust/src/binder.rs +17 −16 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ //! Trait definitions for binder objects use crate::error::{status_t, Result, StatusCode}; use crate::parcel::{Parcel, BorrowedParcel}; use crate::parcel::{BorrowedParcel, Parcel}; use crate::proxy::{DeathRecipient, SpIBinder, WpIBinder}; use crate::sys; Loading Loading @@ -133,7 +133,7 @@ impl TryFrom<i32> for Stability { match stability { 0 => Ok(Local), 1 => Ok(Vintf), _ => Err(StatusCode::BAD_VALUE) _ => Err(StatusCode::BAD_VALUE), } } } Loading @@ -158,7 +158,12 @@ pub trait Remotable: Send + Sync { /// Handle and reply to a request to invoke a transaction on this object. /// /// `reply` may be [`None`] if the sender does not expect a reply. fn on_transact(&self, code: TransactionCode, data: &BorrowedParcel<'_>, reply: &mut BorrowedParcel<'_>) -> Result<()>; fn on_transact( &self, code: TransactionCode, data: &BorrowedParcel<'_>, reply: &mut BorrowedParcel<'_>, ) -> Result<()>; /// Handle a request to invoke the dump transaction on this /// object. Loading Loading @@ -454,28 +459,19 @@ impl<I: FromIBinder + ?Sized> Weak<I> { /// Construct a new weak reference from a strong reference fn new(binder: &Strong<I>) -> Self { let weak_binder = binder.as_binder().downgrade(); Weak { weak_binder, interface_type: PhantomData, } Weak { weak_binder, interface_type: PhantomData } } /// Upgrade this weak reference to a strong reference if the binder object /// is still alive pub fn upgrade(&self) -> Result<Strong<I>> { self.weak_binder .promote() .ok_or(StatusCode::DEAD_OBJECT) .and_then(FromIBinder::try_from) self.weak_binder.promote().ok_or(StatusCode::DEAD_OBJECT).and_then(FromIBinder::try_from) } } impl<I: FromIBinder + ?Sized> Clone for Weak<I> { fn clone(&self) -> Self { Self { weak_binder: self.weak_binder.clone(), interface_type: PhantomData, } Self { weak_binder: self.weak_binder.clone(), interface_type: PhantomData } } } Loading Loading @@ -614,7 +610,12 @@ pub trait InterfaceClassMethods { /// contains a `T` pointer in its user data. fd should be a non-owned file /// descriptor, and args must be an array of null-terminated string /// poiinters with length num_args. unsafe extern "C" fn on_dump(binder: *mut sys::AIBinder, fd: i32, args: *mut *const c_char, num_args: u32) -> status_t; unsafe extern "C" fn on_dump( binder: *mut sys::AIBinder, fd: i32, args: *mut *const c_char, num_args: u32, ) -> status_t; } /// Interface for transforming a generic SpIBinder into a specific remote Loading libs/binder/rust/src/binder_async.rs +4 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,10 @@ pub trait BinderAsyncPool { /// boxed `Future` trait object, and including `after_spawn` in the trait function /// allows the caller to avoid double-boxing if they want to do anything to the value /// returned from the spawned thread. fn spawn<'a, F1, F2, Fut, A, B, E>(spawn_me: F1, after_spawn: F2) -> BoxFuture<'a, Result<B, E>> fn spawn<'a, F1, F2, Fut, A, B, E>( spawn_me: F1, after_spawn: F2, ) -> BoxFuture<'a, Result<B, E>> where F1: FnOnce() -> A, F2: FnOnce(A) -> Fut, Loading libs/binder/rust/src/lib.rs +1 −1 Original line number Diff line number Diff line Loading @@ -106,8 +106,8 @@ mod state; use binder_ndk_sys as sys; pub use binder::{BinderFeatures, FromIBinder, IBinder, Interface, Strong, Weak}; pub use crate::binder_async::{BinderAsyncPool, BoxFuture}; pub use binder::{BinderFeatures, FromIBinder, IBinder, Interface, Strong, Weak}; pub use error::{ExceptionCode, Status, StatusCode}; pub use native::{ add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Loading Loading
PREUPLOAD.cfg +2 −0 Original line number Diff line number Diff line [Builtin Hooks] rustfmt = true bpfmt = true clang_format = true [Builtin Hooks Options] rustfmt = --config-path=rustfmt.toml # Only turn on clang-format check for the following subfolders. clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp cmds/idlcli/ Loading
libs/binder/rust/binder_tokio/lib.rs +9 −9 Original line number Diff line number Diff line Loading @@ -28,22 +28,22 @@ //! //! [`Tokio`]: crate::Tokio use binder::{BinderAsyncPool, BoxFuture, FromIBinder, StatusCode, Strong}; use binder::binder_impl::BinderAsyncRuntime; use binder::{BinderAsyncPool, BoxFuture, FromIBinder, StatusCode, Strong}; use std::future::Future; /// Retrieve an existing service for a particular interface, sleeping for a few /// seconds if it doesn't yet exist. pub async fn get_interface<T: FromIBinder + ?Sized + 'static>(name: &str) -> Result<Strong<T>, StatusCode> { pub async fn get_interface<T: FromIBinder + ?Sized + 'static>( name: &str, ) -> Result<Strong<T>, StatusCode> { if binder::is_handling_transaction() { // See comment in the BinderAsyncPool impl. return binder::get_interface::<T>(name); } let name = name.to_string(); let res = tokio::task::spawn_blocking(move || { binder::get_interface::<T>(&name) }).await; let res = tokio::task::spawn_blocking(move || binder::get_interface::<T>(&name)).await; // The `is_panic` branch is not actually reachable in Android as we compile // with `panic = abort`. Loading @@ -58,16 +58,16 @@ pub async fn get_interface<T: FromIBinder + ?Sized + 'static>(name: &str) -> Res /// Retrieve an existing service for a particular interface, or start it if it /// is configured as a dynamic service and isn't yet started. pub async fn wait_for_interface<T: FromIBinder + ?Sized + 'static>(name: &str) -> Result<Strong<T>, StatusCode> { pub async fn wait_for_interface<T: FromIBinder + ?Sized + 'static>( name: &str, ) -> Result<Strong<T>, StatusCode> { if binder::is_handling_transaction() { // See comment in the BinderAsyncPool impl. return binder::wait_for_interface::<T>(name); } let name = name.to_string(); let res = tokio::task::spawn_blocking(move || { binder::wait_for_interface::<T>(&name) }).await; let res = tokio::task::spawn_blocking(move || binder::wait_for_interface::<T>(&name)).await; // The `is_panic` branch is not actually reachable in Android as we compile // with `panic = abort`. Loading
libs/binder/rust/src/binder.rs +17 −16 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ //! Trait definitions for binder objects use crate::error::{status_t, Result, StatusCode}; use crate::parcel::{Parcel, BorrowedParcel}; use crate::parcel::{BorrowedParcel, Parcel}; use crate::proxy::{DeathRecipient, SpIBinder, WpIBinder}; use crate::sys; Loading Loading @@ -133,7 +133,7 @@ impl TryFrom<i32> for Stability { match stability { 0 => Ok(Local), 1 => Ok(Vintf), _ => Err(StatusCode::BAD_VALUE) _ => Err(StatusCode::BAD_VALUE), } } } Loading @@ -158,7 +158,12 @@ pub trait Remotable: Send + Sync { /// Handle and reply to a request to invoke a transaction on this object. /// /// `reply` may be [`None`] if the sender does not expect a reply. fn on_transact(&self, code: TransactionCode, data: &BorrowedParcel<'_>, reply: &mut BorrowedParcel<'_>) -> Result<()>; fn on_transact( &self, code: TransactionCode, data: &BorrowedParcel<'_>, reply: &mut BorrowedParcel<'_>, ) -> Result<()>; /// Handle a request to invoke the dump transaction on this /// object. Loading Loading @@ -454,28 +459,19 @@ impl<I: FromIBinder + ?Sized> Weak<I> { /// Construct a new weak reference from a strong reference fn new(binder: &Strong<I>) -> Self { let weak_binder = binder.as_binder().downgrade(); Weak { weak_binder, interface_type: PhantomData, } Weak { weak_binder, interface_type: PhantomData } } /// Upgrade this weak reference to a strong reference if the binder object /// is still alive pub fn upgrade(&self) -> Result<Strong<I>> { self.weak_binder .promote() .ok_or(StatusCode::DEAD_OBJECT) .and_then(FromIBinder::try_from) self.weak_binder.promote().ok_or(StatusCode::DEAD_OBJECT).and_then(FromIBinder::try_from) } } impl<I: FromIBinder + ?Sized> Clone for Weak<I> { fn clone(&self) -> Self { Self { weak_binder: self.weak_binder.clone(), interface_type: PhantomData, } Self { weak_binder: self.weak_binder.clone(), interface_type: PhantomData } } } Loading Loading @@ -614,7 +610,12 @@ pub trait InterfaceClassMethods { /// contains a `T` pointer in its user data. fd should be a non-owned file /// descriptor, and args must be an array of null-terminated string /// poiinters with length num_args. unsafe extern "C" fn on_dump(binder: *mut sys::AIBinder, fd: i32, args: *mut *const c_char, num_args: u32) -> status_t; unsafe extern "C" fn on_dump( binder: *mut sys::AIBinder, fd: i32, args: *mut *const c_char, num_args: u32, ) -> status_t; } /// Interface for transforming a generic SpIBinder into a specific remote Loading
libs/binder/rust/src/binder_async.rs +4 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,10 @@ pub trait BinderAsyncPool { /// boxed `Future` trait object, and including `after_spawn` in the trait function /// allows the caller to avoid double-boxing if they want to do anything to the value /// returned from the spawned thread. fn spawn<'a, F1, F2, Fut, A, B, E>(spawn_me: F1, after_spawn: F2) -> BoxFuture<'a, Result<B, E>> fn spawn<'a, F1, F2, Fut, A, B, E>( spawn_me: F1, after_spawn: F2, ) -> BoxFuture<'a, Result<B, E>> where F1: FnOnce() -> A, F2: FnOnce(A) -> Fut, Loading
libs/binder/rust/src/lib.rs +1 −1 Original line number Diff line number Diff line Loading @@ -106,8 +106,8 @@ mod state; use binder_ndk_sys as sys; pub use binder::{BinderFeatures, FromIBinder, IBinder, Interface, Strong, Weak}; pub use crate::binder_async::{BinderAsyncPool, BoxFuture}; pub use binder::{BinderFeatures, FromIBinder, IBinder, Interface, Strong, Weak}; pub use error::{ExceptionCode, Status, StatusCode}; pub use native::{ add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Loading