Fix issue with SntpClient after the end of NTP era 0 (2036).
This is the second of two commits. This commit makes the actual fixes
and makes tests pass.
Before this change SntpClient converted to Unix epoch times too eagerly.
NTP 64-bit timestamps are lossy: they only hold the number of seconds /
factions of seconds in the NTP era and the era is not transmitted. The
existing code assumed the era was always era 0, which ends in 2036.
As explained at https://www.eecis.udel.edu/~mills/y2k.html,
the lossiness of the type is not an issue providing that the maths is
implemented carefully: the NTP timestamps are only ever subtracted from
each other, are always assumed to be in the same or adjacent NTP eras,
and are used to calculate offsets that are applied to client Unix epoch
times.
This commit:
+ Switches to use a dedicated Timestamp64 type, avoiding the use
of the Unix epoch.
+ Switches to use a dedicated Duration64 type for holding the
32-bit signed difference between two Timestamp64 instances.
+ Simplifies the readTimeStamp() and writeTimeStamp() methods.
+ Adds missing validation covered by a TODO. The code was randomizing
the lower bits of the client transmit timestamp, but then not checking
the result as it should, presumably because it was difficult to know
what value was sent. Easily fixed with a dedicated type.
+ Stops randomizing the lower bits of various other timestamps
unnecessarily.
+ Fixes some naming to add clarity.
Bug: 199481251
Test: atest core/tests/coretests/src/android/net/sntp/Timestamp64Test.java
Test: atest core/tests/coretests/src/android/net/sntp/Duration64Test.java
Test: atest core/tests/coretests/src/android/net/SntpClientTest.java
Merged-In: I6d3584f318b0ef6ceab42bb88f20c73b0ad006cb
Change-Id: I6d3584f318b0ef6ceab42bb88f20c73b0ad006cb
Fix issue with SntpClient after the end of NTP era 0 (2036).
This commit is 1/2. It makes some refactoring changes, lint fixes, adds
tests and introduces types that will be used in 2/2. Some of the added
tests fail and demonstrate the issue being fixed with the current
implementation.
-----
Failures that demonstrate the bug:
android.net.SntpClientTest#testRequestTime_era1ClientEra1Server
STACKTRACE:
junit.framework.AssertionFailedError: expected=5, actual=-4294967295995, allowedSlop=1
at junit.framework.Assert.fail(Assert.java:50)
at junit.framework.Assert.assertTrue(Assert.java:20)
at android.net.SntpClientTest.assertNearlyEquals(SntpClientTest.java:502)
at android.net.SntpClientTest.checkRequestTimeCalcs(SntpClientTest.java:215)
at android.net.SntpClientTest.testRequestTime_era1ClientEra1Server(SntpClientTest.java:201)
android.net.SntpClientTest#testRequestTime_era0ClientEra1Server: FAILED (145ms)
STACKTRACE:
junit.framework.AssertionFailedError: expected=1139293696005, actual=-3155673599995, allowedSlop=1
at junit.framework.Assert.fail(Assert.java:50)
at junit.framework.Assert.assertTrue(Assert.java:20)
at android.net.SntpClientTest.assertNearlyEquals(SntpClientTest.java:502)
at android.net.SntpClientTest.checkRequestTimeCalcs(SntpClientTest.java:215)
at android.net.SntpClientTest.testRequestTime_era0ClientEra1Server(SntpClientTest.java:174)
android.net.SntpClientTest#testNonMatchingOriginateTime: FAILED (116ms)
STACKTRACE:
junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:48)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertFalse(Assert.java:34)
at junit.framework.Assert.assertFalse(Assert.java:41)
at android.net.SntpClientTest.testNonMatchingOriginateTime(SntpClientTest.java:384)
------
This commit:
+ Introduces a dedicated Timestamp64 type + test for holding NTP
timestamps.
+ Introduces a dedicated Duration64 type + test for holding the
32-bit signed difference between two Timestamp64 instances.
+ Fixes some naming to add clarity / addresses lint issues.
+ Adjusts tests
Tests are NOT expected to pass with just this commit. See 2/2.
Bug: 199481251
Test: atest core/tests/coretests/src/android/net/sntp/Timestamp64Test.java
Test: atest core/tests/coretests/src/android/net/sntp/Duration64Test.java
Test: atest core/tests/coretests/src/android/net/SntpClientTest.java
Merged-In: Ifdaada39298b05c48a3207fe6c0fad71c8a0a252
Change-Id: Ifdaada39298b05c48a3207fe6c0fad71c8a0a252
Some OEMs use test SIMs which have ICCID=FFFFFFF... In this case we
don't strip trailing F's.
Bug: 199254579
Test: manual
Change-Id: I69b40fa75e59163e8c30be77cc38e908d6dd8cd4
This will allow us to point other directories at these files for OWNERS
and make it easier to update after future team changes.
Test: N/A
Bug: 202714830
Change-Id: Iaaf5b8eb7568be4ebfd1b30abae0b757153f0391
This patch adds handling active device and set volume
Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: Manual
Change-Id: I50a966ed2f199464381ff561fd83342b0a9b08a9
If an app does not have the permission to access network
in Restricted mode, we should be removing
ALLOWED_REASON_RESTRICTED_MODE_PERMISSIONS from the uid's
allowedReasons but right now, we end up removing all the
allowedReasons except ALLOWED_REASON_RESTRICTED_MODE_PERMISSIONS
and this could result in sending wrong network state to apps.
Bug: 202213533
Test: atest tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: Ibcae147bf4ba84ff91ef7038ffef8c33082b82ca
Merged-In: Ibcae147bf4ba84ff91ef7038ffef8c33082b82ca
(cherry picked from commit 259414efbc207e5e8c4299f39a3c48580e3221df)
This remove the leak of hidden private field and add an api to get
entreprise raw contact
Bug: 194119078
Test: Build
Tag: #refactor
Change-Id: I9285cd54545e1359a4a7f57826ddb1a0e1dcdfbe
Remove createBond from settingLib. SystemUI and Setting have the
individual settingLib instance. If we trigger pairing inside settingLib,
the action would be called twice.
Bug: 201758444
Bug: 150670922
Test: Pair the coordinated set devices, and check the set member pairing
would be done automatically without the pairing dialog
Change-Id: I289b8af857530f0fb207b777d09d94549cfdf553
Previously, we were skipping a broadcast when either the permission or
the app op was granted. However, for runtime permissions to be
considered "granted" both the permission and the app op need to be
granted. This change updates taking this into account.
Test: manual
Bug: 202436287
Bug: 183537857
Change-Id: I9f12f9e17e61246d723d18ead93c6115bbf6d5cf
Initialize LCE list so that its size is at least 1. This is important for 1st call back after registration especially when there is no LCE report yet.
Bug: 198682652
Test: atest -c TelephonyCallbackTest in airplane mode.
Change-Id: I54b4ce0c51e6c10c6ef67776cf3083a04b7d5da3
Merged-In: I54b4ce0c51e6c10c6ef67776cf3083a04b7d5da3
Also migrates related dependencies, and needed to make a small code
change to make it work.
Fixes: 202986197
Test: Ran the tests
Test: Treehugger
Change-Id: Ie30ca52200b93d4f7bff9f60ceb0ba95d052b5c8
Commit e5ad1297165888eb5eef24c1985e64b18b8fb88b combined with pending
reviews demonstrated the OWNERS syntax has quirks and it is not working
as intended.
Documentation used:
https://android-review.googlesource.com/plugins/code-owners/Documentation/backend-find-owners.html#syntax
The syntax guide recommends that patterns like sub-dir/* aren't used as
they can cause problems when renaming directories; better to have OWNERS
in the sub-dir. The pattern sntp/* didn't appear to be working (perhaps
because of spaces).
Test: None
Bug: 199481251
Change-Id: I193744eaaad529b9680d3ccf905b86d68f62f7ff