# ClusterHomeSample
`ClusterHomeSample` is a sample reference application that runs on the cluster display.
It uses `ClusterHomeManager` API (a.k.a. Cluster2) to interact with the CarService.
It supports both the FULL mode and the LIGHT mode. However, in actual production cases,
the cluster service supports one specific mode, thus the actual cluster application
only needs to run in one specific mode.
## CarService Configuration
In order to enable `ClusterHomeService`, remove `cluster_service` from
`config_allowed_optional_car_features` and add `cluster_home_service`,
in the RRO configuration of the CarService.
```
...
- cluster_home_service
...
```
Set `config_clusterHomeServiceMode` to select what mode the `ClusterHomeService` to run in.
```
0
```
`config_clusterHomeActivity` sets the activity that runs on the cluster display.
Note that the activity specified here will run as the system user,
thus the activity's `showForAllUsers` attribute must be set to `true`
in the application's `AndroidManifest.xml` file.
```
com.android.car.cluster.home/.ClusterHomeActivity
```
The followings are used by the `ClusterHomeManager#startVisibilityMonitoring(Activity)` method
to configure parameters for visibility monitoring.
```
100%
99.9%
100
```
## Application Configuration
### `directBootAware`
A cluster application needs to be able to start regardless of user unlocked state.
Therefore `dirctBootAware` must be set to `true` in the application's `AndroidManifest.xml`.
```
```
See https://developer.android.com/privacy-and-security/direct-boot
for more information on `directBootAware`.
### `showForAllUsers`
For the activities that run as the system user, the `showForAllUsers`
attribute must be set to `true` in the `AndroidManifest.xml` file.
```
```
See https://developer.android.com/guide/topics/manifest/activity-element#showForAllUsers
for more information on `showForAllUsers`.
## FULL mode
The cluster application makes full use of the `ClusterHomeManager` APIs in the FULL mode.
It starts with the `UI_TYPE_HOME` activity running as user 0, and switches to `UI_TYPE_START`
activity when the current user is unlocked. It can switch to other UI activity types
(e.g. `UI_TYPE_MAPS`, `UI_TYPE_PHONE`, etc.) as necessary.
See `ClusterHomeActivity` for more details.
To run `ClusterHomeService` in the FULL mode, the device needs to have
all the following VHAL properties defined:
- `CLUSTER_SWITCH_UI`
- `CLUSTER_REPORT_STATE`
- `CLUSTER_DISPLAY_STATE`
- `CLUSTER_REQUEST_DISPLAY`
If the service is configured for the FULL mode but any of the above properties is not defined,
`ClusterHomeManager` API will throw an `IllegalStateException`.
## LIGHT mode
In the LIGHT mode, it stays as the `UI_TYPE_HOME` activity that runs as user 0.
`ClusterHomeManager#startVisibilityMonitoring` and `ClusterHomeManager#sendHeartbeat` are
used in the LIGHT mode. The device must implement `CLUSTER_HEARTBEAT` VHAL property
to be able to use these API.
See `ClusterHomeActivityLightMode` for a sample implementation.