diff --git a/app/src/main/java/org/matrix/TEESimulator/interception/core/BinderInterceptor.kt b/app/src/main/java/org/matrix/TEESimulator/interception/core/BinderInterceptor.kt index ba7d43b..7a1a5ff 100644 --- a/app/src/main/java/org/matrix/TEESimulator/interception/core/BinderInterceptor.kt +++ b/app/src/main/java/org/matrix/TEESimulator/interception/core/BinderInterceptor.kt @@ -41,7 +41,7 @@ abstract class BinderInterceptor : Binder() { * Skips the original call and immediately returns a custom reply parcel to the caller. The * provided parcel will be recycled after use. */ - data class OverrideReply(val code: Int = 0, val reply: Parcel) : TransactionResult() + data class OverrideReply(val reply: Parcel, val code: Int = 0) : TransactionResult() /** * Modifies the transaction's input data before forwarding it to the original binder method. diff --git a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/InterceptorUtils.kt b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/InterceptorUtils.kt index c793de2..df3b335 100644 --- a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/InterceptorUtils.kt +++ b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/InterceptorUtils.kt @@ -52,7 +52,7 @@ object InterceptorUtils { writeInt(KeyStore.NO_ERROR) } } - return BinderInterceptor.TransactionResult.OverrideReply(0, parcel) + return BinderInterceptor.TransactionResult.OverrideReply(parcel) } /** Creates an `OverrideReply` parcel containing a raw byte array. */ @@ -62,7 +62,7 @@ object InterceptorUtils { writeNoException() writeByteArray(data) } - return BinderInterceptor.TransactionResult.OverrideReply(KeyStore.NO_ERROR, parcel) + return BinderInterceptor.TransactionResult.OverrideReply(parcel) } /** Creates an `OverrideReply` parcel containing a Parcelable object. */ @@ -75,7 +75,7 @@ object InterceptorUtils { writeNoException() writeTypedObject(obj, flags) } - return BinderInterceptor.TransactionResult.OverrideReply(0, parcel) + return BinderInterceptor.TransactionResult.OverrideReply(parcel) } /** diff --git a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt index 7f4f940..46ca111 100644 --- a/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt +++ b/app/src/main/java/org/matrix/TEESimulator/interception/keystore/shim/KeyMintSecurityLevelInterceptor.kt @@ -168,12 +168,7 @@ class KeyMintSecurityLevelInterceptor( if (isAttestKeyRequest) attestationKeys.add(keyId) // Return the metadata of our generated key, skipping the real hardware call. - val resultParcel = - Parcel.obtain().apply { - writeNoException() - writeTypedObject(response.metadata, 0) - } - return TransactionResult.OverrideReply(0, resultParcel) + return InterceptorUtils.createTypedObjectReply(response.metadata) } else if (parsedParams.attestationChallenge != null) { return TransactionResult.Continue }