HostValidator
public final 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.
| See also | |
|---|---|
HostValidator.Builder |
Summary
Nested types |
|---|
public final class HostValidator.BuilderBuilder of |
Constants |
|
|---|---|
static final @NonNull HostValidator |
A host validator that doesn't block any hosts. |
static final 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 methods |
|
|---|---|
@NonNull Map<String, List<String>> |
Returns a map from package name to signature digests of each of the allowed hosts. |
boolean |
isValidHost(@NonNull HostInfo hostInfo)Returns whether the given host is allowed to bind to this client. |
Constants
ALLOW_ALL_HOSTS_VALIDATOR
public static final @NonNull HostValidator ALLOW_ALL_HOSTS_VALIDATOR
A host validator that doesn't block any hosts.
This is intended to be used only during development.
| See also | |
|---|---|
createHostValidator |
TEMPLATE_RENDERER_PERMISSION
public static final 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). Other hosts must be allow-listed using addAllowedHost or addAllowedHosts
Public methods
getAllowedHosts
public @NonNull Map<String, List<String>> getAllowedHosts()
Returns a map from package name to signature digests of each of the allowed hosts.
isValidHost
public boolean isValidHost(@NonNull HostInfo hostInfo)
Returns whether the given host is allowed to bind to this client.