Ensure mocked replies use native OK status (#60)
Corrects a bug where the native binder `status_t` was being set to application-level error codes (e.g., `KeyStore.NO_ERROR` which is 1). Moreover, we call method `InterceptorUtils.createTypedObjectReply` to keep the code style consistent.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-6
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user