IviServiceHostConfig

data class IviServiceHostConfig(val serviceHostBuilderName: String, val implementationModule: ModuleReference, val interfaces: List<IviServiceInterfaceConfig>, val dependencies: IviServiceDependencies = IviServiceDependencies(), val tags: List<String> = emptyList(), val subPackageName: String? = null, val singleUser: Boolean = false) : Serializable

Defines the implementation and the IVI service interfaces of an IVI service host.

Reference to <ServiceHostBuilderName> class

The serviceHostBuilderName, implementationModule and subPackageName properties are used to refer to the builder class of the service host. The builder class is expected to be defined with the fully qualified class name: <package-of-implementationModule>[.<subPackageName>].<ServiceHostBuilderName>. The builder class needs to implement the IviServiceHostBuilder interface and must have a constructor without parameters.

Example

A builder class in a module with the name "platform_framework_functionaltest_ipc_exampleserviceplugin":

package com.tomtom.ivi.platform.framework.functionaltest.ipc.exampleserviceplugin

...

class ExampleServiceHostBuilder : IviServiceHostBuilder() {
override fun build(iviServiceHostContext: IviServiceHostContext) =
SimpleIviServiceHost(
listOf(
TestExampleService(iviServiceHostContext),
...
)
)
}

This corresponds to the following IviServiceHostConfig:

IviServiceHostConfig(
serviceHostBuilderName = "ExampleServiceHostBuilder",
implementationModule = ModuleReference(
groupName = "com.tomtom.ivi.platform"
moduleName = "platform_framework_functionaltest_ipc_exampleserviceplugin"
packageName = "com.tomtom.ivi.platform.framework.functionaltest.ipc.exampleserviceplugin"
)
...
)

The ModuleReference class is open for extension. If some parts of the module reference parameters can be derived, define and use a subclass to simplify the configuration. For instance, an IviPlatformModuleReference, subclass of ModuleReference, can derive the package name from the module name for all TomTom Digital Cockpit platform modules.

As such the above example can be simplified to:

IviServiceHostConfig(
serviceHostBuilderName = "ExampleServiceHostBuilder",
implementationModule = IviPlatformModuleReference(
"platform_framework_functionaltest_ipc_exampleserviceplugin"
)
...
)

Service host interfaces

The service interface implemented by the service host needs to be configured to allow the service host to be registered. A service host needs to have at least one interface.

Example

val exampleServiceHost = IviServiceHostConfig(
serviceHostBuilderName = "ExampleServiceHostBuilder",
...
interfaces = listOf(
IviServiceInterfaceConfig(
serviceName = "ExampleService",
serviceApiModule = IviPlatformModuleReference(
"platform_framework_functionaltest_ipc_exampleserviceapi"
)
),
...
),
...
)

This defines that the ExampleServiceHostBuilder builds a host that implements the com.tomtom.ivi.platform.framework.functionaltest.ipc.exampleserviceapi.ExampleService interface. The package name here is derived from the module name.

To register a discoverable service interface (a service interface annotated with the IviDiscoverableService annotation), the IviServiceInterfaceConfig.serviceId needs to be defined.

Dependencies

A service host implementation can require other IVI service interfaces to be registered. The dependencies property can be used to define those interface. This allows misconfiguration to be detected at build time.

Optional tags

A host config can have one or more tags. The tags can be used to selectively configure the deployment of hosts based on the tag. See IviServiceHostMatcher.

Parameters

serviceHostBuilderName

The name of the service host builder class that must be formatted in PascalCase and must end with the "ServiceHostBuilder" suffix. The suffix is mandatory to allow the configuration to be found easier when searching the code base.

implementationModule

The module that implements the service host and contains the builder class.

interfaces

The service interface of the service host.

dependencies

The service interface dependencies of the service host implementation.

tags

Optional tags.

subPackageName

Optional sub package. If not null, this value is appended to the ModuleReference.packageName of the implementationModule property with a period in between.

singleUser

If true, Android will instantiate that service host in a process running as user 0 only. Any requests to connect to this service host, from any user will be routed to the process in user 0. If false, the service host will run in a process specific for each user. See Building Multiuser-Aware Apps for more information.

Constructors

Link copied to clipboard
constructor(serviceHostBuilderName: String, implementationModule: ModuleReference, interfaces: List<IviServiceInterfaceConfig>, dependencies: IviServiceDependencies = IviServiceDependencies(), tags: List<String> = emptyList(), subPackageName: String? = null, singleUser: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val singleUser: Boolean = false
Link copied to clipboard
val subPackageName: String? = null
Link copied to clipboard