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를 명시적으로 사용 설정해야 합니다.
이 기능을 사용 설정하려면 core/res/res/values/config.xml 파일의 config_enableGnssTimeUpdateService 및 config_autoTimeSourcesPriority 값을 모두 업데이트해야 합니다. config_enableGnssTimeUpdateService 값을 true로 설정하고 config_autoTimeSourcesPriority의 항목 목록에 gnss를 추가합니다. 우선순위 목록의 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 명령어의 예시입니다.
#EnableMasterLocationSwitchintheforegrounduser(usuallyuser10onautomotive).Ifyoujustflashed,thiscanbedonethroughsetupwizard.adbshellcmdlocationset-location-enabledtrue--user10#AddGPStestprovider(Thisusuallyfailsthefirsttime.ThrowsaSecurityExceptionwith"android from <SOME_UID> not allowed to perform MOCK_LOCATION".)adbshellcmdlocationprovidersadd-test-providergps#EnablemocklocationpermissionsforpreviousUIDadbshellappopssetUID_PRINTED_IN_PREVIOUS_ERRORandroid:mock_locationallow#AddGPStestprovider(Shouldworkwithnoerrors.)adbshellcmdlocationprovidersadd-test-providergps#EnableGPStestprovideradbshellcmdlocationprovidersset-test-provider-enabledgpstrue#Setlocationwithtime(Timecan'tbelowerthanthelimitsetbythelowerbound.)adbshellcmdlocationprovidersset-test-provider-locationgps--locationLATITUDE,LONGITUDE--timeTIME
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-27(UTC)
[[["이해하기 쉬움","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-08-27(UTC)"],[],[],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"]]