@Test public void shouldSendSdkHeartBeat_answerIsNo() { sharedPreferences.edit().putLong(testSdk, 1).apply(); assertThat(heartBeatInfoStorage.shouldSendSdkHeartBeat(testSdk, 1)).isFalse(); }
synchronized boolean shouldSendSdkHeartBeat(String heartBeatTag, long millis) { if (sharedPreferences.contains(heartBeatTag)) { long timeElapsed = millis - sharedPreferences.getLong(heartBeatTag, -1); if (timeElapsed >= (long) 1000 * 60 * 60 * 24) { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } return false; } else { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } }
HeartBeatInfoStorage { synchronized boolean shouldSendSdkHeartBeat(String heartBeatTag, long millis) { if (sharedPreferences.contains(heartBeatTag)) { long timeElapsed = millis - sharedPreferences.getLong(heartBeatTag, -1); if (timeElapsed >= (long) 1000 * 60 * 60 * 24) { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } return false; } else { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } } }
HeartBeatInfoStorage { synchronized boolean shouldSendSdkHeartBeat(String heartBeatTag, long millis) { if (sharedPreferences.contains(heartBeatTag)) { long timeElapsed = millis - sharedPreferences.getLong(heartBeatTag, -1); if (timeElapsed >= (long) 1000 * 60 * 60 * 24) { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } return false; } else { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } } private  HeartBeatInfoStorage(Context applicationContext); @VisibleForTesting @RestrictTo(RestrictTo.Scope.TESTS)  HeartBeatInfoStorage(SharedPreferences preferences); }
HeartBeatInfoStorage { synchronized boolean shouldSendSdkHeartBeat(String heartBeatTag, long millis) { if (sharedPreferences.contains(heartBeatTag)) { long timeElapsed = millis - sharedPreferences.getLong(heartBeatTag, -1); if (timeElapsed >= (long) 1000 * 60 * 60 * 24) { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } return false; } else { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } } private  HeartBeatInfoStorage(Context applicationContext); @VisibleForTesting @RestrictTo(RestrictTo.Scope.TESTS)  HeartBeatInfoStorage(SharedPreferences preferences);  }
HeartBeatInfoStorage { synchronized boolean shouldSendSdkHeartBeat(String heartBeatTag, long millis) { if (sharedPreferences.contains(heartBeatTag)) { long timeElapsed = millis - sharedPreferences.getLong(heartBeatTag, -1); if (timeElapsed >= (long) 1000 * 60 * 60 * 24) { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } return false; } else { sharedPreferences.edit().putLong(heartBeatTag, millis).apply(); return true; } } private  HeartBeatInfoStorage(Context applicationContext); @VisibleForTesting @RestrictTo(RestrictTo.Scope.TESTS)  HeartBeatInfoStorage(SharedPreferences preferences);   }