GNSS Zaman Tespiti

Android 12'den itibaren Android, Unix dönem zamanlarını time_detector hizmetine önermek için isteğe bağlı olarak Küresel Navigasyon Uydu Sistemini (GNSS) kullanabilir. Bu, AOSP'de varsayılan olarak etkin değildir.

GNSS zaman tespiti etkinleştirildiğinde, gnss_time_update_service pasif olarak GNSS kaynaklarından gelen konum güncellemelerini dinler ve GNSS önerilerini time_detector hizmetine gönderir. time_detector hizmeti daha sonra sistem saatinin öneriyle eşleşecek şekilde güncellenip güncellenmeyeceğini belirler.

Güç kullanımına etkisi

AOSP gnss_time_update_service konum güncellemelerini pasif olarak dinler. Bu, hiçbir zaman GPS'i aktif olarak açmadığı veya ek güç tüketmediği anlamına gelir. Bu aynı zamanda sistemdeki başka bir uygulama veya hizmet aktif olarak konum güncellemeleri talep etmediği sürece gnss_time_update_service konum güncellemesi almayacağı ve bir GNSS zamanı önermeyeceği anlamına da gelir.

Uygulama

GNSS zaman tespitini etkinleştirmek için cihaz üreticilerinin sistem sunucusunda gnss_time_update_service açıkça etkinleştirmesi gerekir.

Bu özelliğin etkinleştirilmesi için core/res/res/values/config.xml dosyasındaki hem config_enableGnssTimeUpdateService hem de config_autoTimeSourcesPriority değerlerinin güncellenmesi gerekir. config_enableGnssTimeUpdateService değerini true olarak ayarlayın ve config_autoTimeSourcesPriority için öğe listesine gnss ekleyin. gnss öncelik listesindeki konumu, GNSS önerilerine diğer kaynaklardan gelen önerilere göre verilen önceliği belirler.

Aşağıda GNSS zaman tespitinin etkinleştirildiği ve gnss network ve telephony sonra öncelik listesinde üçüncü olduğu örnek core/res/res/values/config.xml dosyası bulunmaktadır.

<!-- 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>

Hata ayıklama ve test etme

GNSS zaman tespitini test etmek için adb shell cmd location komutlarını kullanabilirsiniz. Bir konumu ve ilgili GNSS zamanını belirtebileceğiniz test konumu sağlayıcılarını eklemek için bu komutları kullanın. gnss_time_update_service bu konum güncellemelerini dinler ve periyodik olarak önerilerde bulunur.

Aşağıda adb shell cmd location komutlarının örnekleri gösterilmektedir:

# 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 UID
adb 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 provider
adb 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