Merge "Remove IRPC error handling" into main

This commit is contained in:
Tri Vo 2023-08-31 22:18:06 +00:00 committed by Gerrit Code Review
commit 8ace735b6e

View file

@ -55,10 +55,6 @@ pub enum Error {
/// Wraps a Binder status code.
#[error("Binder transaction error {0:?}")]
BinderTransaction(StatusCode),
/// Wraps a Remote Provisioning ErrorCode as defined by the IRemotelyProvisionedComponent
/// AIDL interface spec.
#[error("Error::Rp({0:?})")]
Rp(ErrorCode),
}
impl Error {
@ -103,16 +99,6 @@ pub fn map_km_error<T>(r: BinderResult<T>) -> Result<T, Error> {
})
}
/// Helper function to map the binder status we get from calls into a RemotelyProvisionedComponent
/// to a Keystore Error. We don't create an anyhow error here to make
/// it easier to evaluate service specific errors.
pub fn map_rem_prov_error<T>(r: BinderResult<T>) -> Result<T, Error> {
r.map_err(|s| match s.exception_code() {
ExceptionCode::SERVICE_SPECIFIC => Error::Rp(ErrorCode(s.service_specific_error())),
e_code => Error::Binder(e_code, 0),
})
}
/// This function is similar to map_km_error only that we don't expect
/// any KeyMint error codes, we simply preserve the exception code and optional
/// service specific exception.
@ -230,7 +216,6 @@ pub fn get_error_code(e: &anyhow::Error) -> i32 {
match root_cause.downcast_ref::<Error>() {
Some(Error::Rc(rcode)) => rcode.0,
Some(Error::Km(ec)) => ec.0,
Some(Error::Rp(_)) => ResponseCode::SYSTEM_ERROR.0,
// If an Error::Binder reaches this stage we report a system error.
// The exception code and possible service specific error will be
// printed in the error log above.