Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99a7e497 authored by Neil Fuller's avatar Neil Fuller
Browse files

Switch "UTC time" to "Unix epoch time"

This is more correct.

Bug: 218802673
Test: Compile only
Change-Id: I4397ae1c055beca71998ce598ff489ecd4241dc1
parent 09560b2a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -56,14 +56,14 @@ public final class NitzData {
    private final TimeZone mEmulatorHostTimeZone;

    private NitzData(String originalString, int zoneOffsetMillis, Integer dstOffsetMillis,
            long utcTimeMillis, TimeZone emulatorHostTimeZone) {
            long unixEpochTimeMillis, TimeZone emulatorHostTimeZone) {
        if (originalString == null) {
            throw new NullPointerException("originalString==null");
        }
        this.mOriginalString = originalString;
        this.mZoneOffset = zoneOffsetMillis;
        this.mDstOffset = dstOffsetMillis;
        this.mCurrentTimeMillis = utcTimeMillis;
        this.mCurrentTimeMillis = unixEpochTimeMillis;
        this.mEmulatorHostTimeZone = emulatorHostTimeZone;
    }

@@ -130,8 +130,8 @@ public final class NitzData {

    /** A method for use in tests to create NitzData instances. */
    public static NitzData createForTests(int zoneOffsetMillis, Integer dstOffsetMillis,
            long utcTimeMillis, TimeZone emulatorHostTimeZone) {
        return new NitzData("Test data", zoneOffsetMillis, dstOffsetMillis, utcTimeMillis,
            long unixEpochTimeMillis, TimeZone emulatorHostTimeZone) {
        return new NitzData("Test data", zoneOffsetMillis, dstOffsetMillis, unixEpochTimeMillis,
                emulatorHostTimeZone);
    }

+2 −2
Original line number Diff line number Diff line
@@ -95,8 +95,8 @@ public interface NitzStateMachine {
        int getNitzUpdateSpacingMillis();

        /**
         * If UTC time between two NITZ signals is greater than this value then the second signal
         * cannot be ignored.
         * If Unix epoch time between two NITZ signals is greater than this value then the second
         * signal cannot be ignored.
         */
        int getNitzUpdateDiffMillis();

+9 −9
Original line number Diff line number Diff line
@@ -207,24 +207,24 @@ public final class NitzSignalInputFilterPredicateFactory {
                    return true;
                }

                // See if the NITZ signals have sufficiently different encoded UTC times. If yes,
                // then we want to process the new one.
                // See if the NITZ signals have sufficiently different encoded Unix epoch times. If
                // yes, then we want to process the new one.
                int nitzUpdateDiff = deviceState.getNitzUpdateDiffMillis();

                // Calculate the UTC difference between the time the two signals hold, accounting
                // for any difference in receipt time and age.
                long utcTimeDifferenceMillis = newNitzData.getCurrentTimeInMillis()
                // Calculate the Unix epoch difference between the time the two signals hold,
                // accounting for any difference in receipt time and age.
                long unixEpochTimeDifferenceMillis = newNitzData.getCurrentTimeInMillis()
                        - previousNitzData.getCurrentTimeInMillis();
                long ageAdjustedElapsedRealtimeDifferenceMillis =
                        newSignal.getAgeAdjustedElapsedRealtimeMillis()
                                - previousSignal.getAgeAdjustedElapsedRealtimeMillis();

                // In ideal conditions, the difference between
                // ageAdjustedElapsedRealtimeSinceLastSaved and utcTimeDifferenceMillis will be zero
                // if two NITZ signals are consistent and if the elapsed realtime clock is ticking
                // at the correct rate.
                // ageAdjustedElapsedRealtimeSinceLastSaved and unixEpochTimeDifferenceMillis will
                // be zero if two NITZ signals are consistent and if the elapsed realtime clock is
                // ticking at the correct rate.
                long millisGainedOrLost = Math.abs(
                        utcTimeDifferenceMillis - ageAdjustedElapsedRealtimeDifferenceMillis);
                        unixEpochTimeDifferenceMillis - ageAdjustedElapsedRealtimeDifferenceMillis);
                if (millisGainedOrLost > nitzUpdateDiff) {
                    return true;
                }
+1 −1
Original line number Diff line number Diff line
@@ -366,7 +366,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine {
                        + " reason=" + reason);
            } else {
                TimestampedValue<Long> newNitzTime = nitzSignal.createTimeSignal();
                builder.setUtcTime(newNitzTime);
                builder.setUnixEpochTime(newNitzTime);
                builder.addDebugInfo("Sending new time suggestion"
                        + " nitzSignal=" + nitzSignal
                        + ", reason=" + reason);
+3 −3
Original line number Diff line number Diff line
@@ -68,9 +68,9 @@ public final class TimeServiceHelperImpl implements TimeServiceHelper {

        Objects.requireNonNull(timeSuggestion);

        if (timeSuggestion.getUtcTime() != null) {
            TimestampedValue<Long> utcTime = timeSuggestion.getUtcTime();
            TelephonyMetrics.getInstance().writeNITZEvent(mSlotIndex, utcTime.getValue());
        if (timeSuggestion.getUnixEpochTime() != null) {
            TimestampedValue<Long> unixEpochTime = timeSuggestion.getUnixEpochTime();
            TelephonyMetrics.getInstance().writeNITZEvent(mSlotIndex, unixEpochTime.getValue());
        }
        mTimeDetector.suggestTelephonyTime(timeSuggestion);
    }
Loading