summaryrefslogtreecommitdiff
path: root/core/java/android/util/NtpTrustedTime.java
Commit message (Collapse)AuthorAgeFilesLines
* Document a section of codeNeil Fuller2022-04-051-0/+10
| | | | | | | | | | Document a section of code that prevents an NTP-related CTS test working if the device is not connected to Wifi. The reason the code exists took a little bit of research, so here it is. Bug: 213393821 Test: Comment-only change Change-Id: I0b5d9f298ef36e861f780a29fdf74f0226fa1567
* Add the ability to configure NTP port for testsNeil Fuller2022-03-171-4/+27
| | | | | | | | | | | | | | | | | | | | | | | | | Add the ability to configure NTP port for tests via the command line and the associated plumbing / knock-ons. In-progress CTS tests will run a fake NTP server on the device itself. Binding to NTP's default port of 123 is restricted. Therefore, we need to be able to override the port for tests. adb shell cmd network_time_update_service set_server_config --port 9999 adb shell dumpsys network_time_update_service <observe port value> adb shell cmd network_time_update_service force_refresh <observe false> adb shell cmd network_time_update_service set_server_config adb shell dumpsys network_time_update_service <observe port value> adb shell cmd network_time_update_service force_refresh <observe true> Bug: 213393821 Test: See above Change-Id: I21e8b735fab268df0d617848b8a562f86560ad16
* Make NTP config configurable from cmdNeil Fuller2022-03-031-15/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable NTP failure / timeout testing by providing an ability for testers to change the NTP configuration. Also improve debugging information from dumpsys and logs. Testing: adb shell cmd network_time_update_service set_server_config --hostname localhost adb shell dumpsys network_time_update_service adb shell cmd network_time_update_service force_refresh <observe false> adb shell dumpsys network_time_update_service adb shell cmd network_time_update_service set_server_config --hostname localhost --timeout_millis 1000 adb shell dumpsys network_time_update_service adb shell cmd network_time_update_service force_refresh <observe false, but faster> adb shell cmd network_time_update_service set_server_config --hostname localhost --timeout_millis 10000 adb shell dumpsys network_time_update_service adb shell cmd network_time_update_service force_refresh <observe false, but slower> adb shell cmd network_time_update_service set_server_config adb shell cmd network_time_update_service force_refresh <observe true> Bug: 213393821 Test: See above Change-Id: Ic66c7fabe0b42a3d5c86f8b85f17096bf64a8209
* Command-line interface: NetworkTimeUpdateServiceNeil Fuller2022-03-011-0/+7
| | | | | | | | | | | | | | | Initial command-line interface for NetworkTimeUpdateService for use in tests. To be joined by more commands as they are identified. Bug: 213393821 Test: adb shell cmd network_time_update_service help Test: adb shell cmd network_time_update_service clear_time && adb shell dumpsys network_time_update_service Test: adb shell cmd network_time_update_service force_refresh && adb shell dumpsys network_time_update_service Change-Id: I033764a7df9759e9fd4da0b0776f6535a574ff59
* Add local logs to NetworkTimeUpdateServiceKanyinsola2022-02-251-1/+10
| | | | | | Bug: b/217357882 Test: Changes adds local logs. Existing unit tests still pass. Change-Id: I2876a479c5219b6e4af6dfe25ba0942d82115ca5
* Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-11-041-5/+6
| | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
* Make NtpTrustedTime safer / expand docsNeil Fuller2020-01-131-98/+198
| | | | | | | | | | | | | | | | | | | | | | | This commit makes a number of changes: 1) Documents / enforces thread safety, removes or deprecates unsafe check-then-do methods / adds a way to get the NTP query result atomically. 2) Delays configuration lookup until point of use: the config can change due to various possible config overlays, e.g. MCC-based config. (1) is because the threading model is currently unclear / possibly unsafe - it looks like NtpTrustedTime is supposed to be single threaded but it's also a singleton so could be accessed from multiple threads. If NtpTrustedTime were not a singleton things might be easier but the @UnsupportedAppUsage makes it difficult to change now. (2) is to address the same issue as https://r.android.com/1182530, contributed by Luca Stefani. Bug: 140712361 Test: build only Merged-In: Ie09da9db5d853b59829886a020de21a88da5dd51 Change-Id: Ie09da9db5d853b59829886a020de21a88da5dd51 (cherry picked from commit 65f0f31bdee65d1bbe76fcd14a13151a476a51ec)
* Merge "Use new UnsupportedAppUsage annotation."Treehugger Robot2020-01-131-1/+1
|\
| * Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-091-1/+1
| | | | | | | | | | | | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I288969b0c22fa3a63bc2e71bb5009fe4a927e154 Merged-In: I288969b0c22fa3a63bc2e71bb5009fe4a927e154
* | Rename android.util.TimestampedValue to android.osNeil Fuller2020-01-091-0/+1
|/ | | | | | | | | | | Rename android.util.TimestampedValue to android.os to avoid dependency from android.util onto android.os, which is disallowed by lint. Bug: 147012511 Test: boot Merged-In: I4b84db03c8ad24bbef63e45d6d15fb306a10364e Change-Id: I4b84db03c8ad24bbef63e45d6d15fb306a10364e (cherry picked from commit d159015e5445fcfc0b3e4084095e2850d28a3fb4)
* Fix annotation / debuggingNeil Fuller2020-01-071-2/+1
| | | | | | | | | | Fix copy and paste errors from commit 4ab8a199de8 - the API is new so does not need @UnsupportedAppUsage and the debug log was incorrect. Bug: 140712361 Test: build only Change-Id: I123f76d011d7505d3dc053cb48c40353f0579d17
* Change NetworkTimeUpdateServiceImpl behaviorNeil Fuller2019-12-191-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-08-141-0/+7
| | | | | | | | | | | | | | | | | | | | For packages: android.util.proto android.util.jar android.util.apk android.util This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I18848448a81132399f6878812acf5031ed8cec9f Merged-In: Ia0f48c244b0fbe33d40d797702a82303648196ed
* Allow specifying a network for SNTP time syncKurt Marcinkiewicz2018-05-161-3/+16
| | | | | | | | | | | | | | | | | | | Permits syncing over a specific network instead of the default for the process. This was causing an issue with Android Wear devices paired with iOS where the default network is bluetooth (see b/32663274). This CL is in support of ag/3776564 Bug: 32663274 Test: adb shell am instrument -e class android.net.SntpClientTest -w \ com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner (cherry-pick of pi-dev Ic9fc169cf75457810d4992121d85d7642e350b90) Merged-In: I339c77063c72a9d76a5c4cb17052e20fb6e045a6 Merged-In: I8dfd1cad99c63efdc14c174c19f094a61cdfc44f Change-Id: I44df66688292b144ec7dfcdd9ae5d82489f82774
* am 3d992507: am 09dff843: Merge "Only try to fetch time from NTP if there is ↵Lorenzo Colitti2015-01-261-0/+20
|\ | | | | | | | | | | | | a network connection." into lmp-mr1-dev * commit '3d992507a09b4d32c1e961a99d77027db050f01b': Only try to fetch time from NTP if there is a network connection.
| * Only try to fetch time from NTP if there is a network connection.Lorenzo Colitti2015-01-261-0/+20
| | | | | | | | | | Bug: 19046107 Change-Id: Iff647ee33fe0eb9b530d7baad636d32b386e4fa7
* | check ntpserver as empty string instead of nullYoung-Ho Cha2015-01-081-1/+2
|/ | | | | | | | mServer cannot set null, because string from resource always returns non-null charsequence Change-Id: I8d6a6fdbc34267ee361e7bd20719887268161870 Signed-off-by: Young-Ho Cha <ganadist@gmail.com>
* Actually move to Global settings.Jeff Sharkey2012-09-141-2/+2
| | | | | | | Also add better ConnectivityService logging. Bug: 7157464 Change-Id: Ia235a7e62ed809240913c4782920c1410c7d597d
* Move to Global.NETSTATS and Global.NTP constants.Jeff Sharkey2012-09-141-7/+7
| | | | | Bug: 7157464 Change-Id: Ief10fd37940f62420f5684940994c9f93802e0be
* Cached NTP time for system services.Jeff Sharkey2011-07-101-10/+50
| | | | | | | | | Uses NTP server and timeout from secure settings, or fallback to defaults in resources. Update various system services to use cached NTP time when fresh enough, or force updates as needed. Bug: 4517273 Change-Id: Ie1c4c4883836013d02ca0bbd850cf8949f93b34b
* Avoid throwing when forceRefresh() missing server.Jeff Sharkey2011-05-041-1/+2
| | | | | Bug: 4377651 Change-Id: Ia950a1e62d39ce9148827ebb4535f6441911b195
* Tests for ThrottleService, NTP into TrustedTime.Jeff Sharkey2011-04-281-0/+96
Wrote initial suite of tests for ThrottleService, checking a variety of edge cases. Checks going over limits, updating policies, and reset after cycle elapses. Moved NTP code in ThrottleService into new TrustedTime interface, which makes it easier to understand, and allows tests to provide custom clocks. Change-Id: I0d62b8b3a169516a2ab2d33025f6fe30dc792be8