Configure AAOS time sources

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-only EXTERNAL_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 in core/res/res/values/config.xml.
  • The config_enableExternalCarTimeToExternalTimeSuggestion property in the CarServices overlay configs packages/services/Car/service/res/values/config.xml is set to true.
  • external time has the appropriate priority in the TimeDetectorStrategy 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:

  1. TimeHalService (in CarServices) receives a broadcast from the Android system for Intent.ACTION_TIME_CHANGED.
  2. TimeHalService publishes an update to the VHAL Property ANDROID_EPOCH_TIME.
  3. 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:

  1. VHAL updates the EXTERNAL_CAR_TIME property.
  2. TimeHalService (in CarServices) reads the property through a subscription.
  3. TimeHalService creates and sends an ExternalTimeSuggestion to TimeManager.
  4. TimeManager forwards the suggestion to TimeDetectorService.
  5. TimeDetectorService uses TimeDetectorStrategy to choose a new system time.