Skip to content

Commit

Permalink
Merge pull request #277 from DP-3T/develop
Browse files Browse the repository at this point in the history
Version 1.3.1
  • Loading branch information
simonroesch committed Jan 22, 2021
2 parents 70fac87 + b25ed18 commit 2701812
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ android {
applicationId "ch.admin.bag.dp3t"
minSdkVersion 23
targetSdkVersion 30
versionCode 13000
versionName "1.3.0"
versionCode 13010
versionName "1.3.1"
resConfigs "en", "fr", "de", "it", "pt", "es", "sq", "bs", "hr", "sr", "rm", "tr", "ti"

buildConfigField "long", "BUILD_TIME", readPropertyWithDefault('buildTimestamp', System.currentTimeMillis()) + 'L'
Expand Down Expand Up @@ -152,7 +152,7 @@ sonarqube {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

def dp3t_sdk_version = '2.0.1'
def dp3t_sdk_version = '2.0.2'
devImplementation "org.dpppt:dp3t-sdk-android:$dp3t_sdk_version-calibration"
teschtImplementation "org.dpppt:dp3t-sdk-android:$dp3t_sdk_version"
abnahmeImplementation "org.dpppt:dp3t-sdk-android:$dp3t_sdk_version"
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/java/ch/admin/bag/dp3t/networking/FakeWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import androidx.work.*;

import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand All @@ -40,7 +39,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;
public static final float SAMPLING_RATE = BuildConfig.FLAVOR.equals("dev") ? 1.0f : 0.2f;
private static final String KEY_T_DUMMY = "KEY_T_DUMMY";

public static Clock clock = new ClockImpl();

Expand Down Expand Up @@ -73,7 +71,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 @@ -88,7 +85,15 @@ public FakeWorker(@NonNull Context context, @NonNull WorkerParameters workerPara
@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 @@ -105,7 +110,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 2701812

Please sign in to comment.