Provide injectable clock for AnrTimerService
This defines a test mode version of the abstract Clock used by the native AnrTimerService. The abstract Clock offers a method to set the current time; this method does nothing for the production Clock but adjusts the current time for the test mode clock. Test timers rely on test code to manually advance the clock's view of current time. Test clocks are allocated one per AnrTimerService and are destroyed along with the AnrTimerService. This gives better test isolation. AnrTimer instances can be created in test mode; these instances use a unique test mode clock. Methods to set the time of a test mode clock are plumbed up to AnrTimer. Again, the methods do nothing unless the AnrTimer is in test mode. Note that production AnrTimers use a singleton clock based on the OS clock and timerfd routes, while test-mode AnrTimers each have their own test-mode clodk. Unit tests have been updated to use the test mode for some tests. Some tests still rely on production timers to verify proper behavior when a production clock is being used. Flag: EXEMPT test-only Bug: 407584606 Test: atest * FrameworksServicesTests:AnrTimerTest * FrameworksServicesTests:com.android.server.am * FrameworksMockingServicesTests:com.android.server.am Change-Id: I165e949db735f1e90db0dfbad094998bb676d4dd
Loading
Please register or sign in to comment