@Test public void handleInjectNtpTime_cachedAgeLow_injectTime() throws InterruptedException { doReturn(NtpTimeHelper.NTP_INTERVAL - 1).when(mMockNtpTrustedTime).getCacheAge(); doReturn(MOCK_NTP_TIME).when(mMockNtpTrustedTime).getCachedNtpTime(); mNtpTimeHelper.retrieveAndInjectNtpTime(); waitForTasksToBePostedOnHandlerAndRunThem(); assertThat(mCountDownLatch.await(2, TimeUnit.SECONDS)).isTrue(); }
synchronized void retrieveAndInjectNtpTime() { if (mInjectNtpTimeState == STATE_RETRIEVING_AND_INJECTING) { return; } if (!isNetworkConnected()) { mInjectNtpTimeState = STATE_PENDING_NETWORK; return; } mInjectNtpTimeState = STATE_RETRIEVING_AND_INJECTING; mWakeLock.acquire(WAKELOCK_TIMEOUT_MILLIS); new Thread(this::blockingGetNtpTimeAndInject).start(); }
NtpTimeHelper { synchronized void retrieveAndInjectNtpTime() { if (mInjectNtpTimeState == STATE_RETRIEVING_AND_INJECTING) { return; } if (!isNetworkConnected()) { mInjectNtpTimeState = STATE_PENDING_NETWORK; return; } mInjectNtpTimeState = STATE_RETRIEVING_AND_INJECTING; mWakeLock.acquire(WAKELOCK_TIMEOUT_MILLIS); new Thread(this::blockingGetNtpTimeAndInject).start(); } }
NtpTimeHelper { synchronized void retrieveAndInjectNtpTime() { if (mInjectNtpTimeState == STATE_RETRIEVING_AND_INJECTING) { return; } if (!isNetworkConnected()) { mInjectNtpTimeState = STATE_PENDING_NETWORK; return; } mInjectNtpTimeState = STATE_RETRIEVING_AND_INJECTING; mWakeLock.acquire(WAKELOCK_TIMEOUT_MILLIS); new Thread(this::blockingGetNtpTimeAndInject).start(); } @VisibleForTesting  NtpTimeHelper(Context context, Looper looper, InjectNtpTimeCallback callback,
            NtpTrustedTime ntpTime);   NtpTimeHelper(Context context, Looper looper, InjectNtpTimeCallback callback); }
NtpTimeHelper { synchronized void retrieveAndInjectNtpTime() { if (mInjectNtpTimeState == STATE_RETRIEVING_AND_INJECTING) { return; } if (!isNetworkConnected()) { mInjectNtpTimeState = STATE_PENDING_NETWORK; return; } mInjectNtpTimeState = STATE_RETRIEVING_AND_INJECTING; mWakeLock.acquire(WAKELOCK_TIMEOUT_MILLIS); new Thread(this::blockingGetNtpTimeAndInject).start(); } @VisibleForTesting  NtpTimeHelper(Context context, Looper looper, InjectNtpTimeCallback callback,
            NtpTrustedTime ntpTime);   NtpTimeHelper(Context context, Looper looper, InjectNtpTimeCallback callback);  }
NtpTimeHelper { synchronized void retrieveAndInjectNtpTime() { if (mInjectNtpTimeState == STATE_RETRIEVING_AND_INJECTING) { return; } if (!isNetworkConnected()) { mInjectNtpTimeState = STATE_PENDING_NETWORK; return; } mInjectNtpTimeState = STATE_RETRIEVING_AND_INJECTING; mWakeLock.acquire(WAKELOCK_TIMEOUT_MILLIS); new Thread(this::blockingGetNtpTimeAndInject).start(); } @VisibleForTesting  NtpTimeHelper(Context context, Looper looper, InjectNtpTimeCallback callback,
            NtpTrustedTime ntpTime);   NtpTimeHelper(Context context, Looper looper, InjectNtpTimeCallback callback);   }