This feature enables partners to choose how to synchronize time, whether from the Android Automotive Operating System (AAOS) or from vehicular systems to Android. To ensure quality implementations, you can configure AAOS to use one of the two new VHAL properties described below to propagate the values effectively. Use:
ANDROID_EPOCH_TIME
to use Android as the source of truth for time. The VHAL supports this write-only property, which communicates time changes from Android to other vehicular systems, such as the Electronic Control Units (ECU) and the Body Control Module (BCM).EXTERNAL_CAR_TIME
to not use Android as the source of truth for time. In this case, the VHAL supports the read-onlyEXTERNAL_CAR_TIME
property, which communicates time changes from other vehicular systems (such as ECUs and BCM) to Android.
AAOS also provides a configurable TimeDetectorStrategy
to help you prioritize
different time sources within Android.
Android is the source of truth for time
When Android is used as the source of time, OEMs can synchronize other car systems (including ECUs and a BCM) with Android time.
To do so, the VHAL implementation must support the write-only property
ANDROID_EPOCH_TIME
property. Android publishes an update to the property by reading
system time, both at boot time and whenever the time source in Android is changed.
Android is not the source of truth for time
When Android is not used as the source of time, you can synchronize Android time
to be the source of truth for time (for example, with an ECU or the BCM). In this case, the
VHAL implementation must support the read-only property EXTERNAL_CAR_TIME
and publish
updates to this property whenever the source of time changes or recalibrates the clock.
OEMs must also ensure that:
- The
config_autoTimeSourcesPriority
values are contained incore/res/res/values/config.xml
. - The
config_enableExternalCarTimeToExternalTimeSuggestion
property in the CarServices overlay configspackages/services/Car/service/res/values/config.xml
is set totrue
. external
time has the appropriate priority in theTimeDetectorStrategy
configuration. To learn more, see GNSS Time Detection. For example:<!-- Specifies priority of automatic time sources. Suggestions from higher entries in the list take precedence over lower ones. See com.android.server.timedetector.TimeDetectorStrategy for available sources. --> <string-array name="config_autoTimeSourcesPriority"> <item>external</item> <item>gnss</item> <item>network</item> <item>telephony</item> </string-array>
Android internal implementation details
The following flow takes place when the ANDROID_EPOCH_TIME
VHAL property is
supported:
TimeHalService
(in CarServices) receives a broadcast from the Android system forIntent.ACTION_TIME_CHANGED
.TimeHalService
publishes an update to the VHAL PropertyANDROID_EPOCH_TIME
.- The VHAL can propagate the time value received to various ECUs and/or BCM units.
The following flow takes place when the EXTERNAL_CAR_TIME
VHAL property is
supported:
- VHAL updates the
EXTERNAL_CAR_TIME
property. TimeHalService
(in CarServices) reads the property through a subscription.TimeHalService
creates and sends anExternalTimeSuggestion
toTimeManager
.TimeManager
forwards the suggestion toTimeDetectorService
.TimeDetectorService
usesTimeDetectorStrategy
to choose a new system time.