Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

0.8.15 #354

Merged
merged 8 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Corona-Warn-App/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ android {
applicationId 'de.rki.coronawarnapp'
minSdkVersion 23
targetSdkVersion 29
versionCode 22
versionName "0.8.14"
versionCode 23
versionName "0.8.15"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField "String", "DOWNLOAD_CDN_URL", "\"$DOWNLOAD_CDN_URL\""
buildConfigField "String", "SUBMISSION_CDN_URL", "\"$SUBMISSION_CDN_URL\""
buildConfigField "String", "VERIFICATION_CDN_URL", "\"$VERIFICATION_CDN_URL\""
buildConfigField "String", "EXPORT_SIGNATURE_ID", "\"de.rki.coronawarnapp-dev\""

//override URLs. Use local.properties if exist.
// If environment.properties also exist, override local.properties
Expand Down Expand Up @@ -87,14 +86,12 @@ android {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField "String", "EXPORT_SIGNATURE_ID", "\"de.rki.coronawarnapp\""
}
releaseForTest {
applicationIdSuffix '.dev'
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField "String", "EXPORT_SIGNATURE_ID", "\"de.rki.coronawarnapp-dev\""
}
}

Expand Down Expand Up @@ -232,4 +229,6 @@ dependencies {
implementation 'net.zetetic:android-database-sqlcipher:4.4.0'
implementation 'org.conscrypt:conscrypt-android:2.4.0'

// LOGGING
implementation 'com.jakewharton.timber:timber:4.7.1'
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
de.rki.coronawarnapp-dev=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE3BYTxr2HuJYQG+d7Ezu6KS8GEbFkiEvyJFg0j+C839gTjT6j7Ho0EXXZ/a07ZfvKcC2cmc1SunsrqU9Jov1J5Q==
de.rki.coronawarnapp.dev=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE3BYTxr2HuJYQG+d7Ezu6KS8GEbFkiEvyJFg0j+C839gTjT6j7Ho0EXXZ/a07ZfvKcC2cmc1SunsrqU9Jov1J5Q==
de.rki.coronawarnapp=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEc7DEstcUIRcyk35OYDJ95/hTg3UVhsaDXKT0zK7NhHPXoyzipEnOp3GyNXDVpaPi3cAfQmxeuFMZAIX2+6A5Xg==
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.content.Context
import android.content.IntentFilter
import android.content.pm.ActivityInfo
import android.os.Bundle
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
Expand All @@ -17,6 +16,7 @@ import de.rki.coronawarnapp.exception.reporting.ErrorReportReceiver
import de.rki.coronawarnapp.exception.reporting.ReportingConstants.ERROR_REPORT_LOCAL_BROADCAST_CHANNEL
import de.rki.coronawarnapp.notification.NotificationHelper
import org.conscrypt.Conscrypt
import timber.log.Timber
import java.security.Security

class CoronaWarnApplication : Application(), LifecycleObserver,
Expand Down Expand Up @@ -47,6 +47,10 @@ class CoronaWarnApplication : Application(), LifecycleObserver,
Security.insertProviderAt(Conscrypt.newProvider(), 1)
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
registerActivityLifecycleCallbacks(this)

if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
}

