Android 12以降、Androidはオプションでグローバルナビゲーション衛星システム(GNSS)を使用して、 time_detectorサービスにUnixエポック時間を提案できます。これは、AOSPではデフォルトで有効になっていません。
 GNSS時間検出が有効になっている場合、 gnss_time_update_serviceはGNSSソースからの位置更新を受動的にリッスンし、GNSS提案をtime_detectorサービスに送信します。次に、 time_detectorサービスは、提案に一致するようにシステムクロックを更新するかどうかを決定します。
電力使用量への影響
AOSP gnss_time_update_serviceは、位置情報の更新を受動的にリッスンします。これは、GPSをアクティブにオンにしたり、追加の電力を消費したりしないことを意味します。これは、システム内の別のアプリまたはサービスが位置情報の更新をアクティブに要求していない限り、 gnss_time_update_serviceが位置情報の更新を取得せず、GNSS時刻を提案しないことも意味します。
実装
GNSS時間検出を有効にするには、デバイスメーカーは、システムサーバーでgnss_time_update_serviceを明示的に有効にする必要があります。
この機能を有効にするには、 core/res/res/values/config.xml /config.xmlファイルのconfig_enableGnssTimeUpdateServiceとconfig_autoTimeSourcesPriorityの両方の値を更新する必要があります。 config_enableGnssTimeUpdateServiceの値をtrueに設定し、 config_autoTimeSourcesPriorityのアイテムリストにgnssを追加します。優先順位リスト内のgnssの位置によって、他のソースからの提案に対してGNSS提案に与えられる優先順位が決まります。
以下は、 core/res/res/values/config.xmlファイルの例です。ここでは、GNSS時間検出が有効になっており、 gnssはnetworkとtelephonyに次ぐ優先順位リストの3番目です。
<!-- 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>network</item>
        <item>telephony</item>
        <item>gnss</item>
    </string-array>
    <!-- Enables the GnssTimeUpdate service. This is the global switch for enabling Gnss time based
         suggestions to TimeDetector service. See also config_autoTimeSourcesPriority. -->
    <bool name="config_enableGnssTimeUpdateService">true</bool>
デバッグとテスト
 GNSS時間検出をテストするには、 adb shell cmd locationコマンドを使用できます。これらのコマンドを使用して、場所と関連するGNSS時間を指定できるテスト場所プロバイダーを追加します。 gnss_time_update_serviceはこれらの位置情報の更新をリッスンし、定期的に提案を行います。
次に、 adb shell cmd locationコマンドの例を示します。
# Enable Master Location Switch in the foreground user (usually user 10 on automotive). If you just flashed, this can be done through setup wizard.adb shell cmd location set-location-enabled true --user 10# Add GPS test provider (This usually fails the first time. Will throw a SecurityException with "android from <SOME_UID> not allowed to perform MOCK_LOCATION".)adb shell cmd location providers add-test-provider gps# Enable mock location permissions for previous UIDadb shell appops set UID_PRINTED_IN_PREVIOUS_ERROR android:mock_location allow# Add GPS test provider (Should work with no errors.)adb shell cmd location providers add-test-provider gps# Enable GPS test provideradb shell cmd location providers set-test-provider-enabled gps true# Set location with time (Time can't be lower than the limit set by the lower bound.)adb shell cmd location providers set-test-provider-location gps --location LATITUDE,LONGITUDE --time TIME