Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
External time detection
Stay organized with collections
Save and categorize content based on your preferences.
Starting in Android 12, Android can optionally use an external source of time to
suggest Unix epoch times to the Time Detector service. This isn't enabled
by default in AOSP.
The external time origin lets you provide completely custom time suggestions
to Android. After receiving suggestions from the external time origin, the
time_detector
service determines whether to update the system clock based on
the configured automatic time prioritization rules.
Implementation
To support external time detection, you must implement a component that submits
external time suggestions to the time_detector
service through a system API
call.
To configure the external origin, use the core/res/res/values/config.xml
system server configuration file. Add the value external
to
config_autoTimeSourcesPriority
.
The following example tells Android to give external time suggestions the
highest priority when setting the system clock. If there is no valid external
time suggestion available then the next origin, gnss
in this case, is used:
<string-array name="config_autoTimeSourcesPriority">
<item>external</item>
<item>gnss</item>
</string-array>
To provide the system with an external time suggestion, use the
suggestExternalTime
method in TimeManager
. If the external origin is
configured using config_autoTimeSourcesPriority
in the configuration file and
no higher priority time suggestions are available, Android uses the timestamp
passed to this method to set the current Unix epoch time.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-09-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[],[],null,["From Android 12, Android can optionally use an external\nsource of time to suggest Unix epoch times to the [`time_detector`](/docs/core/connect/time#time_detector-service) service.\nThis isn't enabled by default in AOSP.\n\nThe *external* time origin allows device manufacturers to provide completely\ncustom time suggestions to Android. After receiving suggestions from the\nexternal time origin, the `time_detector` service determines whether to update\nthe system clock using the configured [prioritization rules](/docs/core/connect/time#automatic-time).\n\nImplementation\n\nTo support external time detection, device manufacturers must implement a\ncomponent that submits external time suggestions to the `time_detector` service\nthrough a system API call.\n\nTo configure the external origin, use the `core/res/res/values/config.xml`\nsystem server configuration file. Add the value `external` to\n`config_autoTimeSourcesPriority`.\n\nThe following example tells Android to give external time suggestions the\nhighest priority when setting the system clock. If there is no valid external\ntime suggestion available then the next origin, `gnss` in this case, is used. \n\n \u003cstring-array name=\"config_autoTimeSourcesPriority\"\u003e\n \u003citem\u003eexternal\u003c/item\u003e\n \u003citem\u003egnss\u003c/item\u003e\n \u003c/string-array\u003e\n\nTo provide the system with an external time suggestion, use the\n[`suggestExternalTime()`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/core/java/android/app/time/TimeManager.java?q=%22void%20suggestExternalTime%22) method in `TimeManager`. If the external origin is\nconfigured using `config_autoTimeSourcesPriority` in the configuration file and\nno higher priority time suggestions are available, Android uses the timestamp\npassed to this method to set the current Unix epoch time."]]