Merge "Clarify method names and improve debug"
diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java
index 7379443..d03a87d 100644
--- a/core/java/android/os/SystemClock.java
+++ b/core/java/android/os/SystemClock.java
@@ -352,7 +352,7 @@
}
long currentNanos = elapsedRealtimeNanos();
long deltaMs = (currentNanos - time.getElapsedRealtimeNanos()) / 1000000L;
- return time.getTime() + deltaMs;
+ return time.getUnixEpochTimeMillis() + deltaMs;
}
};
}
diff --git a/location/java/android/location/LocationTime.java b/location/java/android/location/LocationTime.java
index e5535d1..2f03508 100644
--- a/location/java/android/location/LocationTime.java
+++ b/location/java/android/location/LocationTime.java
@@ -20,28 +20,32 @@
import android.os.Parcel;
import android.os.Parcelable;
+import java.time.Duration;
+import java.time.Instant;
+
/**
- * Data class for passing location derived time.
+ * Data class for passing GNSS-derived time.
* @hide
*/
public final class LocationTime implements Parcelable {
- private final long mTime;
+ private final long mUnixEpochTimeMillis;
private final long mElapsedRealtimeNanos;
- public LocationTime(long time, long elapsedRealtimeNanos) {
- mTime = time;
+ public LocationTime(long unixEpochTimeMillis, long elapsedRealtimeNanos) {
+ mUnixEpochTimeMillis = unixEpochTimeMillis;
mElapsedRealtimeNanos = elapsedRealtimeNanos;
}
/**
- * The current time, according to the Gnss location provider. */
- public long getTime() {
- return mTime;
+ * The Unix epoch time in millis, according to the Gnss location provider.
+ */
+ public long getUnixEpochTimeMillis() {
+ return mUnixEpochTimeMillis;
}
/**
- * The elapsed nanos since boot {@link #getTime} was computed at.
+ * The elapsed nanos since boot when {@link #getUnixEpochTimeMillis} was the current time.
*/
public long getElapsedRealtimeNanos() {
return mElapsedRealtimeNanos;
@@ -49,7 +53,7 @@
@Override
public void writeToParcel(Parcel out, int flags) {
- out.writeLong(mTime);
+ out.writeLong(mUnixEpochTimeMillis);
out.writeLong(mElapsedRealtimeNanos);
}
@@ -58,8 +62,18 @@
return 0;
}
+ @Override
+ public String toString() {
+ return "LocationTime{"
+ + "mUnixEpochTimeMillis=" + Instant.ofEpochMilli(mUnixEpochTimeMillis)
+ + "(" + mUnixEpochTimeMillis + ")"
+ + ", mElapsedRealtimeNanos=" + Duration.ofNanos(mElapsedRealtimeNanos)
+ + "(" + mElapsedRealtimeNanos + ")"
+ + '}';
+ }
+
public static final @NonNull Parcelable.Creator<LocationTime> CREATOR =
- new Parcelable.Creator<LocationTime>() {
+ new Parcelable.Creator<>() {
public LocationTime createFromParcel(Parcel in) {
long time = in.readLong();
long elapsedRealtimeNanos = in.readLong();
diff --git a/services/core/java/com/android/server/timedetector/GnssTimeUpdateService.java b/services/core/java/com/android/server/timedetector/GnssTimeUpdateService.java
index 5db6000..6949191 100644
--- a/services/core/java/com/android/server/timedetector/GnssTimeUpdateService.java
+++ b/services/core/java/com/android/server/timedetector/GnssTimeUpdateService.java
@@ -261,10 +261,11 @@
private void suggestGnssTime(LocationTime locationTime) {
logDebug("suggestGnssTime()");
- long gnssTime = locationTime.getTime();
+ long gnssUnixEpochTimeMillis = locationTime.getUnixEpochTimeMillis();
long elapsedRealtimeMs = locationTime.getElapsedRealtimeNanos() / 1_000_000L;
- TimestampedValue<Long> timeSignal = new TimestampedValue<>(elapsedRealtimeMs, gnssTime);
+ TimestampedValue<Long> timeSignal =
+ new TimestampedValue<>(elapsedRealtimeMs, gnssUnixEpochTimeMillis);
mLastSuggestedGnssTime = timeSignal;
GnssTimeSuggestion timeSuggestion = new GnssTimeSuggestion(timeSignal);