Check for NTP time as soon as WIFI is connected.

Listen for connectivity changes. If WIFI is connected, check if
we have recently checked for NTP time. If we haven't yet checked the
time or it has been long enough (a day), then connect to the NTP server
and get the latest time. Update the time if it is significantly out of sync.

This doesn't poll the NTP server every time there is connectivity, only
if it hasn't been checked since boot or has been a day.

This fixes the problem that during SetupWizard, we try to contact the NTP
server before there is connectivity and fail. Now, as soon as the user
chooses a WiFi network to connect to, it will update the time before
getting to the Date/Time step. Then as soon as the user corrects the TZ,
the date/time should be correct.

Bug: 3491920
Change-Id: I62664156616510b67ecd6a1c24dd838b98d5204f
1 file changed