GNSS टाइम डिटेक्शन

एंड्रॉइड 12 से, एंड्रॉइड वैकल्पिक रूप से टाइम_डिटेक्टर सेवा को यूनिक्स युग के समय का सुझाव देने के लिए ग्लोबल नेविगेशन सैटेलाइट सिस्टम (जीएनएसएस) का उपयोग कर सकता है। यह AOSP में डिफ़ॉल्ट रूप से सक्षम नहीं है.

जब GNSS समय का पता लगाना सक्षम होता है, gnss_time_update_service निष्क्रिय रूप से GNSS स्रोतों से स्थान अपडेट सुनता है और GNSS सुझावों को time_detector सेवा में सबमिट करता है। time_detector सेवा तब यह निर्धारित करती है कि सुझाव से मेल खाने के लिए सिस्टम घड़ी को अपडेट करना है या नहीं।

बिजली के उपयोग पर प्रभाव

AOSP gnss_time_update_service निष्क्रिय रूप से स्थान अपडेट सुनता है। इसका मतलब यह है कि यह कभी भी सक्रिय रूप से जीपीएस चालू नहीं करता है या अतिरिक्त बिजली की खपत नहीं करता है। इसका मतलब यह भी है कि जब तक सिस्टम में कोई अन्य ऐप या सेवा सक्रिय रूप से स्थान अपडेट का अनुरोध नहीं करती है, तब तक gnss_time_update_service स्थान अपडेट नहीं मिलेगा और GNSS समय का सुझाव नहीं दिया जाएगा।

कार्यान्वयन

GNSS समय का पता लगाने को सक्षम करने के लिए, डिवाइस निर्माताओं को सिस्टम सर्वर में gnss_time_update_service स्पष्ट रूप से सक्षम करना होगा।

इस सुविधा को सक्षम करने के लिए core/res/res/values/config.xml फ़ाइल में config_enableGnssTimeUpdateService और config_autoTimeSourcesPriority मान दोनों को अद्यतन किया जाना चाहिए। config_enableGnssTimeUpdateService के मान को true पर सेट करें और 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>

डिबगिंग और परीक्षण

जीएनएसएस समय का पता लगाने का परीक्षण करने के लिए, आप adb shell cmd location कमांड का उपयोग कर सकते हैं। परीक्षण स्थान प्रदाताओं को जोड़ने के लिए इन आदेशों का उपयोग करें जहां आप एक स्थान और संबंधित जीएनएसएस समय निर्दिष्ट कर सकते हैं। 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