HostValidator


class HostValidator


Validates that the calling package is authorized to connect to a CarAppService.

Host are expected to either hold android.car.permission.TEMPLATE_RENDERER privileged permission, or be included in the allow-listed set of hosts, identified by their signatures.

Summary

Nested types

Builder of HostValidator.

Constants

const HostValidator

A host validator that doesn't block any hosts.

const String!
TEMPLATE_RENDERER_PERMISSION = "android.car.permission.TEMPLATE_RENDERER"

System permission used to identify valid hosts (only used by hosts running on Android API level 31 or later).

Public functions

(Mutable)Map<String!, (Mutable)List<String!>!>

Returns a map from package name to signature digests of each of the allowed hosts.

Boolean
isValidHost(hostInfo: HostInfo)

Returns whether the given host is allowed to bind to this client.

Constants

ALLOW_ALL_HOSTS_VALIDATOR

Added in 1.0.0
const val ALLOW_ALL_HOSTS_VALIDATORHostValidator

A host validator that doesn't block any hosts.

This is intended to be used only during development.

TEMPLATE_RENDERER_PERMISSION

Added in 1.0.0
const val TEMPLATE_RENDERER_PERMISSION = "android.car.permission.TEMPLATE_RENDERER": String!

System permission used to identify valid hosts (only used by hosts running on Android API level 31 or later). Other hosts must be allow-listed using addAllowedHost or addAllowedHosts

Public functions

getAllowedHosts

Added in 1.0.0
fun getAllowedHosts(): (Mutable)Map<String!, (Mutable)List<String!>!>

Returns a map from package name to signature digests of each of the allowed hosts.

isValidHost

Added in 1.0.0
fun isValidHost(hostInfo: HostInfo): Boolean

Returns whether the given host is allowed to bind to this client.