sendAndWaitForReply

suspend fun <R> sendAndWaitForReply(    descriptor: String,     block: (Parcel, Parcel) -> Unit,     asyncReplyHandler: (Parcel) -> R): R

Utility function allowing clients to send a parcel to a server and wait for asynchronously reply.

The utility function suspends the coroutine until the asynchronous reply is received.

The binder transaction to send the parcel to a server is synchronous. To prevent blocking the calling thread on this transaction, the transaction is sent from the BinderContext.syncBinderTransactionScope. When this fails due to an exception the calling coroutine is resumed with this exception.

Return

The asynchronous reply.

Parameters

R

The return type of the calling coroutine function.

descriptor

The interface name. This is used to validate that the marshalled transaction is intended for the target interface.

block

Invoked on BinderContext.syncBinderTransactionScope to add data to the parcel and perform the normal binder transaction.

asyncReplyHandler

Invoked on a binder thread pool thread to read R from the async reply message.