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 lifecycleOwnerLifecycle is destroyed.

Link copied to clipboard
val killableLifecycleOwner: KillableLifecycleOwner

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

Link copied to clipboard
val mainCoroutineScope: CoroutineScope

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

Link copied to clipboard
val sequencerReceiverHelper: SequencerReceiverHelper

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
val sequencerSenderHelper: SequencerSenderHelper

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.