Skip to content
Commit 4ab8a199 authored by Neil Fuller's avatar Neil Fuller
Browse files

Change NetworkTimeUpdateServiceImpl behavior

This change moves some logic associated with time detection out of the
NetworkTimeUpdateServiceImpl and moves it to the TimeDetectorStrategy
called by the TimeDetectorService.

The TimeDetectorStategy implementation now decides when to use an
NTP-derived time instead. The logic implemented here is effectively the
same as it was: NITZ takes priority over NTP until the latest NITZ
signal becomes "too old".

The motivating reasons for the change:
1) The "what signal is used when several are available?" logic should be
in one place: the TimeDetectoryStrategy not scattered around the
platform. Centralizing will enable different strategies and time sources
to be introduced over time.

2) It will allow removal of the ACTION_NETWORK_SET_TIME intent in a
follow-up commit; this intent was used to coordinate the NTP vs NITZ
logic should no longer be required.

The "bonus" effect of this change is that NetworkTimeUpdateServiceImpl
becomes more general: It can now be the authority for the NTP time on a
device independently of how the system clock should be set. e.g. it
could be used in future to back the
AlarmManager.currentNetworkTimeMillis() API call.  Anything that needs a
"what is the best time according to NTP?" answer could use this service.

Note: The NetworkTimeUpdateServiceImpl still observes the AUTO_TIME
setting and will perform an NTP lookup "on demand" (if required) when
the user enables the setting. This should be a temporary state and
likely to be removed in future; knowledge of AUTO_TIME shouldn't be
required for the NTP info to be correct and if
NetworkTimeUpdateServiceImpl is doing the right thing.

Bug: 140712361
Test: atest com.android.server.timedetector
Test: atest android.app.timedetector
Change-Id: I4b2936a42c552c4dd4cb55010306bb81bca0c712
parent 0de8726e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment