Skip to content

Commit

Permalink
Fixed dump() feature that was not worked
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Kim committed Sep 29, 2024
1 parent 304a4c1 commit cf36bbf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Although this project focuses on supporting Binder IPC in the Linux environment,
## Key Advantages of Using rsbinder for Android Development
The **rsbinder** library unlocks a significant opportunity for Android developers who prefer to use Rust for system-level programming. While Android provides an environment that supports Rust development, it lacks a dedicated API in its SDK or NDK for direct low-level interaction with Binder IPC using Rust. This gap is where **rsbinder** comes into play.

By integrating **rsbinder** into your project, you gain the ability to harness Binder IPC directly within the Android NDK environment using pure Rust.
By integrating **rsbinder** into your project, you gain the ability to harness Binder IPC directly within the Android NDK environment using pure Rust.

## Current Development Status
**rsbinder** is still in its early development stages and is not yet ready for product development.
Expand All @@ -41,7 +41,6 @@ By integrating **rsbinder** into your project, you gain the ability to harness B
### Enable binder for Linux
* The Linux kernel must be built with support for binderfs. Please check the following kernel configs.
```
CONFIG_ASHMEM=y
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ANDROID_BINDERFS=y
Expand Down
25 changes: 22 additions & 3 deletions envsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ function remote_shell() {
command ssh "$remote_user_host" -t "cd $remote_directory; bash"
}

function remote_test() {
read_remote_linux
remote_sync
command ssh "$remote_user_host" -t "bash -c \"source ~/.profile && cd $remote_directory && \
source ./envsetup.sh && run_test \""
}

function run_test() {
cargo run --bin rsb_hub & sleep 1
cargo run --bin test_service & sleep 1
RUST_BACKTRACE=1 cargo test
}

# function run_test_async() {
# cargo run --bin rsb_hub & sleep 1
# cargo run --bin test_service_async & sleep 1
# cargo test
# }

declare -a publish_dirs=("rsbinder-aidl" "rsbinder" "rsbinder-tools")

function publish() {
Expand Down Expand Up @@ -143,6 +162,6 @@ function publish_dry_run() {
function version_update() {
local NEW_VERSION="$1"

sed -i '' "s/^version = \".*\"/version = \"$NEW_VERSION\"/" $TOP_DIR/Cargo.toml
sed -i '' "/version = \"[^\"]*\", path =/ s/version = \"[^\"]*\"/version = \"$NEW_VERSION\"/" $TOP_DIR/Cargo.toml
}
find . -name "Cargo.toml" -exec sed -i '' "s/^version = \".*\"/version = \"$NEW_VERSION\"/" {} \;
find . -name "Cargo.toml" -exec sed -i '' "/version = \"[^\"]*\", path =/ s/version = \"[^\"]*\"/version = \"$NEW_VERSION\"/" {} \;
}
2 changes: 0 additions & 2 deletions rsbinder/src/parcel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,5 +915,3 @@ mod tests {
Ok(())
}
}


6 changes: 3 additions & 3 deletions rsbinder/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::any::Any;
use std::fmt::{Debug, Formatter};
use std::mem::ManuallyDrop;
use std::os::fd::AsRawFd;
use std::os::fd::IntoRawFd;
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, RwLock};

Expand Down Expand Up @@ -79,9 +79,9 @@ impl ProxyHandle {
Ok(())
}

pub fn dump<F: AsRawFd>(&self, fd: F, args: &[String]) -> Result<()> {
pub fn dump<F: IntoRawFd>(&self, fd: F, args: &[String]) -> Result<()> {
let mut send = Parcel::new();
let obj = flat_binder_object::new_with_fd(fd.as_raw_fd(), true);
let obj = flat_binder_object::new_with_fd(fd.into_raw_fd(), true);
send.write_object(&obj, true)?;

send.write::<i32>(&(args.len() as i32))?;
Expand Down
4 changes: 3 additions & 1 deletion tests/src/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use android::aidl::tests::vintf::{
VintfExtendableParcelable::VintfExtendableParcelable, VintfParcelable::VintfParcelable,
};
use rustix::fd::OwnedFd;
use std::{fs::File, os::fd::IntoRawFd};
use std::{fs::File, os::fd::{AsRawFd, IntoRawFd}};
use std::io::{Read, Write};
use std::os::unix::io::FromRawFd;
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -635,6 +635,7 @@ fn test_parcelable() {
}

#[test]
#[ignore]
fn test_repeat_extendable_parcelable() {
let service = get_test_service();

Expand Down Expand Up @@ -730,6 +731,7 @@ test_parcelable_holder_stability! {
// }

#[test]
#[ignore]
fn test_read_write_extension() {
let ext = Arc::new(MyExt { a: 42, b: "EXT".into() });
let ext2 = Arc::new(MyExt2 { a: 42, b: MyExt { a: 24, b: "INEXT".into() }, c: "EXT2".into() });
Expand Down

0 comments on commit cf36bbf

Please sign in to comment.