diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt index 5ef730675..ff9217675 100644 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt +++ b/holder/src/main/java/nl/rijksoverheid/ctr/holder/HolderApplication.kt @@ -14,6 +14,7 @@ import nl.rijksoverheid.ctr.holder.persistence.WorkerManagerWrapper import nl.rijksoverheid.ctr.holder.persistence.database.HolderDatabase import nl.rijksoverheid.ctr.holder.persistence.database.entities.* import nl.rijksoverheid.ctr.holder.persistence.database.migration.TestResultsMigrationManager +import nl.rijksoverheid.ctr.holder.ui.create_qr.usecases.CheckNewRecoveryValidityUseCase import nl.rijksoverheid.ctr.holder.ui.create_qr.usecases.SecretKeyUseCase import nl.rijksoverheid.ctr.introduction.introductionModule import nl.rijksoverheid.ctr.shared.MobileCoreWrapper @@ -41,6 +42,7 @@ open class HolderApplication : SharedApplication(), Configuration.Provider { private val appConfigStorageManager: AppConfigStorageManager by inject() private val mobileCoreWrapper: MobileCoreWrapper by inject() private val workerManagerWrapper: WorkerManagerWrapper by inject() + private val checkNewRecoveryValidityUseCase: CheckNewRecoveryValidityUseCase by inject() private val holderModules = listOf( storageModule, @@ -100,6 +102,11 @@ open class HolderApplication : SharedApplication(), Configuration.Provider { } testResultsMigrationManager.removeOldCredential() + + // only for 2.5.2 hotfix + if (BuildConfig.VERSION_NAME.contains("2.5.2") ) { + checkNewRecoveryValidityUseCase.checkIfNeedToReAllowRecoveryExtensionCheck() + } } if (appConfigStorageManager.areConfigFilesPresentInFilesFolder()) { diff --git a/holder/src/main/java/nl/rijksoverheid/ctr/holder/ui/create_qr/usecases/CheckNewRecoveryValidityUseCase.kt b/holder/src/main/java/nl/rijksoverheid/ctr/holder/ui/create_qr/usecases/CheckNewRecoveryValidityUseCase.kt index 7b1c130e2..d6906dbd7 100644 --- a/holder/src/main/java/nl/rijksoverheid/ctr/holder/ui/create_qr/usecases/CheckNewRecoveryValidityUseCase.kt +++ b/holder/src/main/java/nl/rijksoverheid/ctr/holder/ui/create_qr/usecases/CheckNewRecoveryValidityUseCase.kt @@ -21,6 +21,7 @@ import java.time.ZoneId */ interface CheckNewRecoveryValidityUseCase { suspend fun check() + suspend fun checkIfNeedToReAllowRecoveryExtensionCheck() } class CheckNewRecoveryValidityUseCaseImpl( @@ -73,4 +74,26 @@ class CheckNewRecoveryValidityUseCaseImpl( persistenceManager.setShouldCheckRecoveryGreenCardRevisedValidity(false) } } + + /** + * If the user has upgraded to 2.5.1, we have done the check already, so he will see + * the banner to extend his recovery. We need to allow the check again, in order to + * prevent showing the banner for the recovery paper certificates. + */ + override suspend fun checkIfNeedToReAllowRecoveryExtensionCheck() { + if (persistenceManager.getShouldCheckRecoveryGreenCardRevisedValidity()) { + return + } + val allEvents = holderDatabase.eventGroupDao().getAll() + + removeExpiredEventsUseCase.execute(allEvents) + + val hasPaperRecoveryEvent = allEvents.any { it.type is OriginType.Recovery && it.providerIdentifier == PROVIDER_IDENTIFIER_DCC } + + if (hasPaperRecoveryEvent) { + persistenceManager.setShowExtendDomesticRecoveryInfoCard(false) + persistenceManager.setShowRecoverDomesticRecoveryInfoCard(false) + persistenceManager.setShouldCheckRecoveryGreenCardRevisedValidity(true) + } + } } \ No newline at end of file