• dhork@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    13 hours ago

    I have a GPS app on my phone, and when I run it, I can see the difference between the GPS time and phone time quite clearly

    • tal@lemmy.today
      link
      fedilink
      English
      arrow-up
      2
      ·
      10 hours ago

      searches

      For Android:

      https://source.android.com/docs/core/connect/time

      From Android 12, device manufacturers can change the core/res/res/values/config.xml configuration file to specify which time origins to include in automatic time detection, and the priority in which time_detector considers these origins.

      For devices running Android 11 or lower, origin priority is hardcoded to [“telephony”, “network”], meaning that telephony suggestions are prioritized above network suggestions.

      The default AOSP configuration is as follows:

      <!-- 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>
      </string-array>
      

      In Android 12, network and telephony suggestions are configured as origins to use by default. Network time suggestions are prioritized above telephony time suggestions. Device manufacturers can change the order of the origins to revert to the behavior in Android 11 or lower, where telephony is given a higher priority.

      By default, if the highest priority valid suggestion matches the device’s current system clock time to within a couple of seconds, the device time won’t be changed. This is to avoid creating work for installed apps that listen to the ACTION_TIME_CHANGED intent.

      The allowed origin values are:

      • Network
      • Telephony
      • GNSS
      • External

      “Network” will presumably be NTP, “Telephony” the cell tower time, “GNSS” GPS, and I dunno what “External” is — maybe there’s some way to have a USB-connected time device or something.

      • dhork@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        edit-2
        10 hours ago

        This is all good stuff, maybe at some point I will get back into some Android development and make an app that exposes some of the underlying NTP configuration. Really, I just want to see the ntpd (or chrony) config file (if it exists) and tweak it.

        I did some searching of my own today, and found this guy’s blog

        https://jitinsharma.com/posts/adventures-in-android-timekeeping/

        And he seems to think the poll interval is 16, or 18 hours. I don’t know why these poll intervals are so long. I bet even 2^10 (17 mins) would work much better across all phones, and not really consume that much bandwidth.

        And also, if the phone has access to time from the cell network, why can’t it use that more often?

        This is the first phone I have had that is regularly more than a second off, and it bugs me…