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

Commit c285038d authored by Neil Fuller's avatar Neil Fuller Committed by Gerrit Code Review
Browse files

Merge "Move currentTimeMillis() method to DeviceState"

parents accf0ed9 fb71cac5
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -112,6 +112,11 @@ public interface NitzStateMachine {
         * Returns the same value as {@link SystemClock#elapsedRealtime()}.
         */
        long elapsedRealtime();

        /**
         * Returns the same value as {@link System#currentTimeMillis()}.
         */
        long currentTimeMillis();
    }

    /**
@@ -169,5 +174,10 @@ public interface NitzStateMachine {
        public long elapsedRealtime() {
            return SystemClock.elapsedRealtime();
        }

        @Override
        public long currentTimeMillis() {
            return System.currentTimeMillis();
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -493,7 +493,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine {
     */
    private void updateTimeZoneFromNetworkCountryCode(String iso) {
        CountryResult lookupResult = mTimeZoneLookupHelper.lookupByCountry(
                iso, mTimeServiceHelper.currentTimeMillis());
                iso, mDeviceState.currentTimeMillis());
        if (lookupResult != null && lookupResult.allZonesHaveSameOffset) {
            String logMsg = "updateTimeZoneFromNetworkCountryCode: tz result found"
                    + " iso=" + iso
+0 −5
Original line number Diff line number Diff line
@@ -41,11 +41,6 @@ public interface TimeServiceHelper {
     */
    void setListener(Listener listener);

    /**
     * Returns the same value as {@link System#currentTimeMillis()}.
     */
    long currentTimeMillis();

    /**
     * Returns true if the device has an explicit time zone set.
     */
+0 −5
Original line number Diff line number Diff line
@@ -68,11 +68,6 @@ public final class TimeServiceHelperImpl implements TimeServiceHelper {
                });
    }

    @Override
    public long currentTimeMillis() {
        return System.currentTimeMillis();
    }

    @Override
    public boolean isTimeZoneSettingInitialized() {
        return isTimeZoneSettingInitializedStatic();
+9 −9
Original line number Diff line number Diff line
@@ -88,8 +88,8 @@ public class NitzStateMachineImplTest extends TelephonyTest {
        super.setUp("NitzStateMachineTest");

        // In tests we use a fake impls for TimeServiceHelper and DeviceState.
        mFakeTimeServiceHelper = new FakeTimeServiceHelper();
        mFakeDeviceState = new FakeDeviceState();
        mFakeTimeServiceHelper = new FakeTimeServiceHelper(mFakeDeviceState);

        // In tests we use the real TimeZoneLookupHelper.
        mRealTimeZoneLookupHelper = new TimeZoneLookupHelper();
@@ -750,7 +750,7 @@ public class NitzStateMachineImplTest extends TelephonyTest {
        }

        Script initializeSystemClock(long timeMillis) {
            mFakeTimeServiceHelper.currentTimeMillis = timeMillis;
            mFakeDeviceState.currentTimeMillis = timeMillis;
            return this;
        }

@@ -892,22 +892,22 @@ public class NitzStateMachineImplTest extends TelephonyTest {

    private static class FakeTimeServiceHelper implements TimeServiceHelper {

        private final FakeDeviceState mFakeDeviceState;

        public TimeServiceHelper.Listener listener;
        public boolean timeZoneDetectionEnabled;
        public long currentTimeMillis;

        // State we want to track.
        public TestState<String> deviceTimeZone = new TestState<>();
        public TestState<TimestampedValue<Long>> suggestedTime = new TestState<>();

        @Override
        public void setListener(Listener listener) {
            this.listener = listener;
        FakeTimeServiceHelper(FakeDeviceState fakeDeviceState) {
            mFakeDeviceState = fakeDeviceState;
        }

        @Override
        public long currentTimeMillis() {
            return currentTimeMillis;
        public void setListener(Listener listener) {
            this.listener = listener;
        }

        @Override
@@ -929,7 +929,7 @@ public class NitzStateMachineImplTest extends TelephonyTest {
        public void suggestDeviceTime(TimestampedValue<Long> deviceTime) {
            suggestedTime.set(deviceTime);
            // The fake time service just uses the latest suggestion.
            currentTimeMillis = deviceTime.getValue();
            mFakeDeviceState.currentTimeMillis = deviceTime.getValue();
        }

        void commitState() {
Loading