Add lower bound checks for non-manual time suggestions.
Before this change, automatic time detection would not validate the incoming UTC time suggested. When the device time is set to a bad value it can cause problems with connectivity and fail enterprise policy checks.
After this change, automatic time detection (currently NITZ or NTP) will disregard times before a lower bound. The lower bound value is initially set from a date derived from the build timestamp. This works on the principle that a valid time cannot be before the system image was built. There is no upper bound currently as we haven't seen invalid dates in the future, and it's harder to come up with a timestamp that we know will always be invalid.
This change may impact automated or manual tests that use dates in the distant past: these dates will no longer be accepted. Tests will have to be updated to use dates in the future.
Bug: 172229867
Test: atest
frameworks/base/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorStrategyImplTest.java
Change-Id: I844ae06c3145e0fac30bd5455ec4f00d01b06ac8
3 files changed