Loading src/java/com/android/internal/telephony/NitzStateMachine.java +8 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.content.ContentResolver; import android.content.Context; import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.telephony.TelephonyManager; Loading Loading @@ -142,5 +143,12 @@ public interface NitzStateMachine { public String getNetworkCountryIsoForPhone() { return mTelephonyManager.getNetworkCountryIsoForPhone(mPhone.getPhoneId()); } /** * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ public long elapsedRealtime() { return SystemClock.elapsedRealtime(); } } } src/java/com/android/internal/telephony/NitzStateMachineImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -326,7 +326,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // Acquire the wake lock as we are reading the elapsed realtime clock below. mWakeLock.acquire(); long elapsedRealtime = mTimeServiceHelper.elapsedRealtime(); long elapsedRealtime = mDeviceState.elapsedRealtime(); long millisSinceNitzReceived = elapsedRealtime - nitzSignal.getReferenceTimeMillis(); if (millisSinceNitzReceived < 0 || millisSinceNitzReceived > Integer.MAX_VALUE) { Loading src/java/com/android/internal/telephony/TimeServiceHelper.java +0 −8 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.Context; import android.content.Intent; import android.database.ContentObserver; import android.os.Handler; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; Loading Loading @@ -90,13 +89,6 @@ public class TimeServiceHelper { return System.currentTimeMillis(); } /** * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ public long elapsedRealtime() { return SystemClock.elapsedRealtime(); } /** * Returns true if the device has an explicit time zone set. */ Loading tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -774,11 +774,11 @@ public class NitzStateMachineImplTest extends TelephonyTest { when(mDeviceState.getIgnoreNitz()).thenReturn(false); when(mDeviceState.getNitzUpdateDiffMillis()).thenReturn(2000); when(mDeviceState.getNitzUpdateSpacingMillis()).thenReturn(1000 * 60 * 10); when(mDeviceState.elapsedRealtime()).thenReturn(mInitialRealtimeMillis); // Simulate the country not being known. when(mDeviceState.getNetworkCountryIsoForPhone()).thenReturn(""); when(mTimeServiceHelper.elapsedRealtime()).thenReturn(mInitialRealtimeMillis); when(mTimeServiceHelper.currentTimeMillis()).thenReturn(mInitialSystemClockMillis); when(mTimeServiceHelper.isTimeZoneDetectionEnabled()) .thenReturn(mTimeZoneDetectionEnabled); Loading Loading @@ -967,7 +967,6 @@ public class NitzStateMachineImplTest extends TelephonyTest { verify(mTimeServiceHelper, atLeast(0)).setListener(any()); verify(mTimeServiceHelper, atLeast(0)).isTimeZoneDetectionEnabled(); verify(mTimeServiceHelper, atLeast(0)).isTimeZoneSettingInitialized(); verify(mTimeServiceHelper, atLeast(0)).elapsedRealtime(); verify(mTimeServiceHelper, atLeast(0)).currentTimeMillis(); verifyNoMoreInteractions(mTimeServiceHelper); } Loading Loading
src/java/com/android/internal/telephony/NitzStateMachine.java +8 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.content.ContentResolver; import android.content.Context; import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.telephony.TelephonyManager; Loading Loading @@ -142,5 +143,12 @@ public interface NitzStateMachine { public String getNetworkCountryIsoForPhone() { return mTelephonyManager.getNetworkCountryIsoForPhone(mPhone.getPhoneId()); } /** * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ public long elapsedRealtime() { return SystemClock.elapsedRealtime(); } } }
src/java/com/android/internal/telephony/NitzStateMachineImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -326,7 +326,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // Acquire the wake lock as we are reading the elapsed realtime clock below. mWakeLock.acquire(); long elapsedRealtime = mTimeServiceHelper.elapsedRealtime(); long elapsedRealtime = mDeviceState.elapsedRealtime(); long millisSinceNitzReceived = elapsedRealtime - nitzSignal.getReferenceTimeMillis(); if (millisSinceNitzReceived < 0 || millisSinceNitzReceived > Integer.MAX_VALUE) { Loading
src/java/com/android/internal/telephony/TimeServiceHelper.java +0 −8 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.content.Context; import android.content.Intent; import android.database.ContentObserver; import android.os.Handler; import android.os.SystemClock; import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; Loading Loading @@ -90,13 +89,6 @@ public class TimeServiceHelper { return System.currentTimeMillis(); } /** * Returns the same value as {@link SystemClock#elapsedRealtime()}. */ public long elapsedRealtime() { return SystemClock.elapsedRealtime(); } /** * Returns true if the device has an explicit time zone set. */ Loading
tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineImplTest.java +1 −2 Original line number Diff line number Diff line Loading @@ -774,11 +774,11 @@ public class NitzStateMachineImplTest extends TelephonyTest { when(mDeviceState.getIgnoreNitz()).thenReturn(false); when(mDeviceState.getNitzUpdateDiffMillis()).thenReturn(2000); when(mDeviceState.getNitzUpdateSpacingMillis()).thenReturn(1000 * 60 * 10); when(mDeviceState.elapsedRealtime()).thenReturn(mInitialRealtimeMillis); // Simulate the country not being known. when(mDeviceState.getNetworkCountryIsoForPhone()).thenReturn(""); when(mTimeServiceHelper.elapsedRealtime()).thenReturn(mInitialRealtimeMillis); when(mTimeServiceHelper.currentTimeMillis()).thenReturn(mInitialSystemClockMillis); when(mTimeServiceHelper.isTimeZoneDetectionEnabled()) .thenReturn(mTimeZoneDetectionEnabled); Loading Loading @@ -967,7 +967,6 @@ public class NitzStateMachineImplTest extends TelephonyTest { verify(mTimeServiceHelper, atLeast(0)).setListener(any()); verify(mTimeServiceHelper, atLeast(0)).isTimeZoneDetectionEnabled(); verify(mTimeServiceHelper, atLeast(0)).isTimeZoneSettingInitialized(); verify(mTimeServiceHelper, atLeast(0)).elapsedRealtime(); verify(mTimeServiceHelper, atLeast(0)).currentTimeMillis(); verifyNoMoreInteractions(mTimeServiceHelper); } Loading