Add more behavior to TimeDetectorService
The client code now "suggests" time updates
to the time detection service. The current implementation
of the time detection service will validate and set the
device system clock as needed. In future it will ignore
these suggestions if better information is available.
Responsibility for sending the
TelephonyIntents.ACTION_NETWORK_SET_TIME intent has
been moved to the time detection service until it can be
removed or replaced.
The telephony code is still responsible for basic rate
limiting but the majority of the decision logic has been
moved to the service.
There is an associated change in telephony code to switch to
using the server.
Bug: 78217059
Test: atest FrameworksServicesTests:com.android.server.timedetector
Test: atest FrameworksCoreTests:android.util.TimestampedValueTest
Change-Id: I4f7a10ac06b2d32da22689e1ddf309e0a2795f30
diff --git a/core/java/android/util/TimestampedValue.java b/core/java/android/util/TimestampedValue.java
index 75fa18d..1289e4d 100644
--- a/core/java/android/util/TimestampedValue.java
+++ b/core/java/android/util/TimestampedValue.java
@@ -126,4 +126,12 @@
dest.writeLong(timestampedValue.mReferenceTimeMillis);
dest.writeValue(timestampedValue.mValue);
}
+
+ /**
+ * Returns the difference in milliseconds between two instance's reference times.
+ */
+ public static long referenceTimeDifference(
+ @NonNull TimestampedValue<?> one, @NonNull TimestampedValue<?> two) {
+ return one.mReferenceTimeMillis - two.mReferenceTimeMillis;
+ }
}