Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Bump DP3T Android SDK to 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
djcouto committed Jan 25, 2021
1 parent 18e37cc commit 6bf6423
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

def dp3t_sdk_version = '2.0.1'
def dp3t_sdk_version = '2.0.2'
debugImplementation "org.dpppt:dp3t-sdk-android:$dp3t_sdk_version-calibration"
stagingImplementation "org.dpppt:dp3t-sdk-android:$dp3t_sdk_version"
releaseImplementation "org.dpppt:dp3t-sdk-android:$dp3t_sdk_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public class FakeWorker extends Worker {
private static final long FACTOR_DAY_MILLIS = 24 * FACTOR_HOUR_MILLIS;
private static final long MAX_DELAY_HOURS = 48;
private static final float SAMPLING_RATE = BuildConfig.IS_RELEASE.equals("TRUE") ? 0.2f : 1.0f;
private static final String KEY_T_DUMMY = "KEY_T_DUMMY";

public static Clock clock = new ClockImpl();

Expand Down Expand Up @@ -90,7 +89,6 @@ private static void startFakeWorker(Context context, ExistingWorkPolicy policy,
OneTimeWorkRequest fakeWorker = new OneTimeWorkRequest.Builder(FakeWorker.class)
.setConstraints(constraints)
.setInitialDelay(executionDelay, TimeUnit.MILLISECONDS)
.setInputData(new Data.Builder().putLong(KEY_T_DUMMY, t_dummy).build())
.addTag(WORK_TAG)
.build();

Expand All @@ -101,7 +99,15 @@ private static void startFakeWorker(Context context, ExistingWorkPolicy policy,
@Override
public ListenableWorker.Result doWork() {
long now = clock.currentTimeMillis();
long t_dummy = getInputData().getLong(KEY_T_DUMMY, now);
SecureStorage secureStorage = SecureStorage.getInstance(getApplicationContext());
long t_dummy = secureStorage.getTDummy();
if (t_dummy < 0) {
//if t_dummy < 0 because of some weird state, we reset it
t_dummy = now + clock.syncInterval();
}
//to make sure we can still write the EncryptedSharedPreferences, we always write the value back
secureStorage.setTDummy(t_dummy);

while (t_dummy < now) {
Logger.d(TAG, "start");
// only do request if it was planned to do in the last 48h
Expand All @@ -118,7 +124,7 @@ public ListenableWorker.Result doWork() {
Logger.d(TAG, "outdated request is dropped.");
}
t_dummy += clock.syncInterval();
SecureStorage.getInstance(getApplicationContext()).setTDummy(t_dummy);
secureStorage.setTDummy(t_dummy);
}

startFakeWorker(getApplicationContext(), ExistingWorkPolicy.APPEND, t_dummy);
Expand Down

0 comments on commit 6bf6423

Please sign in to comment.