IviServiceConnectionManagerImpl

The IVI service connection managers.

An IVI service connection manager manages the connection of a service interface instance identified by the iviInstanceId and serviceId.

<Interface>Api class instances can observe the connection of type C. As long as connection is observed by an active LifecycleOwner owner, the IVI service host manager will try to establish the connection.

connection is set when the IVI service host manager provide the connection data D. The IVI service host managers provides D when the connection has been established by calling onServiceConnectionAvailable. C is created through IviServiceInterfaceRegistration.connectionFactory of the serviceInterfaceRegistration. C is parameterized by the properties class P and a properties observer interface PO.

The manager keeps a cache of the IVI service interface properties. This cache is updated after a new connection is available and when the IVI service's serviceReady property is set to true. The cache is also updated on any following property changes. The caches are live data properties as such clients can observe the property changes.

serviceAvailable is set to true after the property cache is updated and set to false when either the connection is lost or when the IVI service's serviceReady property is set to false.

On disconnect, the IVI service connection manager is responsible to set the mutableConnection property to null.

Parameters

C

The <Interface>Connection interface implementation.

D

The connection data class for this connection.

P

The <Interface>Properties class.

PO

The <Interface>PropertiesObserver interface.

LP

The <Interface>LiveDataProperties class.

iviInstanceId

The IVI instance ID.

lifecycleOwner

The lifecycle owner of this service connection manager.

serviceInterfaceRegistration

The interface registration entry of this connection.

liveDataPropertiesFactory

Factory for LP.

onConnectionRequestedChangedHandler

Invoked when connectionRequested changes.

onConnectionExceptionHandler

Invoked when connecting throws an exception.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
interface IviServiceConnectionManagerImplEvents : TraceEventListener

Properties

Link copied to clipboard
open override val cachedProperties: LP

Mirror cache of the properties of the IVI service interface. The properties are LiveData properties.

Link copied to clipboard
open override val connection: LiveData<C?>

LiveData containing the connection, if any.

Link copied to clipboard
open override val connectionManager: IviServiceConnectionManager<C, LP>

The service connection manager that manages the connection for the service interface as specified by the serviceInterfaceRegistration.

Link copied to clipboard
open override var connectionRequested: Boolean = false

True when a connection is requested by an <Interface>Api instance.

Link copied to clipboard
open override val iviInstanceId: IviInstanceId?
Link copied to clipboard
val lifecycleOwner: LifecycleOwner
Link copied to clipboard
val onConnectionRequestedChangedHandler: (Boolean) -> Unit
Link copied to clipboard
open override val serviceAvailable: LiveData<Boolean>

Whether the service interface is available.

Link copied to clipboard
val serviceId: IviServiceId
Link copied to clipboard
open override val serviceInterfaceRegistration: IviServiceInterfaceRegistration<C, D, P, PO, LP>
Link copied to clipboard
val serviceStatus: IviServiceStatus

The current status.

Functions

Link copied to clipboard
fun onServiceConnectionAvailable(iviServiceConnectionData: IviServiceConnectionData)

Called when a connection is available.

Link copied to clipboard
fun onServiceConnectionUnavailable(): suspend () -> Unit

Called when the connection is unavailable.