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/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(())