Skip to content
Commit 5b91a19e authored by Neil Fuller's avatar Neil Fuller
Browse files

Prepare to make origin list mutable

This commit copies the pattern used in the time zone detector classes
and applies it to the time detector.

The origin will need to be mutable during tests to allow testing of the
new "external" time source.

Description of the pattern followed:

Environment is the interface used by the Strategy to interact with the
majority of hard-to-fake Android components. FakeEnvironment is used in
the StrategyTest, EnvironmentImpl is the read deal.

EnvironmentImpl further delegates to a ServiceConfigAccessor for
non-user-facing settings. This hides whether the values come from
static config or server flags.

Specifics:

The main change besides additional classes is that the EnvironmentImpl
is now responsible for notifying the strategy of changes that may
influence the choice of time suggestion to use. Previously, the
TimeDetectorService handled notifications, which meant both the
surrounding service object and the enclosed environment object knew
about settings keys being used. Now it's all handled by the Environment.
Later, the same callback from the environment will be used to indicate
the origin list has been changed, once there's a ServerFlag to influence
it.

The new ServiceConfigAccessor is ready for server flags to be used, but
doesn't have any yet. They will be added in a follow-up. This means
there are a few constants that are not currently used, but they will be.

Bug: 183239968
Test: atest services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorStrategyImplTest.java
Test: atest services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
Change-Id: I4462afe12065a10ec762f77887c45611db052fe8
parent a6d011d0
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