diff --git a/keystore2/src/android_hardware_keymint.rs b/keystore2/src/android_hardware_keymint.rs
new file mode 100644
index 0000000..dcdf87f
--- /dev/null
+++ b/keystore2/src/android_hardware_keymint.rs
@@ -0,0 +1,1639 @@
+#![allow(non_snake_case)]
+#![allow(missing_docs)]
+#![allow(clippy::identity_op)]
+#![allow(clippy::excessive_precision)]
+#![allow(clippy::too_many_arguments)]
+pub use binder::public_api as binder;
+pub mod aidl {
+  pub mod android {
+    pub mod hardware {
+      pub mod keymint {
+        pub mod Algorithm {
+          #![allow(non_upper_case_globals)]
+          pub type Algorithm = i32;
+          pub const RSA: Algorithm = 1;
+          pub const EC: Algorithm = 3;
+          pub const AES: Algorithm = 32;
+          pub const TRIPLE_DES: Algorithm = 33;
+          pub const HMAC: Algorithm = 128;
+          pub(crate) mod mangled { pub use super::Algorithm as _7_android_8_hardware_7_keymint_9_Algorithm; }
+        }
+        pub mod BeginResult {
+          pub struct BeginResult {
+            pub challenge: i64, 
+            pub params: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, 
+            pub operation: Option<Box<dyn crate::mangled::_7_android_8_hardware_7_keymint_17_IKeyMintOperation>>, 
+          }
+          pub(crate) mod mangled { pub use super::BeginResult as _7_android_8_hardware_7_keymint_11_BeginResult; }
+          impl Default for BeginResult {
+            fn default() -> Self {
+              Self {
+                challenge: 0,
+                params: Default::default(),
+                operation: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for BeginResult {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for BeginResult {}
+          impl binder::parcel::SerializeOption for BeginResult {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.challenge)?;
+              parcel.write(&this.params)?;
+              let __field_ref = this.operation.as_ref().ok_or(binder::StatusCode::UNEXPECTED_NULL)?;
+              parcel.write(__field_ref)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for BeginResult {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for BeginResult {}
+          impl binder::parcel::DeserializeOption for BeginResult {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.challenge = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.params = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.operation = Some(parcel.read()?);
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod BlockMode {
+          #![allow(non_upper_case_globals)]
+          pub type BlockMode = i32;
+          pub const ECB: BlockMode = 1;
+          pub const CBC: BlockMode = 2;
+          pub const CTR: BlockMode = 3;
+          pub const GCM: BlockMode = 32;
+          pub(crate) mod mangled { pub use super::BlockMode as _7_android_8_hardware_7_keymint_9_BlockMode; }
+        }
+        pub mod Certificate {
+          pub struct Certificate {
+            pub encodedCertificate: Vec<u8>, 
+          }
+          pub(crate) mod mangled { pub use super::Certificate as _7_android_8_hardware_7_keymint_11_Certificate; }
+          impl Default for Certificate {
+            fn default() -> Self {
+              Self {
+                encodedCertificate: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for Certificate {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for Certificate {}
+          impl binder::parcel::SerializeOption for Certificate {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.encodedCertificate)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for Certificate {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for Certificate {}
+          impl binder::parcel::DeserializeOption for Certificate {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.encodedCertificate = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod Constants {
+          #![allow(non_upper_case_globals)]
+          pub type Constants = i32;
+          pub const AUTH_TOKEN_MAC_LENGTH: Constants = 32;
+          pub(crate) mod mangled { pub use super::Constants as _7_android_8_hardware_7_keymint_9_Constants; }
+        }
+        pub mod Digest {
+          #![allow(non_upper_case_globals)]
+          pub type Digest = i32;
+          pub const NONE: Digest = 0;
+          pub const MD5: Digest = 1;
+          pub const SHA1: Digest = 2;
+          pub const SHA_2_224: Digest = 3;
+          pub const SHA_2_256: Digest = 4;
+          pub const SHA_2_384: Digest = 5;
+          pub const SHA_2_512: Digest = 6;
+          pub(crate) mod mangled { pub use super::Digest as _7_android_8_hardware_7_keymint_6_Digest; }
+        }
+        pub mod EcCurve {
+          #![allow(non_upper_case_globals)]
+          pub type EcCurve = i32;
+          pub const P_224: EcCurve = 0;
+          pub const P_256: EcCurve = 1;
+          pub const P_384: EcCurve = 2;
+          pub const P_521: EcCurve = 3;
+          pub(crate) mod mangled { pub use super::EcCurve as _7_android_8_hardware_7_keymint_7_EcCurve; }
+        }
+        pub mod ErrorCode {
+          #![allow(non_upper_case_globals)]
+          pub type ErrorCode = i32;
+          pub const OK: ErrorCode = 0;
+          pub const ROOT_OF_TRUST_ALREADY_SET: ErrorCode = -1;
+          pub const UNSUPPORTED_PURPOSE: ErrorCode = -2;
+          pub const INCOMPATIBLE_PURPOSE: ErrorCode = -3;
+          pub const UNSUPPORTED_ALGORITHM: ErrorCode = -4;
+          pub const INCOMPATIBLE_ALGORITHM: ErrorCode = -5;
+          pub const UNSUPPORTED_KEY_SIZE: ErrorCode = -6;
+          pub const UNSUPPORTED_BLOCK_MODE: ErrorCode = -7;
+          pub const INCOMPATIBLE_BLOCK_MODE: ErrorCode = -8;
+          pub const UNSUPPORTED_MAC_LENGTH: ErrorCode = -9;
+          pub const UNSUPPORTED_PADDING_MODE: ErrorCode = -10;
+          pub const INCOMPATIBLE_PADDING_MODE: ErrorCode = -11;
+          pub const UNSUPPORTED_DIGEST: ErrorCode = -12;
+          pub const INCOMPATIBLE_DIGEST: ErrorCode = -13;
+          pub const INVALID_EXPIRATION_TIME: ErrorCode = -14;
+          pub const INVALID_USER_ID: ErrorCode = -15;
+          pub const INVALID_AUTHORIZATION_TIMEOUT: ErrorCode = -16;
+          pub const UNSUPPORTED_KEY_FORMAT: ErrorCode = -17;
+          pub const INCOMPATIBLE_KEY_FORMAT: ErrorCode = -18;
+          pub const UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM: ErrorCode = -19;
+          pub const UNSUPPORTED_KEY_VERIFICATION_ALGORITHM: ErrorCode = -20;
+          pub const INVALID_INPUT_LENGTH: ErrorCode = -21;
+          pub const KEY_EXPORT_OPTIONS_INVALID: ErrorCode = -22;
+          pub const DELEGATION_NOT_ALLOWED: ErrorCode = -23;
+          pub const KEY_NOT_YET_VALID: ErrorCode = -24;
+          pub const KEY_EXPIRED: ErrorCode = -25;
+          pub const KEY_USER_NOT_AUTHENTICATED: ErrorCode = -26;
+          pub const OUTPUT_PARAMETER_NULL: ErrorCode = -27;
+          pub const INVALID_OPERATION_HANDLE: ErrorCode = -28;
+          pub const INSUFFICIENT_BUFFER_SPACE: ErrorCode = -29;
+          pub const VERIFICATION_FAILED: ErrorCode = -30;
+          pub const TOO_MANY_OPERATIONS: ErrorCode = -31;
+          pub const UNEXPECTED_NULL_POINTER: ErrorCode = -32;
+          pub const INVALID_KEY_BLOB: ErrorCode = -33;
+          pub const IMPORTED_KEY_NOT_ENCRYPTED: ErrorCode = -34;
+          pub const IMPORTED_KEY_DECRYPTION_FAILED: ErrorCode = -35;
+          pub const IMPORTED_KEY_NOT_SIGNED: ErrorCode = -36;
+          pub const IMPORTED_KEY_VERIFICATION_FAILED: ErrorCode = -37;
+          pub const INVALID_ARGUMENT: ErrorCode = -38;
+          pub const UNSUPPORTED_TAG: ErrorCode = -39;
+          pub const INVALID_TAG: ErrorCode = -40;
+          pub const MEMORY_ALLOCATION_FAILED: ErrorCode = -41;
+          pub const IMPORT_PARAMETER_MISMATCH: ErrorCode = -44;
+          pub const SECURE_HW_ACCESS_DENIED: ErrorCode = -45;
+          pub const OPERATION_CANCELLED: ErrorCode = -46;
+          pub const CONCURRENT_ACCESS_CONFLICT: ErrorCode = -47;
+          pub const SECURE_HW_BUSY: ErrorCode = -48;
+          pub const SECURE_HW_COMMUNICATION_FAILED: ErrorCode = -49;
+          pub const UNSUPPORTED_EC_FIELD: ErrorCode = -50;
+          pub const MISSING_NONCE: ErrorCode = -51;
+          pub const INVALID_NONCE: ErrorCode = -52;
+          pub const MISSING_MAC_LENGTH: ErrorCode = -53;
+          pub const KEY_RATE_LIMIT_EXCEEDED: ErrorCode = -54;
+          pub const CALLER_NONCE_PROHIBITED: ErrorCode = -55;
+          pub const KEY_MAX_OPS_EXCEEDED: ErrorCode = -56;
+          pub const INVALID_MAC_LENGTH: ErrorCode = -57;
+          pub const MISSING_MIN_MAC_LENGTH: ErrorCode = -58;
+          pub const UNSUPPORTED_MIN_MAC_LENGTH: ErrorCode = -59;
+          pub const UNSUPPORTED_KDF: ErrorCode = -60;
+          pub const UNSUPPORTED_EC_CURVE: ErrorCode = -61;
+          pub const KEY_REQUIRES_UPGRADE: ErrorCode = -62;
+          pub const ATTESTATION_CHALLENGE_MISSING: ErrorCode = -63;
+          pub const KEYMASTER_NOT_CONFIGURED: ErrorCode = -64;
+          pub const ATTESTATION_APPLICATION_ID_MISSING: ErrorCode = -65;
+          pub const CANNOT_ATTEST_IDS: ErrorCode = -66;
+          pub const ROLLBACK_RESISTANCE_UNAVAILABLE: ErrorCode = -67;
+          pub const HARDWARE_TYPE_UNAVAILABLE: ErrorCode = -68;
+          pub const PROOF_OF_PRESENCE_REQUIRED: ErrorCode = -69;
+          pub const CONCURRENT_PROOF_OF_PRESENCE_REQUESTED: ErrorCode = -70;
+          pub const NO_USER_CONFIRMATION: ErrorCode = -71;
+          pub const DEVICE_LOCKED: ErrorCode = -72;
+          pub const EARLY_BOOT_ENDED: ErrorCode = -73;
+          pub const ATTESTATION_KEYS_NOT_PROVISIONED: ErrorCode = -74;
+          pub const ATTESTATION_IDS_NOT_PROVISIONED: ErrorCode = -75;
+          pub const INVALID_OPERATION: ErrorCode = -76;
+          pub const STORAGE_KEY_UNSUPPORTED: ErrorCode = -77;
+          pub const UNIMPLEMENTED: ErrorCode = -100;
+          pub const VERSION_MISMATCH: ErrorCode = -101;
+          pub const UNKNOWN_ERROR: ErrorCode = -1000;
+          pub(crate) mod mangled { pub use super::ErrorCode as _7_android_8_hardware_7_keymint_9_ErrorCode; }
+        }
+        pub mod HardwareAuthToken {
+          pub struct HardwareAuthToken {
+            pub challenge: i64, 
+            pub userId: i64, 
+            pub authenticatorId: i64, 
+            pub authenticatorType: crate::mangled::_7_android_8_hardware_7_keymint_25_HardwareAuthenticatorType, 
+            pub timestamp: crate::mangled::_7_android_8_hardware_7_keymint_9_Timestamp, 
+            pub mac: Vec<u8>, 
+          }
+          pub(crate) mod mangled { pub use super::HardwareAuthToken as _7_android_8_hardware_7_keymint_17_HardwareAuthToken; }
+          impl Default for HardwareAuthToken {
+            fn default() -> Self {
+              Self {
+                challenge: 0,
+                userId: 0,
+                authenticatorId: 0,
+                authenticatorType: Default::default(),
+                timestamp: Default::default(),
+                mac: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for HardwareAuthToken {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for HardwareAuthToken {}
+          impl binder::parcel::SerializeOption for HardwareAuthToken {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.challenge)?;
+              parcel.write(&this.userId)?;
+              parcel.write(&this.authenticatorId)?;
+              parcel.write(&this.authenticatorType)?;
+              parcel.write(&this.timestamp)?;
+              parcel.write(&this.mac)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for HardwareAuthToken {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for HardwareAuthToken {}
+          impl binder::parcel::DeserializeOption for HardwareAuthToken {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.challenge = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.userId = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.authenticatorId = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.authenticatorType = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.timestamp = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.mac = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod HardwareAuthenticatorType {
+          #![allow(non_upper_case_globals)]
+          pub type HardwareAuthenticatorType = i32;
+          pub const NONE: HardwareAuthenticatorType = 0;
+          pub const PASSWORD: HardwareAuthenticatorType = 1;
+          pub const FINGERPRINT: HardwareAuthenticatorType = 2;
+          pub const ANY: HardwareAuthenticatorType = -1;
+          pub(crate) mod mangled { pub use super::HardwareAuthenticatorType as _7_android_8_hardware_7_keymint_25_HardwareAuthenticatorType; }
+        }
+        pub mod HmacSharingParameters {
+          pub struct HmacSharingParameters {
+            pub seed: Vec<u8>, 
+            pub nonce: Vec<u8>, 
+          }
+          pub(crate) mod mangled { pub use super::HmacSharingParameters as _7_android_8_hardware_7_keymint_21_HmacSharingParameters; }
+          impl Default for HmacSharingParameters {
+            fn default() -> Self {
+              Self {
+                seed: Default::default(),
+                nonce: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for HmacSharingParameters {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for HmacSharingParameters {}
+          impl binder::parcel::SerializeOption for HmacSharingParameters {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.seed)?;
+              parcel.write(&this.nonce)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for HmacSharingParameters {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for HmacSharingParameters {}
+          impl binder::parcel::DeserializeOption for HmacSharingParameters {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.seed = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.nonce = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod IKeyMintDevice {
+          #![allow(non_upper_case_globals)]
+          #![allow(non_snake_case)]
+          #[allow(unused_imports)] use binder::IBinder;
+          use binder::declare_binder_interface;
+          declare_binder_interface! {
+            IKeyMintDevice["android.hardware.keymint.IKeyMintDevice"] {
+              native: BnKeyMintDevice(on_transact),
+              proxy: BpKeyMintDevice {
+              },
+            }
+          }
+          pub trait IKeyMintDevice: binder::Interface {
+            fn get_descriptor() -> &'static str where Self: Sized { "android.hardware.keymint.IKeyMintDevice" }
+            fn getHardwareInfo(&self) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_19_KeyMintHardwareInfo> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn verifyAuthorization(&self, _arg_challenge: i64, _arg_parametersToVerify: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_token: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn addRngEntropy(&self, _arg_data: &[u8]) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn generateKey(&self, _arg_keyParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_generatedKeyBlob: &mut Vec<u8>, _arg_generatedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics, _arg_outCertChain: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate>) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn importKey(&self, _arg_inKeyParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inKeyFormat: crate::mangled::_7_android_8_hardware_7_keymint_9_KeyFormat, _arg_inKeyData: &[u8], _arg_outImportedKeyBlob: &mut Vec<u8>, _arg_outImportedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics, _arg_outCertChain: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate>) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn importWrappedKey(&self, _arg_inWrappedKeyData: &[u8], _arg_inWrappingKeyBlob: &[u8], _arg_inMaskingKey: &[u8], _arg_inUnwrappingParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inPasswordSid: i64, _arg_inBiometricSid: i64, _arg_outImportedKeyBlob: &mut Vec<u8>, _arg_outImportedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn upgradeKey(&self, _arg_inKeyBlobToUpgrade: &[u8], _arg_inUpgradeParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter]) -> binder::public_api::Result<Vec<u8>> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn deleteKey(&self, _arg_inKeyBlob: &[u8]) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn deleteAllKeys(&self) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn destroyAttestationIds(&self) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn begin(&self, _arg_inPurpose: crate::mangled::_7_android_8_hardware_7_keymint_10_KeyPurpose, _arg_inKeyBlob: &[u8], _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inAuthToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_11_BeginResult> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn getDefaultImpl() -> DefaultImpl where Self: Sized {
+              DEFAULT_IMPL.lock().unwrap().clone()
+            }
+            fn setDefaultImpl(d: DefaultImpl) -> DefaultImpl where Self: Sized {
+              std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+            }
+          }
+          pub const TRANSACTION_getHardwareInfo: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+          pub const TRANSACTION_verifyAuthorization: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
+          pub const TRANSACTION_addRngEntropy: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
+          pub const TRANSACTION_generateKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
+          pub const TRANSACTION_importKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 4;
+          pub const TRANSACTION_importWrappedKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 5;
+          pub const TRANSACTION_upgradeKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 6;
+          pub const TRANSACTION_deleteKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 7;
+          pub const TRANSACTION_deleteAllKeys: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 8;
+          pub const TRANSACTION_destroyAttestationIds: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 9;
+          pub const TRANSACTION_begin: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 10;
+          pub type DefaultImpl = Option<std::sync::Arc<dyn IKeyMintDevice + Send + Sync>>;
+          use lazy_static::lazy_static;
+          lazy_static! {
+            static ref DEFAULT_IMPL: std::sync::Mutex<DefaultImpl> = std::sync::Mutex::new(None);
+          }
+          pub(crate) mod mangled { pub use super::IKeyMintDevice as _7_android_8_hardware_7_keymint_14_IKeyMintDevice; }
+          impl IKeyMintDevice for BpKeyMintDevice {
+            fn getHardwareInfo(&self) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_19_KeyMintHardwareInfo> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_getHardwareInfo, 0, |_aidl_data| {
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.getHardwareInfo();
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_hardware_7_keymint_19_KeyMintHardwareInfo = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn verifyAuthorization(&self, _arg_challenge: i64, _arg_parametersToVerify: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_token: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_verifyAuthorization, 0, |_aidl_data| {
+                _aidl_data.write(&_arg_challenge)?;
+                _aidl_data.write(_arg_parametersToVerify)?;
+                _aidl_data.write(_arg_token)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.verifyAuthorization(_arg_challenge, _arg_parametersToVerify, _arg_token);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn addRngEntropy(&self, _arg_data: &[u8]) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_addRngEntropy, 0, |_aidl_data| {
+                _aidl_data.write(_arg_data)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.addRngEntropy(_arg_data);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              Ok(())
+            }
+            fn generateKey(&self, _arg_keyParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_generatedKeyBlob: &mut Vec<u8>, _arg_generatedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics, _arg_outCertChain: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate>) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_generateKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_keyParams)?;
+                _aidl_data.write_slice_size(Some(_arg_generatedKeyBlob))?;
+                _aidl_data.write_slice_size(Some(_arg_outCertChain))?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.generateKey(_arg_keyParams, _arg_generatedKeyBlob, _arg_generatedKeyCharacteristics, _arg_outCertChain);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              *_arg_generatedKeyBlob = _aidl_reply.read()?;
+              *_arg_generatedKeyCharacteristics = _aidl_reply.read()?;
+              *_arg_outCertChain = _aidl_reply.read()?;
+              Ok(())
+            }
+            fn importKey(&self, _arg_inKeyParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inKeyFormat: crate::mangled::_7_android_8_hardware_7_keymint_9_KeyFormat, _arg_inKeyData: &[u8], _arg_outImportedKeyBlob: &mut Vec<u8>, _arg_outImportedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics, _arg_outCertChain: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate>) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_importKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_inKeyParams)?;
+                _aidl_data.write(&_arg_inKeyFormat)?;
+                _aidl_data.write(_arg_inKeyData)?;
+                _aidl_data.write_slice_size(Some(_arg_outImportedKeyBlob))?;
+                _aidl_data.write_slice_size(Some(_arg_outCertChain))?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.importKey(_arg_inKeyParams, _arg_inKeyFormat, _arg_inKeyData, _arg_outImportedKeyBlob, _arg_outImportedKeyCharacteristics, _arg_outCertChain);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              *_arg_outImportedKeyBlob = _aidl_reply.read()?;
+              *_arg_outImportedKeyCharacteristics = _aidl_reply.read()?;
+              *_arg_outCertChain = _aidl_reply.read()?;
+              Ok(())
+            }
+            fn importWrappedKey(&self, _arg_inWrappedKeyData: &[u8], _arg_inWrappingKeyBlob: &[u8], _arg_inMaskingKey: &[u8], _arg_inUnwrappingParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inPasswordSid: i64, _arg_inBiometricSid: i64, _arg_outImportedKeyBlob: &mut Vec<u8>, _arg_outImportedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_importWrappedKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_inWrappedKeyData)?;
+                _aidl_data.write(_arg_inWrappingKeyBlob)?;
+                _aidl_data.write(_arg_inMaskingKey)?;
+                _aidl_data.write(_arg_inUnwrappingParams)?;
+                _aidl_data.write(&_arg_inPasswordSid)?;
+                _aidl_data.write(&_arg_inBiometricSid)?;
+                _aidl_data.write_slice_size(Some(_arg_outImportedKeyBlob))?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.importWrappedKey(_arg_inWrappedKeyData, _arg_inWrappingKeyBlob, _arg_inMaskingKey, _arg_inUnwrappingParams, _arg_inPasswordSid, _arg_inBiometricSid, _arg_outImportedKeyBlob, _arg_outImportedKeyCharacteristics);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              *_arg_outImportedKeyBlob = _aidl_reply.read()?;
+              *_arg_outImportedKeyCharacteristics = _aidl_reply.read()?;
+              Ok(())
+            }
+            fn upgradeKey(&self, _arg_inKeyBlobToUpgrade: &[u8], _arg_inUpgradeParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter]) -> binder::public_api::Result<Vec<u8>> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_upgradeKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_inKeyBlobToUpgrade)?;
+                _aidl_data.write(_arg_inUpgradeParams)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.upgradeKey(_arg_inKeyBlobToUpgrade, _arg_inUpgradeParams);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: Vec<u8> = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn deleteKey(&self, _arg_inKeyBlob: &[u8]) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_deleteKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_inKeyBlob)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.deleteKey(_arg_inKeyBlob);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              Ok(())
+            }
+            fn deleteAllKeys(&self) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_deleteAllKeys, 0, |_aidl_data| {
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.deleteAllKeys();
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              Ok(())
+            }
+            fn destroyAttestationIds(&self) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_destroyAttestationIds, 0, |_aidl_data| {
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.destroyAttestationIds();
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              Ok(())
+            }
+            fn begin(&self, _arg_inPurpose: crate::mangled::_7_android_8_hardware_7_keymint_10_KeyPurpose, _arg_inKeyBlob: &[u8], _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inAuthToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_11_BeginResult> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_begin, 0, |_aidl_data| {
+                _aidl_data.write(&_arg_inPurpose)?;
+                _aidl_data.write(_arg_inKeyBlob)?;
+                _aidl_data.write(_arg_inParams)?;
+                _aidl_data.write(_arg_inAuthToken)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintDevice>::getDefaultImpl() {
+                  return _aidl_default_impl.begin(_arg_inPurpose, _arg_inKeyBlob, _arg_inParams, _arg_inAuthToken);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_hardware_7_keymint_11_BeginResult = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+          }
+          impl IKeyMintDevice for binder::Binder<BnKeyMintDevice> {
+            fn getHardwareInfo(&self) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_19_KeyMintHardwareInfo> { self.0.getHardwareInfo() }
+            fn verifyAuthorization(&self, _arg_challenge: i64, _arg_parametersToVerify: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_token: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken> { self.0.verifyAuthorization(_arg_challenge, _arg_parametersToVerify, _arg_token) }
+            fn addRngEntropy(&self, _arg_data: &[u8]) -> binder::public_api::Result<()> { self.0.addRngEntropy(_arg_data) }
+            fn generateKey(&self, _arg_keyParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_generatedKeyBlob: &mut Vec<u8>, _arg_generatedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics, _arg_outCertChain: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate>) -> binder::public_api::Result<()> { self.0.generateKey(_arg_keyParams, _arg_generatedKeyBlob, _arg_generatedKeyCharacteristics, _arg_outCertChain) }
+            fn importKey(&self, _arg_inKeyParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inKeyFormat: crate::mangled::_7_android_8_hardware_7_keymint_9_KeyFormat, _arg_inKeyData: &[u8], _arg_outImportedKeyBlob: &mut Vec<u8>, _arg_outImportedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics, _arg_outCertChain: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate>) -> binder::public_api::Result<()> { self.0.importKey(_arg_inKeyParams, _arg_inKeyFormat, _arg_inKeyData, _arg_outImportedKeyBlob, _arg_outImportedKeyCharacteristics, _arg_outCertChain) }
+            fn importWrappedKey(&self, _arg_inWrappedKeyData: &[u8], _arg_inWrappingKeyBlob: &[u8], _arg_inMaskingKey: &[u8], _arg_inUnwrappingParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inPasswordSid: i64, _arg_inBiometricSid: i64, _arg_outImportedKeyBlob: &mut Vec<u8>, _arg_outImportedKeyCharacteristics: &mut crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics) -> binder::public_api::Result<()> { self.0.importWrappedKey(_arg_inWrappedKeyData, _arg_inWrappingKeyBlob, _arg_inMaskingKey, _arg_inUnwrappingParams, _arg_inPasswordSid, _arg_inBiometricSid, _arg_outImportedKeyBlob, _arg_outImportedKeyCharacteristics) }
+            fn upgradeKey(&self, _arg_inKeyBlobToUpgrade: &[u8], _arg_inUpgradeParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter]) -> binder::public_api::Result<Vec<u8>> { self.0.upgradeKey(_arg_inKeyBlobToUpgrade, _arg_inUpgradeParams) }
+            fn deleteKey(&self, _arg_inKeyBlob: &[u8]) -> binder::public_api::Result<()> { self.0.deleteKey(_arg_inKeyBlob) }
+            fn deleteAllKeys(&self) -> binder::public_api::Result<()> { self.0.deleteAllKeys() }
+            fn destroyAttestationIds(&self) -> binder::public_api::Result<()> { self.0.destroyAttestationIds() }
+            fn begin(&self, _arg_inPurpose: crate::mangled::_7_android_8_hardware_7_keymint_10_KeyPurpose, _arg_inKeyBlob: &[u8], _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_inAuthToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken) -> binder::public_api::Result<crate::mangled::_7_android_8_hardware_7_keymint_11_BeginResult> { self.0.begin(_arg_inPurpose, _arg_inKeyBlob, _arg_inParams, _arg_inAuthToken) }
+          }
+          fn on_transact(_aidl_service: &dyn IKeyMintDevice, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+            match _aidl_code {
+              TRANSACTION_getHardwareInfo => {
+                let _aidl_return = _aidl_service.getHardwareInfo();
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_verifyAuthorization => {
+                let _arg_challenge: i64 = _aidl_data.read()?;
+                let _arg_parametersToVerify: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_token: crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.verifyAuthorization(_arg_challenge, &_arg_parametersToVerify, &_arg_token);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_addRngEntropy => {
+                let _arg_data: Vec<u8> = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.addRngEntropy(&_arg_data);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_generateKey => {
+                let _arg_keyParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let mut _arg_generatedKeyBlob: Vec<u8> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_generatedKeyBlob)?;
+                let mut _arg_generatedKeyCharacteristics: crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics = Default::default();
+                let mut _arg_outCertChain: Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_outCertChain)?;
+                let _aidl_return = _aidl_service.generateKey(&_arg_keyParams, &mut _arg_generatedKeyBlob, &mut _arg_generatedKeyCharacteristics, &mut _arg_outCertChain);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(&_arg_generatedKeyBlob)?;
+                    _aidl_reply.write(&_arg_generatedKeyCharacteristics)?;
+                    _aidl_reply.write(&_arg_outCertChain)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_importKey => {
+                let _arg_inKeyParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_inKeyFormat: crate::mangled::_7_android_8_hardware_7_keymint_9_KeyFormat = _aidl_data.read()?;
+                let _arg_inKeyData: Vec<u8> = _aidl_data.read()?;
+                let mut _arg_outImportedKeyBlob: Vec<u8> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_outImportedKeyBlob)?;
+                let mut _arg_outImportedKeyCharacteristics: crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics = Default::default();
+                let mut _arg_outCertChain: Vec<crate::mangled::_7_android_8_hardware_7_keymint_11_Certificate> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_outCertChain)?;
+                let _aidl_return = _aidl_service.importKey(&_arg_inKeyParams, _arg_inKeyFormat, &_arg_inKeyData, &mut _arg_outImportedKeyBlob, &mut _arg_outImportedKeyCharacteristics, &mut _arg_outCertChain);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(&_arg_outImportedKeyBlob)?;
+                    _aidl_reply.write(&_arg_outImportedKeyCharacteristics)?;
+                    _aidl_reply.write(&_arg_outCertChain)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_importWrappedKey => {
+                let _arg_inWrappedKeyData: Vec<u8> = _aidl_data.read()?;
+                let _arg_inWrappingKeyBlob: Vec<u8> = _aidl_data.read()?;
+                let _arg_inMaskingKey: Vec<u8> = _aidl_data.read()?;
+                let _arg_inUnwrappingParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_inPasswordSid: i64 = _aidl_data.read()?;
+                let _arg_inBiometricSid: i64 = _aidl_data.read()?;
+                let mut _arg_outImportedKeyBlob: Vec<u8> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_outImportedKeyBlob)?;
+                let mut _arg_outImportedKeyCharacteristics: crate::mangled::_7_android_8_hardware_7_keymint_18_KeyCharacteristics = Default::default();
+                let _aidl_return = _aidl_service.importWrappedKey(&_arg_inWrappedKeyData, &_arg_inWrappingKeyBlob, &_arg_inMaskingKey, &_arg_inUnwrappingParams, _arg_inPasswordSid, _arg_inBiometricSid, &mut _arg_outImportedKeyBlob, &mut _arg_outImportedKeyCharacteristics);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(&_arg_outImportedKeyBlob)?;
+                    _aidl_reply.write(&_arg_outImportedKeyCharacteristics)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_upgradeKey => {
+                let _arg_inKeyBlobToUpgrade: Vec<u8> = _aidl_data.read()?;
+                let _arg_inUpgradeParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.upgradeKey(&_arg_inKeyBlobToUpgrade, &_arg_inUpgradeParams);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_deleteKey => {
+                let _arg_inKeyBlob: Vec<u8> = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.deleteKey(&_arg_inKeyBlob);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_deleteAllKeys => {
+                let _aidl_return = _aidl_service.deleteAllKeys();
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_destroyAttestationIds => {
+                let _aidl_return = _aidl_service.destroyAttestationIds();
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_begin => {
+                let _arg_inPurpose: crate::mangled::_7_android_8_hardware_7_keymint_10_KeyPurpose = _aidl_data.read()?;
+                let _arg_inKeyBlob: Vec<u8> = _aidl_data.read()?;
+                let _arg_inParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_inAuthToken: crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.begin(_arg_inPurpose, &_arg_inKeyBlob, &_arg_inParams, &_arg_inAuthToken);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+            }
+          }
+        }
+        pub mod IKeyMintOperation {
+          #![allow(non_upper_case_globals)]
+          #![allow(non_snake_case)]
+          #[allow(unused_imports)] use binder::IBinder;
+          use binder::declare_binder_interface;
+          declare_binder_interface! {
+            IKeyMintOperation["android.hardware.keymint.IKeyMintOperation"] {
+              native: BnKeyMintOperation(on_transact),
+              proxy: BpKeyMintOperation {
+              },
+            }
+          }
+          pub trait IKeyMintOperation: binder::Interface {
+            fn get_descriptor() -> &'static str where Self: Sized { "android.hardware.keymint.IKeyMintOperation" }
+            fn update(&self, _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_input: &[u8], _arg_inVerificationToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken, _arg_outParams: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, _arg_output: &mut Vec<u8>) -> binder::public_api::Result<i32> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn finish(&self, _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_input: &[u8], _arg_inSignature: &[u8], _arg_authToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken, _arg_inVerificationToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken, _arg_outParams: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, _arg_output: &mut Vec<u8>) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn abort(&self) -> binder::public_api::Result<()> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn getDefaultImpl() -> DefaultImpl where Self: Sized {
+              DEFAULT_IMPL.lock().unwrap().clone()
+            }
+            fn setDefaultImpl(d: DefaultImpl) -> DefaultImpl where Self: Sized {
+              std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+            }
+          }
+          pub const TRANSACTION_update: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+          pub const TRANSACTION_finish: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
+          pub const TRANSACTION_abort: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
+          pub type DefaultImpl = Option<std::sync::Arc<dyn IKeyMintOperation + Send + Sync>>;
+          use lazy_static::lazy_static;
+          lazy_static! {
+            static ref DEFAULT_IMPL: std::sync::Mutex<DefaultImpl> = std::sync::Mutex::new(None);
+          }
+          pub(crate) mod mangled { pub use super::IKeyMintOperation as _7_android_8_hardware_7_keymint_17_IKeyMintOperation; }
+          impl IKeyMintOperation for BpKeyMintOperation {
+            fn update(&self, _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_input: &[u8], _arg_inVerificationToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken, _arg_outParams: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, _arg_output: &mut Vec<u8>) -> binder::public_api::Result<i32> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_update, 0, |_aidl_data| {
+                _aidl_data.write(_arg_inParams)?;
+                _aidl_data.write(_arg_input)?;
+                _aidl_data.write(_arg_inVerificationToken)?;
+                _aidl_data.write_slice_size(Some(_arg_outParams))?;
+                _aidl_data.write_slice_size(Some(_arg_output))?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintOperation>::getDefaultImpl() {
+                  return _aidl_default_impl.update(_arg_inParams, _arg_input, _arg_inVerificationToken, _arg_outParams, _arg_output);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: i32 = _aidl_reply.read()?;
+              *_arg_outParams = _aidl_reply.read()?;
+              *_arg_output = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn finish(&self, _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_input: &[u8], _arg_inSignature: &[u8], _arg_authToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken, _arg_inVerificationToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken, _arg_outParams: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, _arg_output: &mut Vec<u8>) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_finish, 0, |_aidl_data| {
+                _aidl_data.write(_arg_inParams)?;
+                _aidl_data.write(_arg_input)?;
+                _aidl_data.write(_arg_inSignature)?;
+                _aidl_data.write(_arg_authToken)?;
+                _aidl_data.write(_arg_inVerificationToken)?;
+                _aidl_data.write_slice_size(Some(_arg_outParams))?;
+                _aidl_data.write_slice_size(Some(_arg_output))?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintOperation>::getDefaultImpl() {
+                  return _aidl_default_impl.finish(_arg_inParams, _arg_input, _arg_inSignature, _arg_authToken, _arg_inVerificationToken, _arg_outParams, _arg_output);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              *_arg_outParams = _aidl_reply.read()?;
+              *_arg_output = _aidl_reply.read()?;
+              Ok(())
+            }
+            fn abort(&self) -> binder::public_api::Result<()> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_abort, 0, |_aidl_data| {
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeyMintOperation>::getDefaultImpl() {
+                  return _aidl_default_impl.abort();
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              Ok(())
+            }
+          }
+          impl IKeyMintOperation for binder::Binder<BnKeyMintOperation> {
+            fn update(&self, _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_input: &[u8], _arg_inVerificationToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken, _arg_outParams: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, _arg_output: &mut Vec<u8>) -> binder::public_api::Result<i32> { self.0.update(_arg_inParams, _arg_input, _arg_inVerificationToken, _arg_outParams, _arg_output) }
+            fn finish(&self, _arg_inParams: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_input: &[u8], _arg_inSignature: &[u8], _arg_authToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken, _arg_inVerificationToken: &crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken, _arg_outParams: &mut Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, _arg_output: &mut Vec<u8>) -> binder::public_api::Result<()> { self.0.finish(_arg_inParams, _arg_input, _arg_inSignature, _arg_authToken, _arg_inVerificationToken, _arg_outParams, _arg_output) }
+            fn abort(&self) -> binder::public_api::Result<()> { self.0.abort() }
+          }
+          fn on_transact(_aidl_service: &dyn IKeyMintOperation, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+            match _aidl_code {
+              TRANSACTION_update => {
+                let _arg_inParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_input: Vec<u8> = _aidl_data.read()?;
+                let _arg_inVerificationToken: crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken = _aidl_data.read()?;
+                let mut _arg_outParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_outParams)?;
+                let mut _arg_output: Vec<u8> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_output)?;
+                let _aidl_return = _aidl_service.update(&_arg_inParams, &_arg_input, &_arg_inVerificationToken, &mut _arg_outParams, &mut _arg_output);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_outParams)?;
+                    _aidl_reply.write(&_arg_output)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_finish => {
+                let _arg_inParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_input: Vec<u8> = _aidl_data.read()?;
+                let _arg_inSignature: Vec<u8> = _aidl_data.read()?;
+                let _arg_authToken: crate::mangled::_7_android_8_hardware_7_keymint_17_HardwareAuthToken = _aidl_data.read()?;
+                let _arg_inVerificationToken: crate::mangled::_7_android_8_hardware_7_keymint_17_VerificationToken = _aidl_data.read()?;
+                let mut _arg_outParams: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_outParams)?;
+                let mut _arg_output: Vec<u8> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_output)?;
+                let _aidl_return = _aidl_service.finish(&_arg_inParams, &_arg_input, &_arg_inSignature, &_arg_authToken, &_arg_inVerificationToken, &mut _arg_outParams, &mut _arg_output);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(&_arg_outParams)?;
+                    _aidl_reply.write(&_arg_output)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_abort => {
+                let _aidl_return = _aidl_service.abort();
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+            }
+          }
+        }
+        pub mod KeyCharacteristics {
+          pub struct KeyCharacteristics {
+            pub softwareEnforced: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, 
+            pub hardwareEnforced: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, 
+          }
+          pub(crate) mod mangled { pub use super::KeyCharacteristics as _7_android_8_hardware_7_keymint_18_KeyCharacteristics; }
+          impl Default for KeyCharacteristics {
+            fn default() -> Self {
+              Self {
+                softwareEnforced: Default::default(),
+                hardwareEnforced: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for KeyCharacteristics {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for KeyCharacteristics {}
+          impl binder::parcel::SerializeOption for KeyCharacteristics {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.softwareEnforced)?;
+              parcel.write(&this.hardwareEnforced)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for KeyCharacteristics {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for KeyCharacteristics {}
+          impl binder::parcel::DeserializeOption for KeyCharacteristics {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.softwareEnforced = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.hardwareEnforced = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod KeyDerivationFunction {
+          #![allow(non_upper_case_globals)]
+          pub type KeyDerivationFunction = i32;
+          pub const NONE: KeyDerivationFunction = 0;
+          pub const RFC5869_SHA256: KeyDerivationFunction = 1;
+          pub const ISO18033_2_KDF1_SHA1: KeyDerivationFunction = 2;
+          pub const ISO18033_2_KDF1_SHA256: KeyDerivationFunction = 3;
+          pub const ISO18033_2_KDF2_SHA1: KeyDerivationFunction = 4;
+          pub const ISO18033_2_KDF2_SHA256: KeyDerivationFunction = 5;
+          pub(crate) mod mangled { pub use super::KeyDerivationFunction as _7_android_8_hardware_7_keymint_21_KeyDerivationFunction; }
+        }
+        pub mod KeyFormat {
+          #![allow(non_upper_case_globals)]
+          pub type KeyFormat = i32;
+          pub const X509: KeyFormat = 0;
+          pub const PKCS8: KeyFormat = 1;
+          pub const RAW: KeyFormat = 3;
+          pub(crate) mod mangled { pub use super::KeyFormat as _7_android_8_hardware_7_keymint_9_KeyFormat; }
+        }
+        pub mod KeyMintHardwareInfo {
+          pub struct KeyMintHardwareInfo {
+            pub versionNumber: i32, 
+            pub securityLevel: crate::mangled::_7_android_8_hardware_7_keymint_13_SecurityLevel, 
+            pub keyMintName: String, 
+            pub keyMintAuthorName: String, 
+          }
+          pub(crate) mod mangled { pub use super::KeyMintHardwareInfo as _7_android_8_hardware_7_keymint_19_KeyMintHardwareInfo; }
+          impl Default for KeyMintHardwareInfo {
+            fn default() -> Self {
+              Self {
+                versionNumber: 0,
+                securityLevel: Default::default(),
+                keyMintName: Default::default(),
+                keyMintAuthorName: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for KeyMintHardwareInfo {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for KeyMintHardwareInfo {}
+          impl binder::parcel::SerializeOption for KeyMintHardwareInfo {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.versionNumber)?;
+              parcel.write(&this.securityLevel)?;
+              parcel.write(&this.keyMintName)?;
+              parcel.write(&this.keyMintAuthorName)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for KeyMintHardwareInfo {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for KeyMintHardwareInfo {}
+          impl binder::parcel::DeserializeOption for KeyMintHardwareInfo {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.versionNumber = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.securityLevel = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.keyMintName = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.keyMintAuthorName = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod KeyOrigin {
+          #![allow(non_upper_case_globals)]
+          pub type KeyOrigin = i32;
+          pub const GENERATED: KeyOrigin = 0;
+          pub const DERIVED: KeyOrigin = 1;
+          pub const IMPORTED: KeyOrigin = 2;
+          pub const SECURELY_IMPORTED: KeyOrigin = 4;
+          pub(crate) mod mangled { pub use super::KeyOrigin as _7_android_8_hardware_7_keymint_9_KeyOrigin; }
+        }
+        pub mod KeyParameter {
+          pub struct KeyParameter {
+            pub tag: crate::mangled::_7_android_8_hardware_7_keymint_3_Tag, 
+            pub boolValue: bool, 
+            pub integer: i32, 
+            pub longInteger: i64, 
+            pub dateTime: i64, 
+            pub blob: Vec<u8>, 
+          }
+          pub(crate) mod mangled { pub use super::KeyParameter as _7_android_8_hardware_7_keymint_12_KeyParameter; }
+          impl Default for KeyParameter {
+            fn default() -> Self {
+              Self {
+                tag: Default::default(),
+                boolValue: false,
+                integer: 0,
+                longInteger: 0,
+                dateTime: 0,
+                blob: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for KeyParameter {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for KeyParameter {}
+          impl binder::parcel::SerializeOption for KeyParameter {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.tag)?;
+              parcel.write(&this.boolValue)?;
+              parcel.write(&this.integer)?;
+              parcel.write(&this.longInteger)?;
+              parcel.write(&this.dateTime)?;
+              parcel.write(&this.blob)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for KeyParameter {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for KeyParameter {}
+          impl binder::parcel::DeserializeOption for KeyParameter {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.tag = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.boolValue = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.integer = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.longInteger = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.dateTime = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.blob = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod KeyPurpose {
+          #![allow(non_upper_case_globals)]
+          pub type KeyPurpose = i32;
+          pub const ENCRYPT: KeyPurpose = 0;
+          pub const DECRYPT: KeyPurpose = 1;
+          pub const SIGN: KeyPurpose = 2;
+          pub const VERIFY: KeyPurpose = 3;
+          pub const WRAP_KEY: KeyPurpose = 5;
+          pub(crate) mod mangled { pub use super::KeyPurpose as _7_android_8_hardware_7_keymint_10_KeyPurpose; }
+        }
+        pub mod PaddingMode {
+          #![allow(non_upper_case_globals)]
+          pub type PaddingMode = i32;
+          pub const NONE: PaddingMode = 1;
+          pub const RSA_OAEP: PaddingMode = 2;
+          pub const RSA_PSS: PaddingMode = 3;
+          pub const RSA_PKCS1_1_5_ENCRYPT: PaddingMode = 4;
+          pub const RSA_PKCS1_1_5_SIGN: PaddingMode = 5;
+          pub const PKCS7: PaddingMode = 64;
+          pub(crate) mod mangled { pub use super::PaddingMode as _7_android_8_hardware_7_keymint_11_PaddingMode; }
+        }
+        pub mod SecurityLevel {
+          #![allow(non_upper_case_globals)]
+          pub type SecurityLevel = i32;
+          pub const SOFTWARE: SecurityLevel = 0;
+          pub const TRUSTED_ENVIRONMENT: SecurityLevel = 1;
+          pub const STRONGBOX: SecurityLevel = 2;
+          pub(crate) mod mangled { pub use super::SecurityLevel as _7_android_8_hardware_7_keymint_13_SecurityLevel; }
+        }
+        pub mod Tag {
+          #![allow(non_upper_case_globals)]
+          pub type Tag = i32;
+          pub const INVALID: Tag = 0;
+          pub const PURPOSE: Tag = 536870913;
+          pub const ALGORITHM: Tag = 268435458;
+          pub const KEY_SIZE: Tag = 805306371;
+          pub const BLOCK_MODE: Tag = 536870916;
+          pub const DIGEST: Tag = 536870917;
+          pub const PADDING: Tag = 536870918;
+          pub const CALLER_NONCE: Tag = 1879048199;
+          pub const MIN_MAC_LENGTH: Tag = 805306376;
+          pub const EC_CURVE: Tag = 268435466;
+          pub const RSA_PUBLIC_EXPONENT: Tag = 1342177480;
+          pub const INCLUDE_UNIQUE_ID: Tag = 1879048394;
+          pub const BLOB_USAGE_REQUIREMENTS: Tag = 268435757;
+          pub const BOOTLOADER_ONLY: Tag = 1879048494;
+          pub const ROLLBACK_RESISTANCE: Tag = 1879048495;
+          pub const HARDWARE_TYPE: Tag = 268435760;
+          pub const EARLY_BOOT_ONLY: Tag = 1879048497;
+          pub const ACTIVE_DATETIME: Tag = 1610613136;
+          pub const ORIGINATION_EXPIRE_DATETIME: Tag = 1610613137;
+          pub const USAGE_EXPIRE_DATETIME: Tag = 1610613138;
+          pub const MIN_SECONDS_BETWEEN_OPS: Tag = 805306771;
+          pub const MAX_USES_PER_BOOT: Tag = 805306772;
+          pub const USER_ID: Tag = 805306869;
+          pub const USER_SECURE_ID: Tag = 1073742326;
+          pub const NO_AUTH_REQUIRED: Tag = 1879048695;
+          pub const USER_AUTH_TYPE: Tag = 268435960;
+          pub const AUTH_TIMEOUT: Tag = 805306873;
+          pub const ALLOW_WHILE_ON_BODY: Tag = 1879048698;
+          pub const TRUSTED_USER_PRESENCE_REQUIRED: Tag = 1879048699;
+          pub const TRUSTED_CONFIRMATION_REQUIRED: Tag = 1879048700;
+          pub const UNLOCKED_DEVICE_REQUIRED: Tag = 1879048701;
+          pub const APPLICATION_ID: Tag = -1879047591;
+          pub const APPLICATION_DATA: Tag = -1879047492;
+          pub const CREATION_DATETIME: Tag = 1610613437;
+          pub const ORIGIN: Tag = 268436158;
+          pub const ROOT_OF_TRUST: Tag = -1879047488;
+          pub const OS_VERSION: Tag = 805307073;
+          pub const OS_PATCHLEVEL: Tag = 805307074;
+          pub const UNIQUE_ID: Tag = -1879047485;
+          pub const ATTESTATION_CHALLENGE: Tag = -1879047484;
+          pub const ATTESTATION_APPLICATION_ID: Tag = -1879047483;
+          pub const ATTESTATION_ID_BRAND: Tag = -1879047482;
+          pub const ATTESTATION_ID_DEVICE: Tag = -1879047481;
+          pub const ATTESTATION_ID_PRODUCT: Tag = -1879047480;
+          pub const ATTESTATION_ID_SERIAL: Tag = -1879047479;
+          pub const ATTESTATION_ID_IMEI: Tag = -1879047478;
+          pub const ATTESTATION_ID_MEID: Tag = -1879047477;
+          pub const ATTESTATION_ID_MANUFACTURER: Tag = -1879047476;
+          pub const ATTESTATION_ID_MODEL: Tag = -1879047475;
+          pub const VENDOR_PATCHLEVEL: Tag = 805307086;
+          pub const BOOT_PATCHLEVEL: Tag = 805307087;
+          pub const DEVICE_UNIQUE_ATTESTATION: Tag = 1879048912;
+          pub const IDENTITY_CREDENTIAL_KEY: Tag = 1879048913;
+          pub const STORAGE_KEY: Tag = 1879048914;
+          pub const ASSOCIATED_DATA: Tag = -1879047192;
+          pub const NONCE: Tag = -1879047191;
+          pub const MAC_LENGTH: Tag = 805307371;
+          pub const RESET_SINCE_ID_ROTATION: Tag = 1879049196;
+          pub const CONFIRMATION_TOKEN: Tag = -1879047187;
+          pub(crate) mod mangled { pub use super::Tag as _7_android_8_hardware_7_keymint_3_Tag; }
+        }
+        pub mod TagType {
+          #![allow(non_upper_case_globals)]
+          pub type TagType = i32;
+          pub const INVALID: TagType = 0;
+          pub const ENUM: TagType = 268435456;
+          pub const ENUM_REP: TagType = 536870912;
+          pub const UINT: TagType = 805306368;
+          pub const UINT_REP: TagType = 1073741824;
+          pub const ULONG: TagType = 1342177280;
+          pub const DATE: TagType = 1610612736;
+          pub const BOOL: TagType = 1879048192;
+          pub const BIGNUM: TagType = -2147483648;
+          pub const BYTES: TagType = -1879048192;
+          pub const ULONG_REP: TagType = -1610612736;
+          pub(crate) mod mangled { pub use super::TagType as _7_android_8_hardware_7_keymint_7_TagType; }
+        }
+        pub mod Timestamp {
+          pub struct Timestamp {
+            pub milliSeconds: i64, 
+          }
+          pub(crate) mod mangled { pub use super::Timestamp as _7_android_8_hardware_7_keymint_9_Timestamp; }
+          impl Default for Timestamp {
+            fn default() -> Self {
+              Self {
+                milliSeconds: 0,
+              }
+            }
+          }
+          impl binder::parcel::Serialize for Timestamp {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for Timestamp {}
+          impl binder::parcel::SerializeOption for Timestamp {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.milliSeconds)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for Timestamp {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for Timestamp {}
+          impl binder::parcel::DeserializeOption for Timestamp {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.milliSeconds = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod VerificationToken {
+          pub struct VerificationToken {
+            pub challenge: i64, 
+            pub timestamp: crate::mangled::_7_android_8_hardware_7_keymint_9_Timestamp, 
+            pub securityLevel: crate::mangled::_7_android_8_hardware_7_keymint_13_SecurityLevel, 
+            pub mac: Vec<u8>, 
+          }
+          pub(crate) mod mangled { pub use super::VerificationToken as _7_android_8_hardware_7_keymint_17_VerificationToken; }
+          impl Default for VerificationToken {
+            fn default() -> Self {
+              Self {
+                challenge: 0,
+                timestamp: Default::default(),
+                securityLevel: Default::default(),
+                mac: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for VerificationToken {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for VerificationToken {}
+          impl binder::parcel::SerializeOption for VerificationToken {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.challenge)?;
+              parcel.write(&this.timestamp)?;
+              parcel.write(&this.securityLevel)?;
+              parcel.write(&this.mac)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for VerificationToken {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for VerificationToken {}
+          impl binder::parcel::DeserializeOption for VerificationToken {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.challenge = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.timestamp = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.securityLevel = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.mac = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+      }
+    }
+  }
+}
+pub mod mangled {
+  pub use super::aidl::android::hardware::keymint::Algorithm::mangled::*;
+  pub use super::aidl::android::hardware::keymint::BeginResult::mangled::*;
+  pub use super::aidl::android::hardware::keymint::BlockMode::mangled::*;
+  pub use super::aidl::android::hardware::keymint::Certificate::mangled::*;
+  pub use super::aidl::android::hardware::keymint::Constants::mangled::*;
+  pub use super::aidl::android::hardware::keymint::Digest::mangled::*;
+  pub use super::aidl::android::hardware::keymint::EcCurve::mangled::*;
+  pub use super::aidl::android::hardware::keymint::ErrorCode::mangled::*;
+  pub use super::aidl::android::hardware::keymint::HardwareAuthToken::mangled::*;
+  pub use super::aidl::android::hardware::keymint::HardwareAuthenticatorType::mangled::*;
+  pub use super::aidl::android::hardware::keymint::HmacSharingParameters::mangled::*;
+  pub use super::aidl::android::hardware::keymint::IKeyMintDevice::mangled::*;
+  pub use super::aidl::android::hardware::keymint::IKeyMintOperation::mangled::*;
+  pub use super::aidl::android::hardware::keymint::KeyCharacteristics::mangled::*;
+  pub use super::aidl::android::hardware::keymint::KeyDerivationFunction::mangled::*;
+  pub use super::aidl::android::hardware::keymint::KeyFormat::mangled::*;
+  pub use super::aidl::android::hardware::keymint::KeyMintHardwareInfo::mangled::*;
+  pub use super::aidl::android::hardware::keymint::KeyOrigin::mangled::*;
+  pub use super::aidl::android::hardware::keymint::KeyParameter::mangled::*;
+  pub use super::aidl::android::hardware::keymint::KeyPurpose::mangled::*;
+  pub use super::aidl::android::hardware::keymint::PaddingMode::mangled::*;
+  pub use super::aidl::android::hardware::keymint::SecurityLevel::mangled::*;
+  pub use super::aidl::android::hardware::keymint::Tag::mangled::*;
+  pub use super::aidl::android::hardware::keymint::TagType::mangled::*;
+  pub use super::aidl::android::hardware::keymint::Timestamp::mangled::*;
+  pub use super::aidl::android::hardware::keymint::VerificationToken::mangled::*;
+}
\ No newline at end of file
diff --git a/keystore2/src/android_security_keystore2.rs b/keystore2/src/android_security_keystore2.rs
new file mode 100644
index 0000000..1969ed5
--- /dev/null
+++ b/keystore2/src/android_security_keystore2.rs
@@ -0,0 +1,1311 @@
+#![allow(non_snake_case)]
+#![allow(missing_docs)]
+#![allow(clippy::identity_op)]
+#![allow(clippy::excessive_precision)]
+#![allow(clippy::too_many_arguments)]
+pub use binder::public_api as binder;
+pub mod aidl {
+  pub mod android {
+    pub mod security {
+      pub mod keystore2 {
+        pub mod AuthenticatorSpec {
+          pub struct AuthenticatorSpec {
+            pub authenticatorType: crate::mangled::_7_android_8_hardware_7_keymint_25_HardwareAuthenticatorType, 
+            pub authenticatorId: i64, 
+          }
+          pub(crate) mod mangled { pub use super::AuthenticatorSpec as _7_android_8_security_9_keystore2_17_AuthenticatorSpec; }
+          impl Default for AuthenticatorSpec {
+            fn default() -> Self {
+              Self {
+                authenticatorType: Default::default(),
+                authenticatorId: 0,
+              }
+            }
+          }
+          impl binder::parcel::Serialize for AuthenticatorSpec {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for AuthenticatorSpec {}
+          impl binder::parcel::SerializeOption for AuthenticatorSpec {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.authenticatorType)?;
+              parcel.write(&this.authenticatorId)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for AuthenticatorSpec {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for AuthenticatorSpec {}
+          impl binder::parcel::DeserializeOption for AuthenticatorSpec {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.authenticatorType = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.authenticatorId = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod Certificate {
+          pub struct Certificate {
+            pub data: Vec<u8>, 
+          }
+          pub(crate) mod mangled { pub use super::Certificate as _7_android_8_security_9_keystore2_11_Certificate; }
+          impl Default for Certificate {
+            fn default() -> Self {
+              Self {
+                data: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for Certificate {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for Certificate {}
+          impl binder::parcel::SerializeOption for Certificate {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.data)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for Certificate {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for Certificate {}
+          impl binder::parcel::DeserializeOption for Certificate {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.data = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod CertificateChain {
+          pub struct CertificateChain {
+            pub certificates: Vec<crate::mangled::_7_android_8_security_9_keystore2_11_Certificate>, 
+          }
+          pub(crate) mod mangled { pub use super::CertificateChain as _7_android_8_security_9_keystore2_16_CertificateChain; }
+          impl Default for CertificateChain {
+            fn default() -> Self {
+              Self {
+                certificates: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for CertificateChain {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for CertificateChain {}
+          impl binder::parcel::SerializeOption for CertificateChain {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.certificates)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for CertificateChain {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for CertificateChain {}
+          impl binder::parcel::DeserializeOption for CertificateChain {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.certificates = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod Domain {
+          #![allow(non_upper_case_globals)]
+          pub type Domain = i32;
+          pub const App: Domain = 0;
+          pub const Grant: Domain = 1;
+          pub const SELinux: Domain = 2;
+          pub const Blob: Domain = 3;
+          pub const KeyId: Domain = 4;
+          pub(crate) mod mangled { pub use super::Domain as _7_android_8_security_9_keystore2_6_Domain; }
+        }
+        pub mod IKeystoreOperation {
+          #![allow(non_upper_case_globals)]
+          #![allow(non_snake_case)]
+          #[allow(unused_imports)] use binder::IBinder;
+          use binder::declare_binder_interface;
+          declare_binder_interface! {
+            IKeystoreOperation["android.security.keystore2.IKeystoreOperation"] {
+              native: BnKeystoreOperation(on_transact),
+              proxy: BpKeystoreOperation {
+              },
+            }
+          }
+          pub trait IKeystoreOperation: binder::Interface {
+            fn get_descriptor() -> &'static str where Self: Sized { "android.security.keystore2.IKeystoreOperation" }
+            fn update(&self, _arg_input: Option<&[u8]>, _arg_aadInput: Option<&[u8]>, _arg_output: &mut Option<Vec<u8>>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn finish(&self, _arg_input: Option<&[u8]>, _arg_signature: Option<&[u8]>, _arg_entropy: Option<&[u8]>, _arg_output: &mut Option<Vec<u8>>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn abort(&self) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn getDefaultImpl() -> DefaultImpl where Self: Sized {
+              DEFAULT_IMPL.lock().unwrap().clone()
+            }
+            fn setDefaultImpl(d: DefaultImpl) -> DefaultImpl where Self: Sized {
+              std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+            }
+          }
+          pub const TRANSACTION_update: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+          pub const TRANSACTION_finish: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
+          pub const TRANSACTION_abort: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
+          pub type DefaultImpl = Option<std::sync::Arc<dyn IKeystoreOperation + Send + Sync>>;
+          use lazy_static::lazy_static;
+          lazy_static! {
+            static ref DEFAULT_IMPL: std::sync::Mutex<DefaultImpl> = std::sync::Mutex::new(None);
+          }
+          pub(crate) mod mangled { pub use super::IKeystoreOperation as _7_android_8_security_9_keystore2_18_IKeystoreOperation; }
+          impl IKeystoreOperation for BpKeystoreOperation {
+            fn update(&self, _arg_input: Option<&[u8]>, _arg_aadInput: Option<&[u8]>, _arg_output: &mut Option<Vec<u8>>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_update, 0, |_aidl_data| {
+                _aidl_data.write(&_arg_input)?;
+                _aidl_data.write(&_arg_aadInput)?;
+                _aidl_data.write_slice_size(_arg_output.as_deref())?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreOperation>::getDefaultImpl() {
+                  return _aidl_default_impl.update(_arg_input, _arg_aadInput, _arg_output);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              *_arg_output = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn finish(&self, _arg_input: Option<&[u8]>, _arg_signature: Option<&[u8]>, _arg_entropy: Option<&[u8]>, _arg_output: &mut Option<Vec<u8>>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_finish, 0, |_aidl_data| {
+                _aidl_data.write(&_arg_input)?;
+                _aidl_data.write(&_arg_signature)?;
+                _aidl_data.write(&_arg_entropy)?;
+                _aidl_data.write_slice_size(_arg_output.as_deref())?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreOperation>::getDefaultImpl() {
+                  return _aidl_default_impl.finish(_arg_input, _arg_signature, _arg_entropy, _arg_output);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              *_arg_output = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn abort(&self) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_abort, 0, |_aidl_data| {
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreOperation>::getDefaultImpl() {
+                  return _aidl_default_impl.abort();
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+          }
+          impl IKeystoreOperation for binder::Binder<BnKeystoreOperation> {
+            fn update(&self, _arg_input: Option<&[u8]>, _arg_aadInput: Option<&[u8]>, _arg_output: &mut Option<Vec<u8>>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.update(_arg_input, _arg_aadInput, _arg_output) }
+            fn finish(&self, _arg_input: Option<&[u8]>, _arg_signature: Option<&[u8]>, _arg_entropy: Option<&[u8]>, _arg_output: &mut Option<Vec<u8>>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.finish(_arg_input, _arg_signature, _arg_entropy, _arg_output) }
+            fn abort(&self) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.abort() }
+          }
+          fn on_transact(_aidl_service: &dyn IKeystoreOperation, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+            match _aidl_code {
+              TRANSACTION_update => {
+                let _arg_input: Option<Vec<u8>> = _aidl_data.read()?;
+                let _arg_aadInput: Option<Vec<u8>> = _aidl_data.read()?;
+                let mut _arg_output: Option<Vec<u8>> = Default::default();
+                _aidl_data.resize_nullable_out_vec(&mut _arg_output)?;
+                let _aidl_return = _aidl_service.update(_arg_input.as_deref(), _arg_aadInput.as_deref(), &mut _arg_output);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_output)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_finish => {
+                let _arg_input: Option<Vec<u8>> = _aidl_data.read()?;
+                let _arg_signature: Option<Vec<u8>> = _aidl_data.read()?;
+                let _arg_entropy: Option<Vec<u8>> = _aidl_data.read()?;
+                let mut _arg_output: Option<Vec<u8>> = Default::default();
+                _aidl_data.resize_nullable_out_vec(&mut _arg_output)?;
+                let _aidl_return = _aidl_service.finish(_arg_input.as_deref(), _arg_signature.as_deref(), _arg_entropy.as_deref(), &mut _arg_output);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_output)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_abort => {
+                let _aidl_return = _aidl_service.abort();
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+            }
+          }
+        }
+        pub mod IKeystoreSecurityLevel {
+          #![allow(non_upper_case_globals)]
+          #![allow(non_snake_case)]
+          #[allow(unused_imports)] use binder::IBinder;
+          use binder::declare_binder_interface;
+          declare_binder_interface! {
+            IKeystoreSecurityLevel["android.security.keystore2.IKeystoreSecurityLevel"] {
+              native: BnKeystoreSecurityLevel(on_transact),
+              proxy: BpKeystoreSecurityLevel {
+              },
+            }
+          }
+          pub trait IKeystoreSecurityLevel: binder::Interface {
+            fn get_descriptor() -> &'static str where Self: Sized { "android.security.keystore2.IKeystoreSecurityLevel" }
+            fn create(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_operationParameters: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_forced: bool, _arg_challenge: &mut crate::mangled::_7_android_8_security_9_keystore2_18_OperationChallenge, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_18_IKeystoreOperation>> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn updateSubcomponent(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: Option<&crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: Option<&crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn generateKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_entropy: &[u8], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn importKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_keyData: &[u8], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn importWrappedKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_wrappingKey: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_maskingKey: &[u8], _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_authenticators: &[crate::mangled::_7_android_8_security_9_keystore2_17_AuthenticatorSpec], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn getDefaultImpl() -> DefaultImpl where Self: Sized {
+              DEFAULT_IMPL.lock().unwrap().clone()
+            }
+            fn setDefaultImpl(d: DefaultImpl) -> DefaultImpl where Self: Sized {
+              std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+            }
+          }
+          pub const TRANSACTION_create: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+          pub const TRANSACTION_updateSubcomponent: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
+          pub const TRANSACTION_generateKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
+          pub const TRANSACTION_importKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
+          pub const TRANSACTION_importWrappedKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 4;
+          pub type DefaultImpl = Option<std::sync::Arc<dyn IKeystoreSecurityLevel + Send + Sync>>;
+          use lazy_static::lazy_static;
+          lazy_static! {
+            static ref DEFAULT_IMPL: std::sync::Mutex<DefaultImpl> = std::sync::Mutex::new(None);
+          }
+          pub(crate) mod mangled { pub use super::IKeystoreSecurityLevel as _7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel; }
+          impl IKeystoreSecurityLevel for BpKeystoreSecurityLevel {
+            fn create(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_operationParameters: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_forced: bool, _arg_challenge: &mut crate::mangled::_7_android_8_security_9_keystore2_18_OperationChallenge, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_18_IKeystoreOperation>> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_create, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                _aidl_data.write(_arg_operationParameters)?;
+                _aidl_data.write(&_arg_forced)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreSecurityLevel>::getDefaultImpl() {
+                  return _aidl_default_impl.create(_arg_key, _arg_operationParameters, _arg_forced, _arg_challenge, _arg_rc);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: Box<dyn crate::mangled::_7_android_8_security_9_keystore2_18_IKeystoreOperation> = _aidl_reply.read()?;
+              *_arg_challenge = _aidl_reply.read()?;
+              *_arg_rc = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn updateSubcomponent(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: Option<&crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: Option<&crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_updateSubcomponent, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                _aidl_data.write(&_arg_publicKey)?;
+                _aidl_data.write(&_arg_certificateChain)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreSecurityLevel>::getDefaultImpl() {
+                  return _aidl_default_impl.updateSubcomponent(_arg_key, _arg_publicKey, _arg_certificateChain);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn generateKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_entropy: &[u8], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_generateKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                _aidl_data.write(_arg_params)?;
+                _aidl_data.write(_arg_entropy)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreSecurityLevel>::getDefaultImpl() {
+                  return _aidl_default_impl.generateKey(_arg_key, _arg_params, _arg_entropy, _arg_resultKey, _arg_publicKey, _arg_certificateChain);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              *_arg_resultKey = _aidl_reply.read()?;
+              *_arg_publicKey = _aidl_reply.read()?;
+              *_arg_certificateChain = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn importKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_keyData: &[u8], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_importKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                _aidl_data.write(_arg_params)?;
+                _aidl_data.write(_arg_keyData)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreSecurityLevel>::getDefaultImpl() {
+                  return _aidl_default_impl.importKey(_arg_key, _arg_params, _arg_keyData, _arg_resultKey, _arg_publicKey, _arg_certificateChain);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              *_arg_resultKey = _aidl_reply.read()?;
+              *_arg_publicKey = _aidl_reply.read()?;
+              *_arg_certificateChain = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn importWrappedKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_wrappingKey: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_maskingKey: &[u8], _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_authenticators: &[crate::mangled::_7_android_8_security_9_keystore2_17_AuthenticatorSpec], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_importWrappedKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                _aidl_data.write(_arg_wrappingKey)?;
+                _aidl_data.write(_arg_maskingKey)?;
+                _aidl_data.write(_arg_params)?;
+                _aidl_data.write(_arg_authenticators)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreSecurityLevel>::getDefaultImpl() {
+                  return _aidl_default_impl.importWrappedKey(_arg_key, _arg_wrappingKey, _arg_maskingKey, _arg_params, _arg_authenticators, _arg_resultKey, _arg_publicKey, _arg_certificateChain);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              *_arg_resultKey = _aidl_reply.read()?;
+              *_arg_publicKey = _aidl_reply.read()?;
+              *_arg_certificateChain = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+          }
+          impl IKeystoreSecurityLevel for binder::Binder<BnKeystoreSecurityLevel> {
+            fn create(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_operationParameters: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_forced: bool, _arg_challenge: &mut crate::mangled::_7_android_8_security_9_keystore2_18_OperationChallenge, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_18_IKeystoreOperation>> { self.0.create(_arg_key, _arg_operationParameters, _arg_forced, _arg_challenge, _arg_rc) }
+            fn updateSubcomponent(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: Option<&crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: Option<&crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.updateSubcomponent(_arg_key, _arg_publicKey, _arg_certificateChain) }
+            fn generateKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_entropy: &[u8], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.generateKey(_arg_key, _arg_params, _arg_entropy, _arg_resultKey, _arg_publicKey, _arg_certificateChain) }
+            fn importKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_keyData: &[u8], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.importKey(_arg_key, _arg_params, _arg_keyData, _arg_resultKey, _arg_publicKey, _arg_certificateChain) }
+            fn importWrappedKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_wrappingKey: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_maskingKey: &[u8], _arg_params: &[crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter], _arg_authenticators: &[crate::mangled::_7_android_8_security_9_keystore2_17_AuthenticatorSpec], _arg_resultKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.importWrappedKey(_arg_key, _arg_wrappingKey, _arg_maskingKey, _arg_params, _arg_authenticators, _arg_resultKey, _arg_publicKey, _arg_certificateChain) }
+          }
+          fn on_transact(_aidl_service: &dyn IKeystoreSecurityLevel, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+            match _aidl_code {
+              TRANSACTION_create => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_operationParameters: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_forced: bool = _aidl_data.read()?;
+                let mut _arg_challenge: crate::mangled::_7_android_8_security_9_keystore2_18_OperationChallenge = Default::default();
+                let mut _arg_rc: crate::mangled::_7_android_8_security_9_keystore2_6_Result = Default::default();
+                let _aidl_return = _aidl_service.create(&_arg_key, &_arg_operationParameters, _arg_forced, &mut _arg_challenge, &mut _arg_rc);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_challenge)?;
+                    _aidl_reply.write(&_arg_rc)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_updateSubcomponent => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_publicKey: Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey> = _aidl_data.read()?;
+                let _arg_certificateChain: Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain> = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.updateSubcomponent(&_arg_key, _arg_publicKey.as_ref(), _arg_certificateChain.as_ref());
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_generateKey => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_params: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_entropy: Vec<u8> = _aidl_data.read()?;
+                let mut _arg_resultKey: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = Default::default();
+                let mut _arg_publicKey: Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey> = Default::default();
+                let mut _arg_certificateChain: Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain> = Default::default();
+                let _aidl_return = _aidl_service.generateKey(&_arg_key, &_arg_params, &_arg_entropy, &mut _arg_resultKey, &mut _arg_publicKey, &mut _arg_certificateChain);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_resultKey)?;
+                    _aidl_reply.write(&_arg_publicKey)?;
+                    _aidl_reply.write(&_arg_certificateChain)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_importKey => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_params: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_keyData: Vec<u8> = _aidl_data.read()?;
+                let mut _arg_resultKey: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = Default::default();
+                let mut _arg_publicKey: Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey> = Default::default();
+                let mut _arg_certificateChain: Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain> = Default::default();
+                let _aidl_return = _aidl_service.importKey(&_arg_key, &_arg_params, &_arg_keyData, &mut _arg_resultKey, &mut _arg_publicKey, &mut _arg_certificateChain);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_resultKey)?;
+                    _aidl_reply.write(&_arg_publicKey)?;
+                    _aidl_reply.write(&_arg_certificateChain)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_importWrappedKey => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_wrappingKey: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_maskingKey: Vec<u8> = _aidl_data.read()?;
+                let _arg_params: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter> = _aidl_data.read()?;
+                let _arg_authenticators: Vec<crate::mangled::_7_android_8_security_9_keystore2_17_AuthenticatorSpec> = _aidl_data.read()?;
+                let mut _arg_resultKey: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = Default::default();
+                let mut _arg_publicKey: Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey> = Default::default();
+                let mut _arg_certificateChain: Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain> = Default::default();
+                let _aidl_return = _aidl_service.importWrappedKey(&_arg_key, &_arg_wrappingKey, &_arg_maskingKey, &_arg_params, &_arg_authenticators, &mut _arg_resultKey, &mut _arg_publicKey, &mut _arg_certificateChain);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_resultKey)?;
+                    _aidl_reply.write(&_arg_publicKey)?;
+                    _aidl_reply.write(&_arg_certificateChain)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+            }
+          }
+        }
+        pub mod IKeystoreService {
+          #![allow(non_upper_case_globals)]
+          #![allow(non_snake_case)]
+          #[allow(unused_imports)] use binder::IBinder;
+          use binder::declare_binder_interface;
+          declare_binder_interface! {
+            IKeystoreService["android.security.keystore2.IKeystoreService"] {
+              native: BnKeystoreService(on_transact),
+              proxy: BpKeystoreService {
+              },
+            }
+          }
+          pub trait IKeystoreService: binder::Interface {
+            fn get_descriptor() -> &'static str where Self: Sized { "android.security.keystore2.IKeystoreService" }
+            fn getSecurityLevel(&self, _arg_securityLevel: crate::mangled::_7_android_8_hardware_7_keymint_13_SecurityLevel, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel>> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn getKeyEntry(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_metadata: &mut crate::mangled::_7_android_8_security_9_keystore2_11_KeyMetadata, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel>> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn listEntries(&self, _arg_domain: crate::mangled::_7_android_8_security_9_keystore2_6_Domain, _arg_nameSpace: i64, _arg_list: &mut Vec<crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn deleteKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn grant(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_granteeUid: i32, _arg_accessVector: i32, _arg_grantKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn ungrant(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_granteeUid: i32) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              Err(binder::StatusCode::UNKNOWN_TRANSACTION.into())
+            }
+            fn getDefaultImpl() -> DefaultImpl where Self: Sized {
+              DEFAULT_IMPL.lock().unwrap().clone()
+            }
+            fn setDefaultImpl(d: DefaultImpl) -> DefaultImpl where Self: Sized {
+              std::mem::replace(&mut *DEFAULT_IMPL.lock().unwrap(), d)
+            }
+          }
+          pub const TRANSACTION_getSecurityLevel: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 0;
+          pub const TRANSACTION_getKeyEntry: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 1;
+          pub const TRANSACTION_listEntries: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 2;
+          pub const TRANSACTION_deleteKey: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 3;
+          pub const TRANSACTION_grant: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 4;
+          pub const TRANSACTION_ungrant: binder::TransactionCode = binder::SpIBinder::FIRST_CALL_TRANSACTION + 5;
+          pub type DefaultImpl = Option<std::sync::Arc<dyn IKeystoreService + Send + Sync>>;
+          use lazy_static::lazy_static;
+          lazy_static! {
+            static ref DEFAULT_IMPL: std::sync::Mutex<DefaultImpl> = std::sync::Mutex::new(None);
+          }
+          pub(crate) mod mangled { pub use super::IKeystoreService as _7_android_8_security_9_keystore2_16_IKeystoreService; }
+          impl IKeystoreService for BpKeystoreService {
+            fn getSecurityLevel(&self, _arg_securityLevel: crate::mangled::_7_android_8_hardware_7_keymint_13_SecurityLevel, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel>> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_getSecurityLevel, 0, |_aidl_data| {
+                _aidl_data.write(&_arg_securityLevel)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreService>::getDefaultImpl() {
+                  return _aidl_default_impl.getSecurityLevel(_arg_securityLevel, _arg_rc);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel> = _aidl_reply.read()?;
+              *_arg_rc = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn getKeyEntry(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_metadata: &mut crate::mangled::_7_android_8_security_9_keystore2_11_KeyMetadata, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel>> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_getKeyEntry, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreService>::getDefaultImpl() {
+                  return _aidl_default_impl.getKeyEntry(_arg_key, _arg_metadata, _arg_publicKey, _arg_certificateChain, _arg_rc);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel> = _aidl_reply.read()?;
+              *_arg_metadata = _aidl_reply.read()?;
+              *_arg_publicKey = _aidl_reply.read()?;
+              *_arg_certificateChain = _aidl_reply.read()?;
+              *_arg_rc = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn listEntries(&self, _arg_domain: crate::mangled::_7_android_8_security_9_keystore2_6_Domain, _arg_nameSpace: i64, _arg_list: &mut Vec<crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_listEntries, 0, |_aidl_data| {
+                _aidl_data.write(&_arg_domain)?;
+                _aidl_data.write(&_arg_nameSpace)?;
+                _aidl_data.write_slice_size(Some(_arg_list))?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreService>::getDefaultImpl() {
+                  return _aidl_default_impl.listEntries(_arg_domain, _arg_nameSpace, _arg_list);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              *_arg_list = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn deleteKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_deleteKey, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreService>::getDefaultImpl() {
+                  return _aidl_default_impl.deleteKey(_arg_key);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn grant(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_granteeUid: i32, _arg_accessVector: i32, _arg_grantKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_grant, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                _aidl_data.write(&_arg_granteeUid)?;
+                _aidl_data.write(&_arg_accessVector)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreService>::getDefaultImpl() {
+                  return _aidl_default_impl.grant(_arg_key, _arg_granteeUid, _arg_accessVector, _arg_grantKey);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              *_arg_grantKey = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+            fn ungrant(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_granteeUid: i32) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> {
+              let _aidl_reply = self.binder.transact(TRANSACTION_ungrant, 0, |_aidl_data| {
+                _aidl_data.write(_arg_key)?;
+                _aidl_data.write(&_arg_granteeUid)?;
+                Ok(())
+              });
+              if let Err(binder::StatusCode::UNKNOWN_TRANSACTION) = _aidl_reply {
+                if let Some(_aidl_default_impl) = <Self as IKeystoreService>::getDefaultImpl() {
+                  return _aidl_default_impl.ungrant(_arg_key, _arg_granteeUid);
+                }
+              }
+              let _aidl_reply = _aidl_reply?;
+              let _aidl_status: binder::Status = _aidl_reply.read()?;
+              if !_aidl_status.is_ok() { return Err(_aidl_status); }
+              let _aidl_return: crate::mangled::_7_android_8_security_9_keystore2_6_Result = _aidl_reply.read()?;
+              Ok(_aidl_return)
+            }
+          }
+          impl IKeystoreService for binder::Binder<BnKeystoreService> {
+            fn getSecurityLevel(&self, _arg_securityLevel: crate::mangled::_7_android_8_hardware_7_keymint_13_SecurityLevel, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel>> { self.0.getSecurityLevel(_arg_securityLevel, _arg_rc) }
+            fn getKeyEntry(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_metadata: &mut crate::mangled::_7_android_8_security_9_keystore2_11_KeyMetadata, _arg_publicKey: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey>, _arg_certificateChain: &mut Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain>, _arg_rc: &mut crate::mangled::_7_android_8_security_9_keystore2_6_Result) -> binder::public_api::Result<Box<dyn crate::mangled::_7_android_8_security_9_keystore2_22_IKeystoreSecurityLevel>> { self.0.getKeyEntry(_arg_key, _arg_metadata, _arg_publicKey, _arg_certificateChain, _arg_rc) }
+            fn listEntries(&self, _arg_domain: crate::mangled::_7_android_8_security_9_keystore2_6_Domain, _arg_nameSpace: i64, _arg_list: &mut Vec<crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor>) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.listEntries(_arg_domain, _arg_nameSpace, _arg_list) }
+            fn deleteKey(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.deleteKey(_arg_key) }
+            fn grant(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_granteeUid: i32, _arg_accessVector: i32, _arg_grantKey: &mut crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.grant(_arg_key, _arg_granteeUid, _arg_accessVector, _arg_grantKey) }
+            fn ungrant(&self, _arg_key: &crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, _arg_granteeUid: i32) -> binder::public_api::Result<crate::mangled::_7_android_8_security_9_keystore2_6_Result> { self.0.ungrant(_arg_key, _arg_granteeUid) }
+          }
+          fn on_transact(_aidl_service: &dyn IKeystoreService, _aidl_code: binder::TransactionCode, _aidl_data: &binder::parcel::Parcel, _aidl_reply: &mut binder::parcel::Parcel) -> binder::Result<()> {
+            match _aidl_code {
+              TRANSACTION_getSecurityLevel => {
+                let _arg_securityLevel: crate::mangled::_7_android_8_hardware_7_keymint_13_SecurityLevel = _aidl_data.read()?;
+                let mut _arg_rc: crate::mangled::_7_android_8_security_9_keystore2_6_Result = Default::default();
+                let _aidl_return = _aidl_service.getSecurityLevel(_arg_securityLevel, &mut _arg_rc);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_rc)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_getKeyEntry => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let mut _arg_metadata: crate::mangled::_7_android_8_security_9_keystore2_11_KeyMetadata = Default::default();
+                let mut _arg_publicKey: Option<crate::mangled::_7_android_8_security_9_keystore2_9_PublicKey> = Default::default();
+                let mut _arg_certificateChain: Option<crate::mangled::_7_android_8_security_9_keystore2_16_CertificateChain> = Default::default();
+                let mut _arg_rc: crate::mangled::_7_android_8_security_9_keystore2_6_Result = Default::default();
+                let _aidl_return = _aidl_service.getKeyEntry(&_arg_key, &mut _arg_metadata, &mut _arg_publicKey, &mut _arg_certificateChain, &mut _arg_rc);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_metadata)?;
+                    _aidl_reply.write(&_arg_publicKey)?;
+                    _aidl_reply.write(&_arg_certificateChain)?;
+                    _aidl_reply.write(&_arg_rc)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_listEntries => {
+                let _arg_domain: crate::mangled::_7_android_8_security_9_keystore2_6_Domain = _aidl_data.read()?;
+                let _arg_nameSpace: i64 = _aidl_data.read()?;
+                let mut _arg_list: Vec<crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor> = Default::default();
+                _aidl_data.resize_out_vec(&mut _arg_list)?;
+                let _aidl_return = _aidl_service.listEntries(_arg_domain, _arg_nameSpace, &mut _arg_list);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_list)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_deleteKey => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.deleteKey(&_arg_key);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_grant => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_granteeUid: i32 = _aidl_data.read()?;
+                let _arg_accessVector: i32 = _aidl_data.read()?;
+                let mut _arg_grantKey: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = Default::default();
+                let _aidl_return = _aidl_service.grant(&_arg_key, _arg_granteeUid, _arg_accessVector, &mut _arg_grantKey);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                    _aidl_reply.write(&_arg_grantKey)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              TRANSACTION_ungrant => {
+                let _arg_key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor = _aidl_data.read()?;
+                let _arg_granteeUid: i32 = _aidl_data.read()?;
+                let _aidl_return = _aidl_service.ungrant(&_arg_key, _arg_granteeUid);
+                match &_aidl_return {
+                  Ok(_aidl_return) => {
+                    _aidl_reply.write(&binder::Status::from(binder::StatusCode::OK))?;
+                    _aidl_reply.write(_aidl_return)?;
+                  }
+                  Err(_aidl_status) => _aidl_reply.write(_aidl_status)?
+                }
+                Ok(())
+              }
+              _ => Err(binder::StatusCode::UNKNOWN_TRANSACTION)
+            }
+          }
+        }
+        pub mod KeyDescriptor {
+          pub struct KeyDescriptor {
+            pub domain: crate::mangled::_7_android_8_security_9_keystore2_6_Domain, 
+            pub namespace_: i64, 
+            pub alias: Option<String>,
+            pub blob: Option<Vec<u8>>,
+          }
+          pub(crate) mod mangled { pub use super::KeyDescriptor as _7_android_8_security_9_keystore2_13_KeyDescriptor; }
+          impl Default for KeyDescriptor {
+            fn default() -> Self {
+              Self {
+                domain: Default::default(),
+                namespace_: 0,
+                alias: Default::default(),
+                blob: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for KeyDescriptor {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for KeyDescriptor {}
+          impl binder::parcel::SerializeOption for KeyDescriptor {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.domain)?;
+              parcel.write(&this.namespace_)?;
+              parcel.write(&this.alias)?;
+              parcel.write(&this.blob)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for KeyDescriptor {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for KeyDescriptor {}
+          impl binder::parcel::DeserializeOption for KeyDescriptor {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.domain = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.namespace_ = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.alias = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.blob = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod KeyMetadata {
+          pub struct KeyMetadata {
+            pub key: crate::mangled::_7_android_8_security_9_keystore2_13_KeyDescriptor, 
+            pub securityLevel: crate::mangled::_7_android_8_hardware_7_keymint_13_SecurityLevel, 
+            pub hardwareEnforced: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, 
+            pub softwareEnforced: Vec<crate::mangled::_7_android_8_hardware_7_keymint_12_KeyParameter>, 
+          }
+          pub(crate) mod mangled { pub use super::KeyMetadata as _7_android_8_security_9_keystore2_11_KeyMetadata; }
+          impl Default for KeyMetadata {
+            fn default() -> Self {
+              Self {
+                key: Default::default(),
+                securityLevel: Default::default(),
+                hardwareEnforced: Default::default(),
+                softwareEnforced: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for KeyMetadata {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for KeyMetadata {}
+          impl binder::parcel::SerializeOption for KeyMetadata {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.key)?;
+              parcel.write(&this.securityLevel)?;
+              parcel.write(&this.hardwareEnforced)?;
+              parcel.write(&this.softwareEnforced)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for KeyMetadata {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for KeyMetadata {}
+          impl binder::parcel::DeserializeOption for KeyMetadata {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.key = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.securityLevel = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.hardwareEnforced = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.softwareEnforced = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod KeyPermission {
+          #![allow(non_upper_case_globals)]
+          pub type KeyPermission = i32;
+          pub const None: KeyPermission = 0;
+          pub const Delete: KeyPermission = 1;
+          pub const GenUniqueId: KeyPermission = 2;
+          pub const GetInfo: KeyPermission = 4;
+          pub const Grant: KeyPermission = 8;
+          pub const List: KeyPermission = 16;
+          pub const ManageBlob: KeyPermission = 32;
+          pub const Rebind: KeyPermission = 64;
+          pub const ReqForcedOp: KeyPermission = 128;
+          pub const Update: KeyPermission = 256;
+          pub const Use: KeyPermission = 512;
+          pub const UseDevId: KeyPermission = 1024;
+          pub(crate) mod mangled { pub use super::KeyPermission as _7_android_8_security_9_keystore2_13_KeyPermission; }
+        }
+        pub mod OperationChallenge {
+          pub struct OperationChallenge {
+            pub challenge: i64, 
+          }
+          pub(crate) mod mangled { pub use super::OperationChallenge as _7_android_8_security_9_keystore2_18_OperationChallenge; }
+          impl Default for OperationChallenge {
+            fn default() -> Self {
+              Self {
+                challenge: 0,
+              }
+            }
+          }
+          impl binder::parcel::Serialize for OperationChallenge {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for OperationChallenge {}
+          impl binder::parcel::SerializeOption for OperationChallenge {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.challenge)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for OperationChallenge {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for OperationChallenge {}
+          impl binder::parcel::DeserializeOption for OperationChallenge {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.challenge = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod PublicKey {
+          pub struct PublicKey {
+            pub keyMaterial: Vec<u8>, 
+          }
+          pub(crate) mod mangled { pub use super::PublicKey as _7_android_8_security_9_keystore2_9_PublicKey; }
+          impl Default for PublicKey {
+            fn default() -> Self {
+              Self {
+                keyMaterial: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for PublicKey {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for PublicKey {}
+          impl binder::parcel::SerializeOption for PublicKey {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.keyMaterial)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for PublicKey {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for PublicKey {}
+          impl binder::parcel::DeserializeOption for PublicKey {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.keyMaterial = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+        pub mod ResponseCode {
+          #![allow(non_upper_case_globals)]
+          pub type ResponseCode = i32;
+          pub const Ok: ResponseCode = 0;
+          pub const Locked: ResponseCode = 2;
+          pub const Uninitialized: ResponseCode = 3;
+          pub const SystemError: ResponseCode = 4;
+          pub const PermissionDenied: ResponseCode = 6;
+          pub const KeyNotFound: ResponseCode = 7;
+          pub const ValueCorrupted: ResponseCode = 8;
+          pub const WrongPassword: ResponseCode = 10;
+          pub const OpAuthNeeded: ResponseCode = 15;
+          pub const KeyPermanentlyInvalidated: ResponseCode = 17;
+          pub const NoSuchSecurityLevel: ResponseCode = 18;
+          pub const KeymintErrorCode: ResponseCode = 19;
+          pub const BackendBusy: ResponseCode = 20;
+          pub(crate) mod mangled { pub use super::ResponseCode as _7_android_8_security_9_keystore2_12_ResponseCode; }
+        }
+        pub mod Result {
+          pub struct Result {
+            pub rc: crate::mangled::_7_android_8_security_9_keystore2_12_ResponseCode, 
+            pub errorCode: crate::mangled::_7_android_8_hardware_7_keymint_9_ErrorCode, 
+          }
+          pub(crate) mod mangled { pub use super::Result as _7_android_8_security_9_keystore2_6_Result; }
+          impl Default for Result {
+            fn default() -> Self {
+              Self {
+                rc: Default::default(),
+                errorCode: Default::default(),
+              }
+            }
+          }
+          impl binder::parcel::Serialize for Result {
+            fn serialize(&self, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              <Self as binder::parcel::SerializeOption>::serialize_option(Some(self), parcel)
+            }
+          }
+          impl binder::parcel::SerializeArray for Result {}
+          impl binder::parcel::SerializeOption for Result {
+            fn serialize_option(this: Option<&Self>, parcel: &mut binder::parcel::Parcel) -> binder::Result<()> {
+              let this = if let Some(this) = this {
+                parcel.write(&1i32)?;
+                this
+              } else {
+                return parcel.write(&0i32);
+              };
+              let start_pos = parcel.get_data_position();
+              parcel.write(&0i32)?;
+              parcel.write(&this.rc)?;
+              parcel.write(&this.errorCode)?;
+              let end_pos = parcel.get_data_position();
+              let parcelable_size = (end_pos - start_pos) as i32;
+              unsafe { parcel.set_data_position(start_pos)?; }
+              parcel.write(&parcelable_size)?;
+              unsafe { parcel.set_data_position(end_pos)?; }
+              Ok(())
+            }
+          }
+          impl binder::parcel::Deserialize for Result {
+            fn deserialize(parcel: &binder::parcel::Parcel) -> binder::Result<Self> {
+              <Self as binder::parcel::DeserializeOption>::deserialize_option(parcel)
+                 .transpose()
+                 .unwrap_or(Err(binder::StatusCode::UNEXPECTED_NULL))
+            }
+          }
+          impl binder::parcel::DeserializeArray for Result {}
+          impl binder::parcel::DeserializeOption for Result {
+            fn deserialize_option(parcel: &binder::parcel::Parcel) -> binder::Result<Option<Self>> {
+              let status: i32 = parcel.read()?;
+              if status == 0 { return Ok(None); }
+              let start_pos = parcel.get_data_position();
+              let parcelable_size: i32 = parcel.read()?;
+              if parcelable_size < 0 { return Err(binder::StatusCode::BAD_VALUE); }
+              let mut result = Self::default();
+              result.rc = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              result.errorCode = parcel.read()?;
+              if (parcel.get_data_position() - start_pos) >= parcelable_size {
+                unsafe { parcel.set_data_position(start_pos + parcelable_size)?; }
+                return Ok(Some(result));
+              }
+              Ok(Some(result))
+            }
+          }
+        }
+      }
+    }
+  }
+}
+pub mod mangled {
+  pub use super::aidl::android::security::keystore2::AuthenticatorSpec::mangled::*;
+  pub use super::aidl::android::security::keystore2::Certificate::mangled::*;
+  pub use super::aidl::android::security::keystore2::CertificateChain::mangled::*;
+  pub use super::aidl::android::security::keystore2::Domain::mangled::*;
+  pub use super::aidl::android::security::keystore2::IKeystoreOperation::mangled::*;
+  pub use super::aidl::android::security::keystore2::IKeystoreSecurityLevel::mangled::*;
+  pub use super::aidl::android::security::keystore2::IKeystoreService::mangled::*;
+  pub use super::aidl::android::security::keystore2::KeyDescriptor::mangled::*;
+  pub use super::aidl::android::security::keystore2::KeyMetadata::mangled::*;
+  pub use super::aidl::android::security::keystore2::KeyPermission::mangled::*;
+  pub use super::aidl::android::security::keystore2::OperationChallenge::mangled::*;
+  pub use super::aidl::android::security::keystore2::PublicKey::mangled::*;
+  pub use super::aidl::android::security::keystore2::ResponseCode::mangled::*;
+  pub use super::aidl::android::security::keystore2::Result::mangled::*;
+  pub(crate) use android_hardware_keymint::mangled::*;
+}
\ No newline at end of file
