Android Automotive secondary displays¶
An Android Automotive OS emulator can have more than one display, such as a passenger screen. This page covers driving an app on one of them. For setting up the emulator, see Android Automotive OS emulators.
Choosing a display¶
To drive an app on another display, such as a passenger screen, pass display to observe, tapOn
and pressButton. Its value is a panel key, a role or active. You can also pin it once for the
session with setActiveDevice display. An explicit display, including active, overrides the pin.
Pressing buttons¶
For pressButton:
- It sends the key to that display and checks that display for the visual change.
displayonpressButtonis Android only. activemeans the focused display, not the display you last observed explicitly. The focused display is the one the latestobservewithoutdisplayor a pin read. Before any such read, it is the display that holds input focus, or the main display when focus is unknown.- A
backthat finds a Car App Library template there taps the host’s Back control on the same display. - A
homethat changes nothing because that display already shows its launcher succeeds, as it does on the default display. - System actions (such as
lockorquick_settings) and rotary input still act device-wide;displayonly picks the display that AutoMobile checks. - The session pin does not apply to
lock,power,power_dialog,volume_up,volume_downor rotary buttons. They act on the whole device, so they work even when the pinned display is gone. - Without
displayor a pin,pressButtonpresses on the default display.
Creating a public display¶
On an emulator, create the extra display as public: the last field of -multidisplay must be 1, for
example -multidisplay 1,1280,720,160,1. Android accessibility does not track a private virtual
display (0), so it has no view hierarchy. The observe call refuses it with an error that names the display
as private and gives its logical display id. Retrying does not help; recreate the display as public.