Loading src/java/com/android/internal/telephony/NitzStateMachine.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -112,6 +112,11 @@ public interface NitzStateMachine { * Returns the same value as {@link SystemClock#elapsedRealtime()}. * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ */ long elapsedRealtime(); long elapsedRealtime(); /** * Returns the same value as {@link System#currentTimeMillis()}. */ long currentTimeMillis(); } } /** /** Loading Loading @@ -169,5 +174,10 @@ public interface NitzStateMachine { public long elapsedRealtime() { public long elapsedRealtime() { return SystemClock.elapsedRealtime(); return SystemClock.elapsedRealtime(); } } @Override public long currentTimeMillis() { return System.currentTimeMillis(); } } } } } src/java/com/android/internal/telephony/NitzStateMachineImpl.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -493,7 +493,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { */ */ private void updateTimeZoneFromNetworkCountryCode(String iso) { private void updateTimeZoneFromNetworkCountryCode(String iso) { CountryResult lookupResult = mTimeZoneLookupHelper.lookupByCountry( CountryResult lookupResult = mTimeZoneLookupHelper.lookupByCountry( iso, mTimeServiceHelper.currentTimeMillis()); iso, mDeviceState.currentTimeMillis()); if (lookupResult != null && lookupResult.allZonesHaveSameOffset) { if (lookupResult != null && lookupResult.allZonesHaveSameOffset) { String logMsg = "updateTimeZoneFromNetworkCountryCode: tz result found" String logMsg = "updateTimeZoneFromNetworkCountryCode: tz result found" + " iso=" + iso + " iso=" + iso Loading src/java/com/android/internal/telephony/TimeServiceHelper.java +0 −5 Original line number Original line Diff line number Diff line Loading @@ -41,11 +41,6 @@ public interface TimeServiceHelper { */ */ void setListener(Listener listener); 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. * Returns true if the device has an explicit time zone set. */ */ Loading src/java/com/android/internal/telephony/TimeServiceHelperImpl.java +0 −5 Original line number Original line Diff line number Diff line Loading @@ -68,11 +68,6 @@ public final class TimeServiceHelperImpl implements TimeServiceHelper { }); }); } } @Override public long currentTimeMillis() { return System.currentTimeMillis(); } @Override @Override public boolean isTimeZoneSettingInitialized() { public boolean isTimeZoneSettingInitialized() { return isTimeZoneSettingInitializedStatic(); return isTimeZoneSettingInitializedStatic(); Loading tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java +9 −9 Original line number Original line Diff line number Diff line Loading @@ -88,8 +88,8 @@ public class NitzStateMachineImplTest extends TelephonyTest { super.setUp("NitzStateMachineTest"); super.setUp("NitzStateMachineTest"); // In tests we use a fake impls for TimeServiceHelper and DeviceState. // In tests we use a fake impls for TimeServiceHelper and DeviceState. mFakeTimeServiceHelper = new FakeTimeServiceHelper(); mFakeDeviceState = new FakeDeviceState(); mFakeDeviceState = new FakeDeviceState(); mFakeTimeServiceHelper = new FakeTimeServiceHelper(mFakeDeviceState); // In tests we use the real TimeZoneLookupHelper. // In tests we use the real TimeZoneLookupHelper. mRealTimeZoneLookupHelper = new TimeZoneLookupHelper(); mRealTimeZoneLookupHelper = new TimeZoneLookupHelper(); Loading Loading @@ -750,7 +750,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { } } Script initializeSystemClock(long timeMillis) { Script initializeSystemClock(long timeMillis) { mFakeTimeServiceHelper.currentTimeMillis = timeMillis; mFakeDeviceState.currentTimeMillis = timeMillis; return this; return this; } } Loading Loading @@ -892,22 +892,22 @@ public class NitzStateMachineImplTest extends TelephonyTest { private static class FakeTimeServiceHelper implements TimeServiceHelper { private static class FakeTimeServiceHelper implements TimeServiceHelper { private final FakeDeviceState mFakeDeviceState; public TimeServiceHelper.Listener listener; public TimeServiceHelper.Listener listener; public boolean timeZoneDetectionEnabled; public boolean timeZoneDetectionEnabled; public long currentTimeMillis; // State we want to track. // State we want to track. public TestState<String> deviceTimeZone = new TestState<>(); public TestState<String> deviceTimeZone = new TestState<>(); public TestState<TimestampedValue<Long>> suggestedTime = new TestState<>(); public TestState<TimestampedValue<Long>> suggestedTime = new TestState<>(); @Override FakeTimeServiceHelper(FakeDeviceState fakeDeviceState) { public void setListener(Listener listener) { mFakeDeviceState = fakeDeviceState; this.listener = listener; } } @Override @Override public long currentTimeMillis() { public void setListener(Listener listener) { return currentTimeMillis; this.listener = listener; } } @Override @Override Loading @@ -929,7 +929,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { public void suggestDeviceTime(TimestampedValue<Long> deviceTime) { public void suggestDeviceTime(TimestampedValue<Long> deviceTime) { suggestedTime.set(deviceTime); suggestedTime.set(deviceTime); // The fake time service just uses the latest suggestion. // The fake time service just uses the latest suggestion. currentTimeMillis = deviceTime.getValue(); mFakeDeviceState.currentTimeMillis = deviceTime.getValue(); } } void commitState() { void commitState() { Loading Loading
src/java/com/android/internal/telephony/NitzStateMachine.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -112,6 +112,11 @@ public interface NitzStateMachine { * Returns the same value as {@link SystemClock#elapsedRealtime()}. * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ */ long elapsedRealtime(); long elapsedRealtime(); /** * Returns the same value as {@link System#currentTimeMillis()}. */ long currentTimeMillis(); } } /** /** Loading Loading @@ -169,5 +174,10 @@ public interface NitzStateMachine { public long elapsedRealtime() { public long elapsedRealtime() { return SystemClock.elapsedRealtime(); return SystemClock.elapsedRealtime(); } } @Override public long currentTimeMillis() { return System.currentTimeMillis(); } } } } }
src/java/com/android/internal/telephony/NitzStateMachineImpl.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -493,7 +493,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { */ */ private void updateTimeZoneFromNetworkCountryCode(String iso) { private void updateTimeZoneFromNetworkCountryCode(String iso) { CountryResult lookupResult = mTimeZoneLookupHelper.lookupByCountry( CountryResult lookupResult = mTimeZoneLookupHelper.lookupByCountry( iso, mTimeServiceHelper.currentTimeMillis()); iso, mDeviceState.currentTimeMillis()); if (lookupResult != null && lookupResult.allZonesHaveSameOffset) { if (lookupResult != null && lookupResult.allZonesHaveSameOffset) { String logMsg = "updateTimeZoneFromNetworkCountryCode: tz result found" String logMsg = "updateTimeZoneFromNetworkCountryCode: tz result found" + " iso=" + iso + " iso=" + iso Loading
src/java/com/android/internal/telephony/TimeServiceHelper.java +0 −5 Original line number Original line Diff line number Diff line Loading @@ -41,11 +41,6 @@ public interface TimeServiceHelper { */ */ void setListener(Listener listener); 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. * Returns true if the device has an explicit time zone set. */ */ Loading
src/java/com/android/internal/telephony/TimeServiceHelperImpl.java +0 −5 Original line number Original line Diff line number Diff line Loading @@ -68,11 +68,6 @@ public final class TimeServiceHelperImpl implements TimeServiceHelper { }); }); } } @Override public long currentTimeMillis() { return System.currentTimeMillis(); } @Override @Override public boolean isTimeZoneSettingInitialized() { public boolean isTimeZoneSettingInitialized() { return isTimeZoneSettingInitializedStatic(); return isTimeZoneSettingInitializedStatic(); Loading
tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java +9 −9 Original line number Original line Diff line number Diff line Loading @@ -88,8 +88,8 @@ public class NitzStateMachineImplTest extends TelephonyTest { super.setUp("NitzStateMachineTest"); super.setUp("NitzStateMachineTest"); // In tests we use a fake impls for TimeServiceHelper and DeviceState. // In tests we use a fake impls for TimeServiceHelper and DeviceState. mFakeTimeServiceHelper = new FakeTimeServiceHelper(); mFakeDeviceState = new FakeDeviceState(); mFakeDeviceState = new FakeDeviceState(); mFakeTimeServiceHelper = new FakeTimeServiceHelper(mFakeDeviceState); // In tests we use the real TimeZoneLookupHelper. // In tests we use the real TimeZoneLookupHelper. mRealTimeZoneLookupHelper = new TimeZoneLookupHelper(); mRealTimeZoneLookupHelper = new TimeZoneLookupHelper(); Loading Loading @@ -750,7 +750,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { } } Script initializeSystemClock(long timeMillis) { Script initializeSystemClock(long timeMillis) { mFakeTimeServiceHelper.currentTimeMillis = timeMillis; mFakeDeviceState.currentTimeMillis = timeMillis; return this; return this; } } Loading Loading @@ -892,22 +892,22 @@ public class NitzStateMachineImplTest extends TelephonyTest { private static class FakeTimeServiceHelper implements TimeServiceHelper { private static class FakeTimeServiceHelper implements TimeServiceHelper { private final FakeDeviceState mFakeDeviceState; public TimeServiceHelper.Listener listener; public TimeServiceHelper.Listener listener; public boolean timeZoneDetectionEnabled; public boolean timeZoneDetectionEnabled; public long currentTimeMillis; // State we want to track. // State we want to track. public TestState<String> deviceTimeZone = new TestState<>(); public TestState<String> deviceTimeZone = new TestState<>(); public TestState<TimestampedValue<Long>> suggestedTime = new TestState<>(); public TestState<TimestampedValue<Long>> suggestedTime = new TestState<>(); @Override FakeTimeServiceHelper(FakeDeviceState fakeDeviceState) { public void setListener(Listener listener) { mFakeDeviceState = fakeDeviceState; this.listener = listener; } } @Override @Override public long currentTimeMillis() { public void setListener(Listener listener) { return currentTimeMillis; this.listener = listener; } } @Override @Override Loading @@ -929,7 +929,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { public void suggestDeviceTime(TimestampedValue<Long> deviceTime) { public void suggestDeviceTime(TimestampedValue<Long> deviceTime) { suggestedTime.set(deviceTime); suggestedTime.set(deviceTime); // The fake time service just uses the latest suggestion. // The fake time service just uses the latest suggestion. currentTimeMillis = deviceTime.getValue(); mFakeDeviceState.currentTimeMillis = deviceTime.getValue(); } } void commitState() { void commitState() { Loading