זיהוי זמן GNSS

מ-Android 12, אנדרואיד יכולה להשתמש באופן אופציונלי במערכת ניווט לוויין (GNSS) כדי להציע זמני יוניקס לשירות time_detector . זה לא מופעל כברירת מחדל ב-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 בשרת המערכת.

יש לעדכן גם את הערכים config_enableGnssTimeUpdateService וגם את הערכים config_autoTimeSourcesPriority בקובץ core/res/res/values/config.xml כדי להפעיל תכונה זו. הגדר את הערך עבור config_enableGnssTimeUpdateService ל- true והוסף gnss לרשימת הפריטים עבור config_autoTimeSourcesPriority . מיקומו של gnss ברשימת העדיפות קובע את העדיפות הניתנת להצעות GNSS ביחס להצעות ממקורות אחרים.

להלן דוגמה לקובץ core/res/res/values/config.xml שבו זיהוי זמן GNSS מופעל ו- gnss במקום השלישי ברשימת העדיפות אחרי network telephony .

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