diff --git a/base/src/rust/ashmem.rs b/base/src/rust/ashmem.rs index 055885cdfa13db1d3ab6b7cfe4626eb9aad3fbe9..36ff005213dad1254b912b3f20ad78c169088de2 100644 --- a/base/src/rust/ashmem.rs +++ b/base/src/rust/ashmem.rs @@ -36,13 +36,6 @@ pub mod ffi { include!("commonlibrary/c_utils/base/include/ashmem.h"); // global function - /** - * Create an ashmem and return its FD. - * # Safety - * Requires C-style string as parameter to specify the name of Ashmem. - */ - pub unsafe fn AshmemCreate(name: *const c_char, size: usize) -> i32; - /** * Create an C++ Ashmem object managed by std::shared_ptr. * # Safety @@ -217,16 +210,4 @@ pub unsafe fn create_ashmem_instance(name: &str, size: i32) -> Option { } else { Some(Ashmem::new(c_ashmem_ptr)) } -} - -/** - * Create raw ashmem and returns its FD. - * # Safety - * Transmits c-style string of `name`. - */ -#[allow(dead_code)] -pub unsafe fn ashmem_create(name: &str, size: i32) -> i32 { - let c_name = CString::new(name).expect("CString::new Failed!"); - let name_ptr = c_name.as_ptr(); - ffi::AshmemCreate(name_ptr, size.try_into().expect("Invalid size.")) } \ No newline at end of file diff --git a/base/test/unittest/rust/rust_utils_ashmem_test.rs b/base/test/unittest/rust/rust_utils_ashmem_test.rs index b7816522f292dc9b1fcabdda32e1ffdb021facf2..0187a503e5f3e05eabbb47ea89fca876397b7327 100644 --- a/base/test/unittest/rust/rust_utils_ashmem_test.rs +++ b/base/test/unittest/rust/rust_utils_ashmem_test.rs @@ -290,7 +290,6 @@ fn test_ashmem_ffi_invalid_006() ashmem.CloseAshmem(); } - #[test] fn test_ashmem_write_read_001() { @@ -299,6 +298,8 @@ fn test_ashmem_write_read_001() let ashmem = ashmem.unwrap(); assert_eq!(ashmem.get_ashmem_size(), MEMORY_SIZE); + assert_eq!(ashmem.get_protection(), ashmem::PROT_READ | ashmem::PROT_WRITE | ashmem::PROT_EXEC); // default protection mask. + assert_ne!(ashmem.get_ashmem_fd(), -1); assert!(ashmem.map_ashmem(ashmem::PROT_READ | ashmem::PROT_WRITE));