Make NitzStateMachine testable
This commit does not modify behavior of NitzStateMachine. It is a refactoring that separates NitzStateMachine from various device concerns that would otherwise make unit testing difficult. There are three main categories of interaction from NitzStateManager with other components: 1) External actions / querying of the NITZ state triggered by ServiceStateTracker. 2) NitzStateManager interacting with the device's time / time zone state and associated user settings. This is now handled by TimeServiceHelper. In future this will mostly be replaced by calls to a proposed TimeDetectionService as part of the work to improve support for devices that have multiple ways of detecting time / time zone. Time / time zone detection being enabled will dependent on which component is asking. 3) NitzStateManager interacting with global / shared device state. i.e. reading and writing SystemProperties and reading unmodifiable clocks. Abstracting these has clear advantages for unit testing since it allows simulation of various device states and avoids modification of the system properties (which is not permitted, anyway). This commit contains a single new test in NitzStateMachineTest to demonstrate the purpose of this change and prove that there is nothing preventing more extensive time / time zone detection tests being written in future commits. The only test in ServiceStateTrackerTest that touched on NITZ logic has been modified to reflect the fact it delegates to a (test stubbed) NitzStateMachine and no longer handles the NITZ logic itself. Testing: To run individual tests: atest FrameworksTelephonyTests:com.android.internal.telephony.NitzStateMachineTest \ FrameworksTelephonyTests:com.android.internal.telephony.ServiceStateTrackerTest To run all telephony tests: atest FrameworksTelephonyTests Bug: 63743683 Test: See above Change-Id: Ie0be1bc4a2d6baf4860ed93902c697f3edfa4d44
Loading
Please register or sign in to comment