/**
Expand All @@ -55,7 +59,7 @@ class CoronaWarnApplication : Application(), LifecycleObserver,
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun onAppBackgrounded() {
isAppInForeground = false
Log.v(TAG, "App backgrounded")
Timber.v("App backgrounded")
}

/**
Expand All @@ -64,7 +68,7 @@ class CoronaWarnApplication : Application(), LifecycleObserver,
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onAppForegrounded() {
isAppInForeground = true
Log.v(TAG, "App foregrounded")
Timber.v("App foregrounded")
}

override fun onActivityPaused(activity: Activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.graphics.Bitmap
import android.graphics.Color
import android.os.Bundle
import android.util.Base64
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -78,6 +77,7 @@ import kotlinx.android.synthetic.main.fragment_test_for_a_p_i.text_scanned_key
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.File
import java.lang.reflect.Type
import java.util.UUID
Expand All @@ -86,8 +86,6 @@ import java.util.UUID
class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHelper.Callback {

companion object {
val TAG: String? = TestForAPIFragment::class.simpleName

const val CONFIG_SCORE = 8

fun keysToJson(keys: List<TemporaryExposureKey>): String {
Expand Down Expand Up @@ -282,7 +280,7 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel
}

private val onScannedKey = { key: AppleLegacyKeyExchange.Key? ->
Log.i(TAG, "keys scanned..")
Timber.i("keys scanned..")
key?.let {
text_scanned_key.text = prettyKey(key)
text_scanned_key.visibility = View.VISIBLE
Expand Down Expand Up @@ -366,10 +364,7 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel
lifecycleScope.launch {
googleFileList = KeyFileHelper.asyncCreateExportFiles(appleFiles, dir)

Log.i(
TAG,
"Provide ${googleFileList.count()} files with ${appleKeyList.size} keys with token $token"
)
Timber.i("Provide ${googleFileList.count()} files with ${appleKeyList.size} keys with token $token")
try {
// only testing implementation: this is used to wait for the broadcastreceiver of the OS / EN API
InternalExposureNotificationClient.asyncProvideDiagnosisKeys(
Expand All @@ -386,21 +381,16 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel
}

private fun checkExposure() {
Log.d(
TAG,
"Check Exposure with token $token"
)
Timber.d("Check Exposure with token $token")

lifecycleScope.launch {
try {
val exposureSummary =
InternalExposureNotificationClient.asyncGetExposureSummary(token!!)
updateExposureSummaryDisplay(exposureSummary)
showToast("Updated Exposure Summary with token $token")
Log.d(
TAG, "Received exposure with token $token from QR Code"
)
Log.i(TAG, exposureSummary.toString())
Timber.d("Received exposure with token $token from QR Code")
Timber.i(exposureSummary.toString())
} catch (e: Exception) {
e.report(ExceptionCategory.EXPOSURENOTIFICATION)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package de.rki.coronawarnapp

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -41,6 +40,7 @@ import kotlinx.android.synthetic.main.fragment_test_risk_level_calculation.trans
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.File
import java.util.UUID
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -171,7 +171,7 @@ class TestRiskLevelCalculation : Fragment() {
}

private val onScannedKey = { key: AppleLegacyKeyExchange.Key? ->
Log.i(TestForAPIFragment.TAG, "keys scanned..")
Timber.i("keys scanned..")
provideDiagnosisKey(key)
}

Expand Down Expand Up @@ -214,10 +214,7 @@ class TestRiskLevelCalculation : Fragment() {
lifecycleScope.launch {
googleFileList = KeyFileHelper.asyncCreateExportFiles(appleFiles, dir)

Log.i(
TAG,
"Provide ${googleFileList.count()} files with ${appleKeyList.size} keys with token $token"
)
Timber.i("Provide ${googleFileList.count()} files with ${appleKeyList.size} keys with token $token")
try {
// only testing implementation: this is used to wait for the broadcastreceiver of the OS / EN API
InternalExposureNotificationClient.asyncProvideDiagnosisKeys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import android.app.Activity
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.exception.ExceptionCategory
import de.rki.coronawarnapp.util.DialogHelper
import timber.log.Timber
import java.util.Locale

class ErrorReportReceiver(private val activity: Activity) : BroadcastReceiver() {
Expand Down Expand Up @@ -67,9 +67,6 @@ class ErrorReportReceiver(private val activity: Activity) : BroadcastReceiver()
}
))
}
Log.e(
TAG,
"[$category]${(prefix ?: "")} $message${(suffix ?: "")}"
)
Timber.e("[$category]${(prefix ?: "")} $message${(suffix ?: "")}")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package de.rki.coronawarnapp.http

import KeyExportFormat
import android.util.Log
import com.google.protobuf.InvalidProtocolBufferException
import de.rki.coronawarnapp.exception.ApplicationConfigurationCorruptException
import de.rki.coronawarnapp.exception.ApplicationConfigurationInvalidException
Expand All @@ -40,6 +39,7 @@ import de.rki.coronawarnapp.util.security.SecurityHelper
import de.rki.coronawarnapp.util.security.VerificationKeys
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import timber.log.Timber
import java.io.File
import java.util.Date
import java.util.UUID
Expand Down Expand Up @@ -97,13 +97,12 @@ class WebRequestBuilder(
suspend fun asyncGetKeyFilesFromServer(
url: String
): File = withContext(Dispatchers.IO) {
val requestID = UUID.randomUUID()
val fileName = "${UUID.nameUUIDFromBytes(url.toByteArray())}.zip"
val file = File(FileStorageHelper.keyExportDirectory, fileName)
file.outputStream().use {
Log.v(requestID.toString(), "Added $url to queue.")
Timber.v("Added $url to queue.")
distributionService.getKeyFiles(url).byteStream().copyTo(it, DEFAULT_BUFFER_SIZE)
Log.v(requestID.toString(), "key file request successful.")
Timber.v("key file request successful.")
}
return@withContext file
}
Expand Down Expand Up @@ -176,7 +175,7 @@ class WebRequestBuilder(
faked: Boolean,
keyList: List<KeyExportFormat.TemporaryExposureKey>
) = withContext(Dispatchers.IO) {
Log.d(TAG, "Writing ${keyList.size} Keys to the Submission Payload.")
Timber.d("Writing ${keyList.size} Keys to the Submission Payload.")
val submissionPayload = KeyExportFormat.SubmissionPayload.newBuilder()
.addAllKeys(keyList)
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.rki.coronawarnapp.http.interceptor

import android.util.Log
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
import timber.log.Timber

class RetryInterceptor : Interceptor {
companion object {
Expand All @@ -15,7 +15,7 @@ class RetryInterceptor : Interceptor {
var response = chain.proceed(request)
var tryCount = 0
while (!response.isSuccessful && tryCount < MAX_RETRY_COUNT) {
Log.d(this.javaClass.simpleName, "Request is not successful - $tryCount")
Timber.d("Request is not successful - $tryCount")
tryCount++
response = chain.proceed(request)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.rki.coronawarnapp.nearby

import android.content.Context
import android.util.Log
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import com.google.android.gms.common.api.ApiException
Expand All @@ -12,6 +11,7 @@ import de.rki.coronawarnapp.exception.TransactionException
import de.rki.coronawarnapp.exception.reporting.report
import de.rki.coronawarnapp.storage.ExposureSummaryRepository
import de.rki.coronawarnapp.transaction.RiskLevelTransaction
import timber.log.Timber

class ExposureStateUpdateWorker(val context: Context, workerParams: WorkerParameters) :
CoroutineWorker(context, workerParams) {
Expand All @@ -21,21 +21,21 @@ class ExposureStateUpdateWorker(val context: Context, workerParams: WorkerParame

override suspend fun doWork(): Result {
try {
Log.v(TAG, "worker to persist exposure summary started")
Timber.v("worker to persist exposure summary started")
val token = inputData.getString(ExposureNotificationClient.EXTRA_TOKEN)
?: throw NoTokenException(IllegalArgumentException("no token was found in the intent"))

Log.v(TAG, "valid token $token retrieved")
Timber.v("valid token $token retrieved")

val exposureSummary = InternalExposureNotificationClient
.asyncGetExposureSummary(token)

ExposureSummaryRepository.getExposureSummaryRepository()
.insertExposureSummaryEntity(exposureSummary)
Log.v(TAG, "exposure summary state updated: $exposureSummary")
Timber.v("exposure summary state updated: $exposureSummary")

RiskLevelTransaction.start()
Log.v(TAG, "risk level calculation triggered")
Timber.v("risk level calculation triggered")
} catch (e: ApiException) {
e.report(ExceptionCategory.EXPOSURENOTIFICATION)
} catch (e: TransactionException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import android.content.Intent
import android.media.AudioAttributes
import android.media.RingtoneManager
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import de.rki.coronawarnapp.BuildConfig
import de.rki.coronawarnapp.CoronaWarnApplication
import de.rki.coronawarnapp.ui.main.MainActivity
import timber.log.Timber
import kotlin.random.Random

/**
Expand Down Expand Up @@ -172,9 +172,9 @@ object NotificationHelper {
private fun logNotificationBuild(notification: Notification?) {
if (BuildConfig.DEBUG) {
if (notification != null) {
Log.d(TAG, "Notification build successfully.")
Timber.d("Notification build successfully.")
} else {
Log.d(TAG, "Notification build failed.")
Timber.d("Notification build failed.")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.rki.coronawarnapp.risk

import android.util.Log
import com.google.android.gms.nearby.exposurenotification.ExposureSummary
import de.rki.coronawarnapp.server.protocols.ApplicationConfigurationOuterClass
import timber.log.Timber
import kotlin.math.round

object RiskLevelCalculation {
Expand Down Expand Up @@ -31,24 +31,18 @@ object RiskLevelCalculation {
val defaultBucketOffset = attenuationParameters.defaultBucketOffset.toDouble()
val normalizationDivisor = attenuationParameters.riskScoreNormalizationDivisor.toDouble()

Log.v(
TAG,
"Weighted Attenuation: ($weightedAttenuationLow +" +
" $weightedAttenuationMid +" +
" $weightedAttenuationHigh +" +
" $defaultBucketOffset)"
)
val attenuationStrings =
"Weighted Attenuation: ($weightedAttenuationLow + $weightedAttenuationMid + " +
"$weightedAttenuationHigh + $defaultBucketOffset)"
Timber.v(attenuationStrings)

val weightedAttenuationDuration =
weightedAttenuationLow
.plus(weightedAttenuationMid)
.plus(weightedAttenuationHigh)
.plus(defaultBucketOffset)

Log.v(
TAG,
"Formula used: ($maximumRiskScore / $normalizationDivisor) * $weightedAttenuationDuration"
)
Timber.v("Formula used: ($maximumRiskScore / $normalizationDivisor) * $weightedAttenuationDuration")

val riskScore = (maximumRiskScore / normalizationDivisor) * weightedAttenuationDuration

Expand Down
Loading