BinderContext

class BinderContext(lifecycleOwner: LifecycleOwner, val messageDispatchFailureListener: BinderMessageDispatchFailureListener, val syncBinderTransactionScope: CoroutineScope? = null)

Groups some properties that are needed in the binder interface implementations.

Parameters

lifecycleOwner

The lifecycle owner of the binder interface.

messageDispatchFailureListener

Called on message dispatch failures.

syncBinderTransactionScope

Scope to use for performing sync binder transaction to start functions with a async reply. May be null when the binder interface does not perform such binder transactions.

Constructors

Link copied to clipboard
fun BinderContext(lifecycleOwner: LifecycleOwner, messageDispatchFailureListener: BinderMessageDispatchFailureListener, syncBinderTransactionScope: CoroutineScope? = null)

Properties

Link copied to clipboard
val ioCoroutineScope: CoroutineScope

CoroutineScope for running coroutines on an IO thread. The scope is cancelled when the lifecycleOwner Lifecycle is destroyed.

Link copied to clipboard

A LifecycleOwner that shadows the lifecycleOwner Lifecycle, which is destroyed when KillableLifecycleOwner.invokeDeathSafe catches a DeadObjectException.

Link copied to clipboard
val mainCoroutineScope: CoroutineScope

CoroutineScope tied to the lifecycleOwner Lifecycle. The coroutines run on the main thread and are cancelled when the lifecycleOwner Lifecycle is destroyed.

Link copied to clipboard

Binder transactions are handled on the the binder thread pool. As such, one way transactions sent by a sender can be handled out of sequence. It just depends on the scheduling. The SequencerReceiverHelper helps solving this issue by posting actions on a thread or by resuming Continuations in sequence as sent by the sender based on a sequence ID.

Link copied to clipboard

The counter part of the SequencerReceiverHelper on the sender side for adding sequence IDs to the transactions.

Link copied to clipboard
val syncBinderTransactionScope: CoroutineScope? = null

Functions

Link copied to clipboard
inline fun <R> withMessageDispatchFailureListener(interfaceDescriptor: String, transactionName: String, block: () -> R): R

Calls BinderMessageDispatchFailureListener.onFailure when block throws an Exception. Any caught exception is rethrown.