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를 명시적으로 사용 설정해야 합니다.

이 기능을 사용 설정하려면 core/res/res/values/config.xml 파일의 config_enableGnssTimeUpdateServiceconfig_autoTimeSourcesPriority 값을 모두 업데이트해야 합니다. config_enableGnssTimeUpdateService 값을 true로 설정하고 config_autoTimeSourcesPriority의 항목 목록에 gnss를 추가합니다. 우선순위 목록의 gnss 위치는 다른 소스의 값과 관련하여 GNSS 추천에 부여되는 우선순위를 결정합니다.

다음은 GNSS 시간 감지가 사용 설정되어 있고 gnss가 우선순위 목록에서 networktelephony 다음으로 세 번째인 core/res/res/values/config.xml 파일의 예시입니다.

<!-- 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 명령어의 예시입니다.

  • 포그라운드 사용자 (일반적으로 자동차의 사용자 10)의 마스터 위치 스위치를 사용 설정합니다. 방금 플래시한 경우 설정 마법사를 통해 이 작업을 실행할 수 있습니다.

    adb shell cmd location set-location-enabled true --user 10
  • GPS 테스트 제공자를 추가합니다 (일반적으로 처음에는 실패하고 android from <SOME_UID> not allowed to perform MOCK_LOCATION로 보안 예외를 발생시킴).

    adb shell cmd location providers add-test-provider gps
  • 이전 UID의 모의 위치 권한 사용 설정

    adb shell appops set UID_PRINTED_IN_PREVIOUS_ERROR android:mock_location allow
  • GPS 테스트 제공자 추가 (오류 없이 작동해야 함)

    adb shell cmd location providers set-test-provider-enabled gps true
  • GPS 테스트 제공자 사용 설정

    adb shell cmd location providers set-test-provider-enabled gps true
  • 시간으로 위치 설정 (시간은 하한으로 설정된 제한보다 낮을 수 없음)

    adb shell cmd location providers set-test-provider-location gps --location LATITUDE,LONGITUDE --time TIME