Effective in 2026, to align with our trunk stable development model and ensure platform stability for the ecosystem, we will publish source code to AOSP in Q2 and Q4. For building and contributing to AOSP, use android-latest-release. The android-latest-release manifest branch will always reference the most recent release pushed to AOSP. For more information, see Changes to AOSP.
外部时间检测
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
从 Android 12 开始,Android 可以选择使用外部时间源向 time_detector 服务提供 Unix 纪元时间建议。此功能在 AOSP 中默认处于停用状态。
通过使用外部时间来源,设备制造商可以向 Android 提供完全自定义的时间建议。收到外部时间来源的建议后,time_detector 服务会使用配置的优先级规则来确定是否更新系统时钟。
实现
如需支持外部时间检测,设备制造商必须实现一个组件来通过系统 API 调用向 time_detector 服务提交外部时间建议。
如需配置外部时间来源,请使用 core/res/res/values/config.xml 系统服务器配置文件。将值 external 添加到 config_autoTimeSourcesPriority。
以下示例会指示 Android 在设置系统时钟时,为外部时间建议提供最高优先级。如果没有有效的外部时间建议,则使用下一个来源(在本例中为 gnss)的值。
<string-array name="config_autoTimeSourcesPriority">
<item>external</item>
<item>gnss</item>
</string-array>
如需为系统提供外部时间建议,请使用 TimeManager 中的 suggestExternalTime() 方法。如果在配置文件中使用 config_autoTimeSourcesPriority 配置了外部时间源站,并且没有更高优先级的时间建议,则 Android 会使用传递给此方法的时间戳来设置当前 Unix 纪元时间。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[]]