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

Commit 8ef16d2b authored by Neil Fuller's avatar Neil Fuller Committed by android-build-merger
Browse files

Merge "Move elapsedRealtime() method to DeviceState" am: 8bb24557

am: 7af0226c

Change-Id: I2311f7ef65d70521bfdb52358ac1f259d08f9d1e
parents 8bee46d5 7af0226c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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();
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -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) {
+0 −8
Original line number Diff line number Diff line
@@ -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;
@@ -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.
     */
+1 −2
Original line number Diff line number Diff line
@@ -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);
@@ -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);
    }