Skip to content
Snippets Groups Projects
Unverified Commit d43c92be authored by Mohamed's avatar Mohamed Committed by GitHub
Browse files

Clean up (DEV) (#2802)

parent bb1a9f91
No related branches found
No related tags found
No related merge requests found
Showing
with 26 additions and 20 deletions
...@@ -173,7 +173,8 @@ android { ...@@ -173,7 +173,8 @@ android {
"-Xno-kotlin-nothing-value-exception", "-Xno-kotlin-nothing-value-exception",
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview", "-Xuse-experimental=kotlinx.coroutines.FlowPreview",
"-Xuse-experimental=kotlin.time.ExperimentalTime" "-Xuse-experimental=kotlin.time.ExperimentalTime",
"-Xopt-in=kotlin.RequiresOptIn"
] ]
} }
} }
......
...@@ -28,6 +28,7 @@ class AppConfigTestFragment : Fragment(R.layout.fragment_test_appconfig), AutoIn ...@@ -28,6 +28,7 @@ class AppConfigTestFragment : Fragment(R.layout.fragment_test_appconfig), AutoIn
private val timeFormatter = ISODateTimeFormat.dateTime() private val timeFormatter = ISODateTimeFormat.dateTime()
.withZone(DateTimeZone.forID("Europe/Berlin")) .withZone(DateTimeZone.forID("Europe/Berlin"))
@Suppress("DEPRECATION")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
......
...@@ -31,7 +31,7 @@ class SettingsCrashReportViewModel @AssistedInject constructor( ...@@ -31,7 +31,7 @@ class SettingsCrashReportViewModel @AssistedInject constructor(
fun simulateException() { fun simulateException() {
try { try {
val a = 2 / 0 throw RuntimeException("Test crash reporting")
} catch (e: Exception) { } catch (e: Exception) {
Timber.e(e, "Msg: ${e.message}") Timber.e(e, "Msg: ${e.message}")
e.reportProblem(SettingsCrashReportViewModel::class.java.simpleName, e.message) e.reportProblem(SettingsCrashReportViewModel::class.java.simpleName, e.message)
......
...@@ -104,6 +104,7 @@ class TestRiskLevelCalculationFragmentCWAViewModel @AssistedInject constructor( ...@@ -104,6 +104,7 @@ class TestRiskLevelCalculationFragmentCWAViewModel @AssistedInject constructor(
.appendLine("Number of Days With Low Risk: $numberOfDaysWithLowRisk") .appendLine("Number of Days With Low Risk: $numberOfDaysWithLowRisk")
.toString() .toString()
@Suppress("DEPRECATION")
val backendParameters = appConfigProvider val backendParameters = appConfigProvider
.currentConfig .currentConfig
.map { it.rawConfig.riskCalculationParameters.toString() } .map { it.rawConfig.riskCalculationParameters.toString() }
......
...@@ -16,31 +16,31 @@ internal data class AttestationContainer( ...@@ -16,31 +16,31 @@ internal data class AttestationContainer(
safetyNetJws = report.jwsResult safetyNetJws = report.jwsResult
}.build() }.build()
override fun requirePass(reqs: SafetyNetRequirements) { override fun requirePass(requirements: SafetyNetRequirements) {
Timber.v("requirePass(%s)", reqs) Timber.v("requirePass(%s)", requirements)
if (reqs.requireBasicIntegrity && !report.basicIntegrity) { if (requirements.requireBasicIntegrity && !report.basicIntegrity) {
throw SafetyNetException( throw SafetyNetException(
Type.BASIC_INTEGRITY_REQUIRED, Type.BASIC_INTEGRITY_REQUIRED,
"Requirement 'basicIntegrity' not met (${report.advice})." "Requirement 'basicIntegrity' not met (${report.advice})."
) )
} }
if (reqs.requireCTSProfileMatch && !report.ctsProfileMatch) { if (requirements.requireCTSProfileMatch && !report.ctsProfileMatch) {
throw SafetyNetException( throw SafetyNetException(
Type.CTS_PROFILE_MATCH_REQUIRED, Type.CTS_PROFILE_MATCH_REQUIRED,
"Requirement 'ctsProfileMatch' not met (${report.advice})." "Requirement 'ctsProfileMatch' not met (${report.advice})."
) )
} }
if (reqs.requireBasicIntegrity && !report.evaluationTypes.contains("BASIC")) { if (requirements.requireBasicIntegrity && !report.evaluationTypes.contains("BASIC")) {
throw SafetyNetException( throw SafetyNetException(
Type.EVALUATION_TYPE_BASIC_REQUIRED, Type.EVALUATION_TYPE_BASIC_REQUIRED,
"Evaluation type 'BASIC' not met (${report.advice})." "Evaluation type 'BASIC' not met (${report.advice})."
) )
} }
if (reqs.requireEvaluationTypeHardwareBacked && !report.evaluationTypes.contains("HARDWARE_BACKED")) { if (requirements.requireEvaluationTypeHardwareBacked && !report.evaluationTypes.contains("HARDWARE_BACKED")) {
throw SafetyNetException( throw SafetyNetException(
Type.EVALUATION_TYPE_HARDWARE_BACKED_REQUIRED, Type.EVALUATION_TYPE_HARDWARE_BACKED_REQUIRED,
"Evaluation type 'HARDWARE_BACKED' not met (${report.advice})." "Evaluation type 'HARDWARE_BACKED' not met (${report.advice})."
......
...@@ -32,11 +32,15 @@ class DefaultTraceLocationRepository @Inject constructor( ...@@ -32,11 +32,15 @@ class DefaultTraceLocationRepository @Inject constructor(
traceLocationDatabase.traceLocationDao() traceLocationDatabase.traceLocationDao()
} }
/**
* Reruns [TraceLocation] for [id]
* @throws [IllegalArgumentException] if location not found
*/
override suspend fun traceLocationForId(id: Long): TraceLocation { override suspend fun traceLocationForId(id: Long): TraceLocation {
val checkIn = traceLocationDao.entryForId(id) val traceLocationEntity = traceLocationDao.entryForId(id)
?: throw IllegalArgumentException("No traceLocation found for ID=$id") ?: throw IllegalArgumentException("No traceLocation found for ID=$id")
return checkIn.toTraceLocation() return traceLocationEntity.toTraceLocation()
} }
/** /**
......
...@@ -51,6 +51,7 @@ class ExposureStateUpdateReceiver : BroadcastReceiver() { ...@@ -51,6 +51,7 @@ class ExposureStateUpdateReceiver : BroadcastReceiver() {
scope.launch(context = scope.coroutineContext) { scope.launch(context = scope.coroutineContext) {
try { try {
@Suppress("DEPRECATION")
intent.getStringExtra(EXTRA_TOKEN)?.let { intent.getStringExtra(EXTRA_TOKEN)?.let {
Timber.tag(TAG).w("Received unknown token from ENF: %s", it) Timber.tag(TAG).w("Received unknown token from ENF: %s", it)
} }
......
...@@ -19,6 +19,7 @@ import de.rki.coronawarnapp.server.protocols.internal.pt.TraceLocationOuterClass ...@@ -19,6 +19,7 @@ import de.rki.coronawarnapp.server.protocols.internal.pt.TraceLocationOuterClass
import de.rki.coronawarnapp.ui.eventregistration.organizer.category.adapter.CategoryItem import de.rki.coronawarnapp.ui.eventregistration.organizer.category.adapter.CategoryItem
import de.rki.coronawarnapp.ui.eventregistration.organizer.category.adapter.category.TraceLocationUIType.EVENT import de.rki.coronawarnapp.ui.eventregistration.organizer.category.adapter.category.TraceLocationUIType.EVENT
import de.rki.coronawarnapp.ui.eventregistration.organizer.category.adapter.category.TraceLocationUIType.LOCATION import de.rki.coronawarnapp.ui.eventregistration.organizer.category.adapter.category.TraceLocationUIType.LOCATION
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@Parcelize @Parcelize
...@@ -28,7 +29,7 @@ data class TraceLocationCategory( ...@@ -28,7 +29,7 @@ data class TraceLocationCategory(
@StringRes val title: Int, @StringRes val title: Int,
@StringRes val subtitle: Int? = null @StringRes val subtitle: Int? = null
) : CategoryItem, Parcelable { ) : CategoryItem, Parcelable {
override val stableId = hashCode().toLong() @IgnoredOnParcel override val stableId = hashCode().toLong()
} }
enum class TraceLocationUIType { enum class TraceLocationUIType {
......
...@@ -202,7 +202,7 @@ class TraceLocationCreateFragment : Fragment(R.layout.trace_location_create_frag ...@@ -202,7 +202,7 @@ class TraceLocationCreateFragment : Fragment(R.layout.trace_location_create_frag
private fun showDurationPicker() { private fun showDurationPicker() {
DurationPicker.Builder() DurationPicker.Builder()
.duration(viewModel.checkInLength?.toContactDiaryFormat() ?: "") .duration(viewModel.checkInLength.toContactDiaryFormat())
.title(getString(R.string.tracelocation_organizer_add_event_length_of_stay)) .title(getString(R.string.tracelocation_organizer_add_event_length_of_stay))
.build() .build()
.apply { .apply {
...@@ -216,7 +216,7 @@ class TraceLocationCreateFragment : Fragment(R.layout.trace_location_create_frag ...@@ -216,7 +216,7 @@ class TraceLocationCreateFragment : Fragment(R.layout.trace_location_create_frag
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState( super.onSaveInstanceState(
outState.apply { outState.apply {
putLong(LENGTH_OF_STAY, viewModel.checkInLength?.standardMinutes ?: 0L) putLong(LENGTH_OF_STAY, viewModel.checkInLength.standardMinutes)
putSerializable(BEGIN, viewModel.begin) putSerializable(BEGIN, viewModel.begin)
putSerializable(END, viewModel.end) putSerializable(END, viewModel.end)
} }
......
package de.rki.coronawarnapp.util.device package de.rki.coronawarnapp.util.device
import android.content.Context
import android.content.res.Resources import android.content.res.Resources
import android.os.Build import android.os.Build
import java.util.Locale import java.util.Locale
import javax.inject.Inject import javax.inject.Inject
class DefaultSystemInfoProvider @Inject constructor(context: Context) : SystemInfoProvider { class DefaultSystemInfoProvider @Inject constructor() : SystemInfoProvider {
override val locale: Locale override val locale: Locale
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
package de.rki.coronawarnapp.util.formatter package de.rki.coronawarnapp.util.formatter
import android.content.Context
import android.view.View import android.view.View
import de.rki.coronawarnapp.ui.information.InformationLegalPresentation import de.rki.coronawarnapp.ui.information.InformationLegalPresentation
import de.rki.coronawarnapp.util.device.DefaultSystemInfoProvider import de.rki.coronawarnapp.util.device.DefaultSystemInfoProvider
...@@ -15,10 +14,9 @@ import de.rki.coronawarnapp.util.device.DefaultSystemInfoProvider ...@@ -15,10 +14,9 @@ import de.rki.coronawarnapp.util.device.DefaultSystemInfoProvider
*/ */
fun formatVisibilityLanguageBased( fun formatVisibilityLanguageBased(
context: Context,
isContactFormView: Boolean? isContactFormView: Boolean?
): Int { ): Int {
InformationLegalPresentation(DefaultSystemInfoProvider(context)).apply { InformationLegalPresentation(DefaultSystemInfoProvider()).apply {
if (!showBackupLinkToContactForm) { if (!showBackupLinkToContactForm) {
return if (isContactFormView == true) { return if (isContactFormView == true) {
View.VISIBLE View.VISIBLE
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
android:linksClickable="true" android:linksClickable="true"
android:text="@string/information_legal_subtitle_contact_label" android:text="@string/information_legal_subtitle_contact_label"
android:textColorLink="@color/colorTextTint" android:textColorLink="@color/colorTextTint"
android:visibility="@{FormatterInformationLegalHelper.formatVisibilityLanguageBased(context, true)}" android:visibility="@{FormatterInformationLegalHelper.formatVisibilityLanguageBased(true)}"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
android:linksClickable="true" android:linksClickable="true"
android:text="@string/information_legal_subtitle_contact_form_non_en_de" android:text="@string/information_legal_subtitle_contact_form_non_en_de"
android:textColorLink="@color/colorTextTint" android:textColorLink="@color/colorTextTint"
android:visibility="@{FormatterInformationLegalHelper.formatVisibilityLanguageBased(context, false)}" android:visibility="@{FormatterInformationLegalHelper.formatVisibilityLanguageBased(false)}"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/information_legal_contact_form" /> app:layout_constraintTop_toBottomOf="@+id/information_legal_contact_form" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment