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

EOL - error logs (EXPOSUREAPP-14837) #5857

Merged
merged 2 commits into from
Feb 21, 2023
Merged
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
32 changes: 23 additions & 9 deletions Corona-Warn-App/src/main/java/de/rki/coronawarnapp/eol/AppEol.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ package de.rki.coronawarnapp.eol
import android.app.AlarmManager
import androidx.core.app.NotificationManagerCompat
import androidx.work.WorkManager
import de.rki.coronawarnapp.bugreporting.debuglog.DebugLogger
import de.rki.coronawarnapp.coronatest.notification.ShareTestResultNotification
import de.rki.coronawarnapp.coronatest.type.BaseCoronaTest
import de.rki.coronawarnapp.nearby.ENFClient
import de.rki.coronawarnapp.nearby.modules.tracing.disableTracingIfEnabled
import de.rki.coronawarnapp.notification.NotificationConstants
import de.rki.coronawarnapp.presencetracing.checkins.checkout.auto.AutoCheckOutIntentFactory
import de.rki.coronawarnapp.tag
import de.rki.coronawarnapp.util.coroutine.AppScope
import de.rki.coronawarnapp.util.flow.intervalFlow
import de.rki.coronawarnapp.util.flow.shareLatest
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.onEach
Expand All @@ -27,13 +31,15 @@ import javax.inject.Singleton

@Singleton
class AppEol @Inject constructor(
@AppScope private val appScope: CoroutineScope,
eolSetting: EolSetting,
private val enfClient: ENFClient,
private val workManager: WorkManager,
private val notificationManager: NotificationManagerCompat,
private val notification: ShareTestResultNotification,
private val debugLogger: DebugLogger,
private val alarmManager: AlarmManager,
@AppScope private val appScope: CoroutineScope,
private val intentFactory: AutoCheckOutIntentFactory,
eolSetting: EolSetting,
private val notification: ShareTestResultNotification,
private val notificationManager: NotificationManagerCompat,
) {
val isEol = combine(
intervalFlow(60_000L),
Expand All @@ -43,10 +49,10 @@ class AppEol @Inject constructor(
}.distinctUntilChanged()
.onEach { isEol ->
if (isEol) {
Timber.tag(TAG).d("Cancel all works ")
Timber.tag(TAG).d("Cancel all works")
workManager.cancelAllWork()

Timber.tag(TAG).d("Cancel all notifications ")
Timber.tag(TAG).d("Cancel all notifications")
notificationManager.cancelAll()
notification.cancelSharePositiveTestResultNotification(
BaseCoronaTest.Type.PCR,
Expand All @@ -56,11 +62,19 @@ class AppEol @Inject constructor(
BaseCoronaTest.Type.RAPID_ANTIGEN,
NotificationConstants.POSITIVE_RAT_RESULT_NOTIFICATION_ID
)

alarmManager.cancel(intentFactory.createIntent())

Timber.tag(TAG).d("Stop logger")
debugLogger.stop()

runCatching {
Timber.tag(TAG).d("Disable ENF")
enfClient.disableTracingIfEnabled()
}
}
}
.shareLatest(scope = appScope)
}.catch {
Timber.tag(TAG).d(it, "EOL failed")
}.shareLatest(scope = appScope)

companion object {
private val TAG = tag<AppEol>()
Expand Down