Key input

Based on the Vehicle HAL property VEHICLE_PROPERTY_HW_KEY_INPUT, defined in hardware/libhardware/include/hardware/vehicle.h, Android Automotive handles key input from elements that include steering remote switches, hardware buttons, and touch panels.

For example, dispatch of a key event over a CAN bus network:

Key event

Figure 1. Android Automotive key events over CANbus flow.

Key event data

The following data is attached to each key event in the Vehicle HAL:

  • Input action (up/down):
  • Key code mapped to Android keys in a partner implementation of the Vehicle HAL.
  • Target display (main/instrument cluster):
    VEHICLE_DISPLAY_MAIN               = 0,

The key input handling in the instrument cluster uses CarInputService (the same service uses for the regular input handling in the vehicle). Key events get propagated to the InstrumentClusterRenderingService:

public class MyClusterRenderingService extends
InstrumentClusterRenderingService {
    @Override protected void onKeyEvent(KeyEvent keyEvent) { /* Inject to
    Presentation? */ }