2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
外部時刻の検出
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android 12 以降では、必要に応じて外部のタイムソースを使用して 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
を使って外部オリジンを設定し、それよりも優先度の高い時刻の提案がない場合は、このメソッドに渡されるタイムスタンプを使用して現在の Unix エポック時刻を設定します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-03-26 UTC。
[[["わかりやすい","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"]],["最終更新日 2025-03-26 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."]]