Skip to content

Commit

Permalink
Merge pull request #149 from DP-3T/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
simonroesch authored Jun 11, 2020
2 parents b55f636 + 8df9bec commit 7fe17d1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for DP3T-SDK Android

## Version 0.5.5 (11.6.2020)

- improve history logging

## Version 0.5.4 (11.6.2020)

- bugfix for user-visible logs
Expand Down
4 changes: 2 additions & 2 deletions dp3t-sdk/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
defaultConfig {
minSdkVersion 23
targetSdkVersion 29
versionCode 54
versionName "0.5.4"
versionCode 55
versionName "0.5.5"
testInstrumentationRunnerArgument 'androidx.benchmark.suppressErrors', 'EMULATOR,LOW-BATTERY,ACTIVITY-MISSING,DEBUGGABLE,UNLOCKED,UNSUSTAINED-ACTIVITY-MISSING'
testInstrumentationRunner "androidx.benchmark.junit4.AndroidBenchmarkRunner"

Expand Down
9 changes: 5 additions & 4 deletions dp3t-sdk/sdk/src/main/java/org/dpppt/android/sdk/DP3T.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import org.dpppt.android.sdk.internal.backend.StatusCodeException;
import org.dpppt.android.sdk.internal.backend.SyncErrorState;
import org.dpppt.android.sdk.internal.backend.models.GaenRequest;
import org.dpppt.android.sdk.internal.history.HistoryEntryType;
import org.dpppt.android.sdk.internal.history.HistoryDatabase;
import org.dpppt.android.sdk.internal.history.HistoryEntry;
import org.dpppt.android.sdk.internal.history.HistoryEntryType;
import org.dpppt.android.sdk.internal.logger.Logger;
import org.dpppt.android.sdk.internal.nearby.GaenStateCache;
import org.dpppt.android.sdk.internal.nearby.GaenStateHelper;
Expand Down Expand Up @@ -413,18 +413,19 @@ public static void clearData(Context context) {
Logger.clear();
}

public static void clientOpened(Context context) {
public static void addClientOpenedToHistory(Context context) {
HistoryDatabase historyDatabase = HistoryDatabase.getInstance(context);
Calendar calendar = new GregorianCalendar();
historyDatabase.addEntry(new HistoryEntry(HistoryEntryType.OPEN_APP, null, true, calendar.getTimeInMillis()));
calendar.add(Calendar.DAY_OF_YEAR, -1 * HISTORY_KEEP_FOR_DAYS);
historyDatabase.clearBefore(calendar.getTimeInMillis());
}

public static void fakeWorkerScheduled(Context context) {
public static void addWorkerStartedToHistory(Context context, String workerName) {
if (AppConfigManager.getInstance(context).getDevHistory()) {
HistoryDatabase historyDatabase = HistoryDatabase.getInstance(context);
historyDatabase.addEntry(new HistoryEntry(HistoryEntryType.SCHEDULED_WORKER, "Fake", true, System.currentTimeMillis()));
historyDatabase
.addEntry(new HistoryEntry(HistoryEntryType.WORKER_STARTED, workerName, true, System.currentTimeMillis()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public static void startSyncWorker(Context context) {
WorkManager workManager = WorkManager.getInstance(context);
workManager.enqueueUniquePeriodicWork(WORK_TAG, ExistingPeriodicWorkPolicy.KEEP, periodicWorkRequest);

if (AppConfigManager.getInstance(context).getDevHistory()) {
HistoryDatabase.getInstance(context)
.addEntry(new HistoryEntry(HistoryEntryType.SCHEDULED_WORKER, "Sync", true, System.currentTimeMillis()));
}

Logger.d(TAG, "scheduled SyncWorker");
}

Expand All @@ -97,6 +92,11 @@ public Result doWork() {
Logger.d(TAG, "start SyncWorker");
Context context = getApplicationContext();

if (AppConfigManager.getInstance(context).getDevHistory()) {
HistoryDatabase.getInstance(context)
.addEntry(new HistoryEntry(HistoryEntryType.WORKER_STARTED, "Sync", true, System.currentTimeMillis()));
}

try {
doSync(context);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public enum HistoryEntryType {
OPEN_APP(0),
SYNC(1),
SCHEDULED_WORKER(2),
WORKER_STARTED(2),
FAKE_REQUEST(3),
NEXT_DAY_KEY_UPLOAD_REQUEST(4);

Expand Down

0 comments on commit 7fe17d1

Please sign in to comment.