Use new binder exception constructors moved from binder_common.
Bug: 234019127
Test: atest compos_key_tests MicrodroidHostTestCases MicrodroidTestApp
Change-Id: I938c9d0ebae90c933c9a7ee8c27e9ecb0cc3e5fa
diff --git a/authfs/fd_server/src/aidl.rs b/authfs/fd_server/src/aidl.rs
index 3a3cdb2..0e8952e 100644
--- a/authfs/fd_server/src/aidl.rs
+++ b/authfs/fd_server/src/aidl.rs
@@ -42,7 +42,6 @@
use authfs_fsverity_metadata::{
get_fsverity_metadata_path, parse_fsverity_metadata, FSVerityMetadata,
};
-use binder_common::{new_binder_exception, new_binder_service_specific_error};
/// Bitflags of forbidden file mode, e.g. setuid, setgid and sticky bit.
const FORBIDDEN_MODES: Mode = Mode::from_bits_truncate(!0o777);
@@ -107,9 +106,12 @@
entry.insert(new_fd_config);
Ok(new_fd)
} else {
- Err(new_binder_exception(
+ Err(Status::new_exception_str(
ExceptionCode::ILLEGAL_STATE,
- format!("The newly created FD {} is already in the pool unexpectedly", new_fd),
+ Some(format!(
+ "The newly created FD {} is already in the pool unexpectedly",
+ new_fd
+ )),
))
}
}
@@ -173,9 +175,9 @@
if let Some(signature) = &metadata.signature {
Ok(signature.clone())
} else {
- Err(new_binder_exception(
- ExceptionCode::SERVICE_SPECIFIC,
- "metadata doesn't contain a signature",
+ Err(Status::new_service_specific_error_str(
+ -1,
+ Some("metadata doesn't contain a signature"),
))
}
} else {
@@ -395,7 +397,7 @@
}
fn new_errno_error(errno: Errno) -> Status {
- new_binder_service_specific_error(errno as i32, errno.desc())
+ Status::new_service_specific_error_str(errno as i32, Some(errno.desc()))
}
fn open_readonly_at(dir_fd: RawFd, path: &Path) -> nix::Result<File> {
diff --git a/authfs/service/Android.bp b/authfs/service/Android.bp
index 6c32c67..943db35 100644
--- a/authfs/service/Android.bp
+++ b/authfs/service/Android.bp
@@ -12,7 +12,6 @@
"authfs_aidl_interface-rust",
"libandroid_logger",
"libanyhow",
- "libbinder_common",
"libbinder_rs",
"liblibc",
"liblog_rust",
diff --git a/authfs/service/src/authfs.rs b/authfs/service/src/authfs.rs
index c941360..547d15d 100644
--- a/authfs/service/src/authfs.rs
+++ b/authfs/service/src/authfs.rs
@@ -32,9 +32,8 @@
};
use authfs_aidl_interface::aidl::com::android::virt::fs::IAuthFs::{BnAuthFs, IAuthFs};
use authfs_aidl_interface::binder::{
- self, BinderFeatures, ExceptionCode, Interface, ParcelFileDescriptor, Strong,
+ self, BinderFeatures, Interface, ParcelFileDescriptor, Status, Strong,
};
-use binder_common::new_binder_exception;
const AUTHFS_BIN: &str = "/system/bin/authfs";
const AUTHFS_SETUP_POLL_INTERVAL_MS: Duration = Duration::from_millis(50);
@@ -60,9 +59,9 @@
let mut path = PathBuf::from(&self.mountpoint);
path.push(remote_fd_name.to_string());
let file = OpenOptions::new().read(true).write(writable).open(&path).map_err(|e| {
- new_binder_exception(
- ExceptionCode::SERVICE_SPECIFIC,
- format!("failed to open {:?} on authfs: {}", &path, e),
+ Status::new_service_specific_error_str(
+ -1,
+ Some(format!("failed to open {:?} on authfs: {}", &path, e)),
)
})?;
Ok(ParcelFileDescriptor::new(file))
@@ -72,7 +71,7 @@
if let Some(s) = self.mountpoint.to_str() {
Ok(s.to_string())
} else {
- Err(new_binder_exception(ExceptionCode::SERVICE_SPECIFIC, "Bad string encoding"))
+ Err(Status::new_service_specific_error_str(-1, Some("Bad string encoding")))
}
}
}
diff --git a/authfs/service/src/main.rs b/authfs/service/src/main.rs
index 890e108..fe8af61 100644
--- a/authfs/service/src/main.rs
+++ b/authfs/service/src/main.rs
@@ -34,9 +34,8 @@
BnAuthFsService, IAuthFsService,
};
use authfs_aidl_interface::binder::{
- self, add_service, BinderFeatures, ExceptionCode, Interface, ProcessState, Strong,
+ self, add_service, BinderFeatures, ExceptionCode, Interface, ProcessState, Status, Strong,
};
-use binder_common::new_binder_exception;
const SERVICE_NAME: &str = "authfs_service";
const SERVICE_ROOT: &str = "/data/misc/authfs";
@@ -57,16 +56,16 @@
// The directory is supposed to be deleted when `AuthFs` is dropped.
create_dir(&mountpoint).map_err(|e| {
- new_binder_exception(
- ExceptionCode::SERVICE_SPECIFIC,
- format!("Cannot create mount directory {:?}: {:?}", &mountpoint, e),
+ Status::new_service_specific_error_str(
+ -1,
+ Some(format!("Cannot create mount directory {:?}: {:?}", &mountpoint, e)),
)
})?;
authfs::AuthFs::mount_and_wait(mountpoint, config, self.debuggable).map_err(|e| {
- new_binder_exception(
- ExceptionCode::SERVICE_SPECIFIC,
- format!("mount_and_wait failed: {:?}", e),
+ Status::new_service_specific_error_str(
+ -1,
+ Some(format!("mount_and_wait failed: {:?}", e)),
)
})
}
@@ -80,9 +79,9 @@
fn validate(&self, config: &AuthFsConfig) -> binder::Result<()> {
if config.port < 0 {
- return Err(new_binder_exception(
+ return Err(Status::new_exception_str(
ExceptionCode::ILLEGAL_ARGUMENT,
- format!("Invalid port: {}", config.port),
+ Some(format!("Invalid port: {}", config.port)),
));
}
Ok(())