اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release بدلاً من aosp-main لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
رصد الوقت باستخدام نظام تحديد المواقع العالمي (GNSS)
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
في الإصدار 12 من نظام التشغيل Android والإصدارات الأحدث، يمكن لنظام التشغيل Android استخدام نظام GNSS (النظام العالمي لتحديد المواقع عبر الأقمار الصناعية) بشكل اختياري لاقتراح أوقات Unix epoch على خدمة time_detector.
لا تكون هذه الميزة مفعّلة تلقائيًا في "مشروع Android المفتوح المصدر" (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:
لاختبار رصد الوقت باستخدام نظام GNSS، استخدِم أوامر adb shell cmd location.
استخدِم هذه الأوامر لإضافة موفّري مواقع اختبارية يمكنك من خلالها تحديد موقع جغرافي ووقت GNSS المرتبط به. يستمع تطبيق gnss_time_update_service إلى هذه التعديلات على الموقع الجغرافي، ويقدّم اقتراحات بشكل دوري.
في ما يلي أمثلة على أوامر adb shell cmd location:
فعِّل مفتاح الموقع الجغرافي الرئيسي للمستخدم الذي يستخدم الجهاز حاليًا (عادةً المستخدم 10
في السيارات). إذا كنت قد أعدت ضبط الجهاز للتو، يمكنك إجراء ذلك من خلال معالج الإعداد.
إضافة مقدّم خدمة اختبار نظام تحديد المواقع العالمي (GPS) (عادةً ما يتعذّر ذلك في المرة الأولى ويتم عرض استثناء أمان مع android from <SOME_UID> not allowed to perform
MOCK_LOCATION)
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-09-03 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-09-03 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["In Android 12 and higher, Android can optionally use a\nGlobal Navigation Satellite System (GNSS) to suggest Unix epoch times to the\n[`time_detector`](/docs/core/connect/time#time_detector-service) service.\nThis isn't enabled by default in AOSP.\n\nWhen GNSS time detection is enabled, the `gnss_time_update_service` passively\nlistens to location updates from GNSS sources and submits GNSS suggestions to\nthe `time_detector` service. The `time_detector` service then determines whether\nto update the system clock to match the suggestion.\n\nImpact on power usage\n\nThe AOSP `gnss_time_update_service` passively listens to location updates. This\nmeans that it never actively turns on the GPS or consumes additional power. This\nalso means that unless another app or service in the system is actively\nrequesting location updates, the `gnss_time_update_service` won't get a location\nupdate and suggest a GNSS time.\n\nImplementation\n\nTo enable GNSS time detection, device manufacturers must explicitly enable the\n`gnss_time_update_service` in the system server.\n\nBoth the `config_enableGnssTimeUpdateService` and\n`config_autoTimeSourcesPriority` values in the `core/res/res/values/config.xml`\nfile must be updated to enable this feature. Set the value for\n`config_enableGnssTimeUpdateService` to `true` and add `gnss` to the item list\nfor `config_autoTimeSourcesPriority`. The position of `gnss` in the priority\nlist determines the priority given to GNSS suggestions with respect to those\nfrom other sources.\n\nThe following is an example `core/res/res/values/config.xml` file where GNSS\ntime detection is enabled and `gnss` is third in the priority list after\n`network` and `telephony`. \n\n \u003c!-- Specifies priority of automatic time sources. Suggestions from higher entries in the list\n take precedence over lower ones.\n See com.android.server.timedetector.TimeDetectorStrategy for available sources. --\u003e\n \u003cstring-array name=\"config_autoTimeSourcesPriority\"\u003e\n \u003citem\u003enetwork\u003c/item\u003e\n \u003citem\u003etelephony\u003c/item\u003e\n \u003citem\u003egnss\u003c/item\u003e\n \u003c/string-array\u003e\n\n \u003c!-- Enables the GnssTimeUpdate service. This is the global switch for enabling Gnss time based\n suggestions to TimeDetector service. See also config_autoTimeSourcesPriority. --\u003e\n \u003cbool name=\"config_enableGnssTimeUpdateService\"\u003etrue\u003c/bool\u003e\n\nDebugging and testing **Note:** The interface for these commands might change between releases. Use the `help` flag to see a list of command options.\n\nTo test GNSS time detection, you can use `adb shell cmd location` commands.\nUse these commands to add test location providers where you can specify a\nlocation and the associated GNSS time. The `gnss_time_update_service` listens to\nthese location updates, and makes suggestions periodically.\n\nThe following shows examples of `adb shell cmd location` commands: \n\n # Enable Master Location Switch in the foreground user (usually user 10 on automotive). If you just flashed, this can be done through setup wizard.\n adb shell cmd location set-location-enabled true --user 10\n\n # Add GPS test provider (This usually fails the first time. Throws a SecurityException with \"android from \u003cSOME_UID\u003e not allowed to perform MOCK_LOCATION\".)\n adb shell cmd location providers add-test-provider gps\n\n # Enable mock location permissions for previous UID\n adb shell appops set \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eUID_PRINTED_IN_PREVIOUS_ERROR\u003c/span\u003e\u003c/var\u003e android:mock_location allow\n\n # Add GPS test provider (Should work with no errors.)\n adb shell cmd location providers add-test-provider gps\n\n # Enable GPS test provider\n adb shell cmd location providers set-test-provider-enabled gps true\n\n # Set location with time (Time can't be lower than the limit set by the lower bound.)\n adb shell cmd location providers set-test-provider-location gps --location \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eLATITUDE\u003c/span\u003e\u003c/var\u003e,\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eLONGITUDE\u003c/span\u003e\u003c/var\u003e --time \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eTIME\u003c/span\u003e\u003c/var\u003e"]]