जीएनएसएस समय का पता लगाने की सुविधा

Android 12 पर, Android विकल्प के तौर पर ग्लोबल नेविगेशन सैटलाइट सिस्टम (जीएनएसएस) time_detector सेवा का इस्तेमाल करें. यह एओएसपी में डिफ़ॉल्ट रूप से चालू नहीं होता.

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

पावर के इस्तेमाल पर असर

एओएसपी gnss_time_update_service, जगह की जानकारी से जुड़े अपडेट को लगातार सुनता है. यह इसका मतलब है कि यह कभी भी GPS को सक्रिय नहीं करता या अतिरिक्त पावर की खपत नहीं करता. यह इसका मतलब यह भी है कि जब तक सिस्टम में मौजूद कोई दूसरा ऐप्लिकेशन या सेवा सक्रिय रूप से जगह की जानकारी अपडेट करने का अनुरोध कर रहे हैं, तो gnss_time_update_service को जगह की जानकारी नहीं मिलेगी GNSS समय के लिए अपडेट करें और सुझाएं.

लागू करना

GNSS समय का पता लगाने की सुविधा चालू करने के लिए, डिवाइस मैन्युफ़ैक्चरर को साफ़ तौर पर सिस्टम सर्वर में gnss_time_update_service.

config_enableGnssTimeUpdateService और core/res/res/values/config.xml में config_autoTimeSourcesPriority की वैल्यू इस सुविधा को चालू करने के लिए, फ़ाइल को अपडेट करना ज़रूरी है. इसके लिए मान सेट करें 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_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. Throws 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