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

Commit

Permalink
Merge pull request #226 from corona-warn-app/dev
Browse files Browse the repository at this point in the history
0.8.4
  • Loading branch information
htooisap authored Jun 6, 2020
2 parents 52f1c24 + b596a87 commit 7dd4f29
Show file tree
Hide file tree
Showing 154 changed files with 5,469 additions and 7,200 deletions.
4 changes: 2 additions & 2 deletions Corona-Warn-App/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ android {
applicationId 'de.rki.coronawarnapp'
minSdkVersion 23
targetSdkVersion 29
versionCode 10
versionName "0.8.3"
versionCode 11
versionName "0.8.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField "String", "DOWNLOAD_CDN_URL", "\"$DOWNLOAD_CDN_URL\""
Expand Down
3 changes: 3 additions & 0 deletions Corona-Warn-App/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>

-keep class de.rki.coronawarnapp.http.requests.* { *; }
-keep class de.rki.coronawarnapp.http.responses.* { *; }
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.lifecycle.ProcessLifecycleOwner
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import de.rki.coronawarnapp.exception.ErrorReportReceiver
import de.rki.coronawarnapp.exception.ReportingConstants.ERROR_REPORT_LOCAL_BROADCAST_CHANNEL
import de.rki.coronawarnapp.exception.handler.GlobalExceptionHandler
import de.rki.coronawarnapp.notification.NotificationHelper
import org.conscrypt.Conscrypt
import java.security.Security
Expand All @@ -43,7 +42,6 @@ class CoronaWarnApplication : Application(), LifecycleObserver,

override fun onCreate() {
super.onCreate()
GlobalExceptionHandler(this)
instance = this
NotificationHelper.createNotificationChannel()
// Enable Conscrypt for TLS1.3 Support below API Level 29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,13 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel
}

private fun bitmapForImage(key: TemporaryExposureKey): Bitmap {
val key = AppleLegacyKeyExchange.Key.newBuilder()
val legacyKey = AppleLegacyKeyExchange.Key.newBuilder()
.setKeyData(ByteString.copyFrom(key.keyData))
.setRollingPeriod(key.rollingPeriod)
.setRollingStartNumber(key.rollingStartIntervalNumber)
.build().toByteArray()
val bMatrix = QRCodeWriter().encode(
Base64.encodeToString(key, Base64.DEFAULT),
Base64.encodeToString(legacyKey, Base64.DEFAULT),
BarcodeFormat.QR_CODE,
300,
300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import java.io.File
import java.util.UUID
import java.util.concurrent.TimeUnit

@Suppress("MagicNumber")
@Suppress("MagicNumber", "LongMethod")
class TestRiskLevelCalculation : Fragment() {
companion object {
val TAG: String? = TestRiskLevelCalculation::class.simpleName
Expand Down Expand Up @@ -305,6 +305,27 @@ class TestRiskLevelCalculation : Fragment() {
binding.labelFormula.text = formulaString

binding.labelFullConfig.text = it.appConfig?.toString()

val token = LocalData.googleApiToken()
if (token != null) {
val exposureInformation =
InternalExposureNotificationClient.asyncGetExposureInformation(token)

var infoString = ""
exposureInformation.forEach {
infoString += "Attenuation duration in min.: " +
"[${it.attenuationDurationsInMinutes?.get(0)}, " +
"${it.attenuationDurationsInMinutes?.get(1)}," +
"${it.attenuationDurationsInMinutes?.get(2)}]\n" +
"Attenuation value: ${it.attenuationValue}\n" +
"Duration in min.: ${it.durationMinutes}\n" +
"Risk Score: ${it.totalRiskScore}\n" +
"Transmission Risk Level: ${it.transmissionRiskLevel}\n" +
"Date Millis Since Epoch: ${it.dateMillisSinceEpoch}\n\n"
}

binding.labelExposureInfo.text = infoString
}
}
})
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.rki.coronawarnapp.nearby
import com.google.android.gms.nearby.Nearby
import com.google.android.gms.nearby.exposurenotification.ExposureConfiguration
import com.google.android.gms.nearby.exposurenotification.ExposureConfiguration.ExposureConfigurationBuilder
import com.google.android.gms.nearby.exposurenotification.ExposureInformation
import com.google.android.gms.nearby.exposurenotification.ExposureSummary
import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey
import de.rki.coronawarnapp.CoronaWarnApplication
Expand Down Expand Up @@ -156,4 +157,15 @@ object InternalExposureNotificationClient {
cont.resumeWithException(it)
}
}

// todo remove before release - not used in prod setup - only for testing
suspend fun asyncGetExposureInformation(token: String): List<ExposureInformation> =
suspendCoroutine { cont ->
exposureNotificationClient.getExposureInformation(token)
.addOnSuccessListener {
cont.resume(it)
}.addOnFailureListener {
cont.resumeWithException(it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ object FileStorageHelper {
* Get key files export directory used to store all export files for the transaction
* Uses FileStorageConstants.KEY_EXPORT_DIRECTORY_NAME constant
*
* TODO Change to CacheDir before release
*
* @return File of key export directory
*/
val keyExportDirectory = File(
CoronaWarnApplication.getAppContext().getExternalFilesDir(null),
CoronaWarnApplication.getAppContext().cacheDir,
FileStorageConstants.KEY_EXPORT_DIRECTORY_NAME
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import de.rki.coronawarnapp.risk.RiskLevelConstants
object RiskLevelRepository {

/**
* LiveData variable that can be consumed in a ViewModel to observe RiskLevel changes
* LiveData variables that can be consumed in a ViewModel to observe RiskLevel changes
*/
val riskLevelScore = MutableLiveData(RiskLevelConstants.UNKNOWN_RISK_INITIAL)
val riskLevelScoreLastSuccessfulCalculated = MutableLiveData(LocalData.lastSuccessfullyCalculatedRiskLevel().raw)

/**
* Set the new calculated [RiskLevel]
Expand Down Expand Up @@ -61,6 +62,7 @@ object RiskLevelRepository {
private fun setLastSuccessfullyCalculatedScore(riskLevel: RiskLevel) {
if (!RiskLevel.UNSUCCESSFUL_RISK_LEVELS.contains(riskLevel)) {
LocalData.lastSuccessfullyCalculatedRiskLevel(riskLevel.raw)
riskLevelScoreLastSuccessfulCalculated.postValue(riskLevel.raw)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class KeyCacheRepository(private val keyCacheDao: KeyCacheDao) {
)

suspend fun deleteOutdatedEntries() = keyCacheDao.getAllEntries().forEach {
if (File(it.path).isOutdated()) {
val file = File(it.path)
if (file.isOutdated() || !file.exists()) {
deleteFileForEntry(it)
keyCacheDao.deleteEntry(it)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,28 @@ import android.net.Uri
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import de.rki.coronawarnapp.exception.handler.GlobalExceptionHandlerConstants
import androidx.lifecycle.lifecycleScope
import de.rki.coronawarnapp.http.DynamicURLs
import de.rki.coronawarnapp.storage.LocalData
import de.rki.coronawarnapp.ui.main.MainActivity
import de.rki.coronawarnapp.ui.onboarding.OnboardingActivity
import de.rki.coronawarnapp.update.UpdateChecker
import kotlinx.coroutines.launch

class LauncherActivity : AppCompatActivity() {
companion object {
private val TAG: String? = LauncherActivity::class.simpleName
}

private lateinit var updateChecker: UpdateChecker

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
retrieveCustomURLsFromSchema(intent.data)
updateChecker = UpdateChecker(this)

if (LocalData.isOnboarded()) {
startMainActivity()
} else {
startOnboardingActivity()
lifecycleScope.launch {
updateChecker.checkForUpdate()
}
}

Expand Down Expand Up @@ -55,34 +58,31 @@ class LauncherActivity : AppCompatActivity() {
}
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

updateChecker.onActivityResult(requestCode, resultCode)
}

fun navigateToActivities() {
if (LocalData.isOnboarded()) {
startMainActivity()
} else {
startOnboardingActivity()
}
}

private fun startOnboardingActivity() {
val onboardingActivity = Intent(this, OnboardingActivity::class.java)
mapIntentExtras(onboardingActivity)
startActivity(onboardingActivity)
this.overridePendingTransition(0, 0)
finish()
}

private fun startMainActivity() {
val mainActivityIntent = Intent(this, MainActivity::class.java)
mapIntentExtras(mainActivityIntent)
startActivity(mainActivityIntent)
this.overridePendingTransition(0, 0)
finish()
}

/**
* Maps the intentExtras for global exception handling to the next activity that is
* started
*
* @param intentForNextActivity
*/
private fun mapIntentExtras(intentForNextActivity: Intent) {
intentForNextActivity.putExtra(
GlobalExceptionHandlerConstants.APP_CRASHED,
intent.getBooleanExtra(GlobalExceptionHandlerConstants.APP_CRASHED, false)
)
intentForNextActivity.putExtra(
GlobalExceptionHandlerConstants.STACK_TRACE,
intent.getStringExtra(GlobalExceptionHandlerConstants.STACK_TRACE)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package de.rki.coronawarnapp.ui.main

import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.ViewModelProviders
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.ui.showDialogWithStacktraceIfPreviouslyCrashed
import de.rki.coronawarnapp.ui.viewmodel.SettingsViewModel
import de.rki.coronawarnapp.util.ConnectivityHelper
import de.rki.coronawarnapp.worker.BackgroundWorkScheduler
Expand Down Expand Up @@ -69,10 +67,8 @@ class MainActivity : AppCompatActivity() {
super.onResume()
ConnectivityHelper.registerNetworkStatusCallback(this, callbackNetwork)
ConnectivityHelper.registerBluetoothStatusCallback(this, callbackBluetooth)
Log.d(TAG, "Background work is available: ${!ConnectivityHelper.isDataSaverEnabled(this)}")
settingsViewModel.updateBackgroundJobEnabled(!ConnectivityHelper.isDataSaverEnabled(this))
settingsViewModel.updateBackgroundJobEnabled(ConnectivityHelper.isBackgroundJobEnabled(this))
scheduleWork()
showDialogWithStacktraceIfPreviouslyCrashed()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.lifecycle.LifecycleObserver
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.storage.LocalData
import de.rki.coronawarnapp.ui.main.MainActivity
import de.rki.coronawarnapp.ui.showDialogWithStacktraceIfPreviouslyCrashed

/**
* This activity holds all the onboarding fragments and isn't used after a successful onboarding flow.
Expand Down Expand Up @@ -41,11 +40,6 @@ class OnboardingActivity : AppCompatActivity(), LifecycleObserver {
)
}

override fun onResume() {
super.onResume()
showDialogWithStacktraceIfPreviouslyCrashed()
}

fun completeOnboarding() {
LocalData.isOnboarded(true)
LocalData.onboardingCompletedTimestamp(System.currentTimeMillis())
Expand Down
Loading

0 comments on commit 7dd4f29

Please sign in to comment.