Commit d3c143da authored by Harri Kirik's avatar Harri Kirik
Browse files

COVAPP-464: Add a new efgs parameter when creating the PP URL

parent 06439532
package org.dpppt.android.app
import org.dpppt.android.app.domain.entity.FederationGatewayUsage
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForDP3TBackend
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForPatientPortal
import org.dpppt.android.app.domain.entity.GracePeriodConfiguration
import org.dpppt.android.app.domain.entity.LocalizedUrl
import org.dpppt.android.sdk.internal.logger.LogLevel
......@@ -52,7 +53,8 @@ object IcefireEnvironment : Environment {
override val crashAppOnUndeliverableException: Boolean = BuildConfig.DEBUG
override val showLongVersionInfo: Boolean = true
override val allowInfectionConfirmationStartWithoutGAEN: Boolean = BuildConfig.DEBUG
override val federationGatewayUsage: FederationGatewayUsage = FederationGatewayUsage.Enabled
override val federationGatewayUsageForDP3TBackend: FederationGatewayUsageForDP3TBackend = FederationGatewayUsageForDP3TBackend.Enabled
override val federationGatewayUsageForPatientPortal: FederationGatewayUsageForPatientPortal = FederationGatewayUsageForPatientPortal.Enabled
override val gotSickAbroadUrl: LocalizedUrl = LocalizedUrl(
et = "https://www.hoia.me/got-sick-abroad?source=app",
en = "https://www.hoia.me/got-sick-abroad/en?source=app",
......
......@@ -83,6 +83,9 @@ const val QUERY_PARAM_KEY = "authId"
const val QUERY_PARAM_LANGUAGE = "lang"
const val QUERY_PARAM_STATUS = "status"
const val QUERY_PARAM_MESSAGE = "message"
const val QUERY_PARAM_EFGS = "efgs"
const val QUERY_VALUE_EFGS_ENABLED = "true"
const val QUERY_VALUE_EFGS_DISABLED = "false"
const val REQUEST_CODE_BATTERY_OPTIMIZATIONS_INTENT = 421
const val REQUEST_BLUETOOTH_INTENT = 999
......
package org.dpppt.android.app
import org.dpppt.android.app.domain.entity.FederationGatewayUsage
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForDP3TBackend
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForPatientPortal
import org.dpppt.android.app.domain.entity.GracePeriodConfiguration
import org.dpppt.android.app.domain.entity.LocalizedUrl
import org.dpppt.android.sdk.internal.logger.LogLevel
......@@ -36,10 +37,14 @@ interface Environment {
// NB: Should only be allowed for debug versions. No reason to allow it for releases.
val allowInfectionConfirmationStartWithoutGAEN: Boolean
/**
* Flag to use when getting or sending exposed keys.
* Flag to use when getting or sending exposed keys to and from the DP-3T backend. See [FederationGatewayUsageForDP3TBackend] for more.
* Has three states: server decides, app requests gateway to be used, app requests the gateway to not to be used.
*/
val federationGatewayUsage: FederationGatewayUsage
val federationGatewayUsageForDP3TBackend: FederationGatewayUsageForDP3TBackend
/**
* Flag to use when doing PP side infection confirmation. See [FederationGatewayUsageForPatientPortal] for more.
*/
val federationGatewayUsageForPatientPortal: FederationGatewayUsageForPatientPortal
/**
* URL to Hoia.me page's got sick abroad information.
*/
......
......@@ -39,7 +39,12 @@ class UseCaseModule {
getRequestUseCase: GetActiveConfirmInfectionRequestUseCase,
getLanguageUseCase: GetActiveLanguageUseCase
): CreatePatientPortalUrlUseCase {
return CreatePatientPortalUrlUseCase(env.patientPortalBaseUrl, getRequestUseCase, getLanguageUseCase)
return CreatePatientPortalUrlUseCase(
env.patientPortalBaseUrl,
getRequestUseCase,
getLanguageUseCase,
env.federationGatewayUsageForPatientPortal
)
}
@Reusable
......@@ -91,7 +96,7 @@ class UseCaseModule {
numberOfDaysToKeepExposedDaysSinceReportDate = NUMBER_OF_DAYS_TO_KEEP_EXPOSED_DAYS_FOR_SDK_STORED_REPORTS,
numberOfDaysToConsiderForExposure = NUMBER_OF_DAYS_TO_CONSIDER_FOR_EXPOSURE_FOR_RECEIVED_INFECTED_KEYS,
numberOfDP3TSyncsPerDay = DP_3T_SYNCS_PER_DAY,
federationGatewayUsage = env.federationGatewayUsage
federationGatewayUsageForDP3TBackend = env.federationGatewayUsageForDP3TBackend
)
}
......
package org.dpppt.android.app.domain.entity
sealed class FederationGatewayUsage {
/**
* Application signals the backend that it prefers the federation gateway to be used if possible.
*/
object Enabled : FederationGatewayUsage()
/**
* Application signals to the backend that it prefers the federation gateway to not be used if possible.
*/
object Disabled : FederationGatewayUsage()
/**
* Application does not signal any preference on the federation gateway usage.
*/
object BackendDecides : FederationGatewayUsage()
}
package org.dpppt.android.app.domain.entity
sealed class FederationGatewayUsageForDP3TBackend {
/**
* Application signals the DP-3T backend that it prefers the federation gateway to be used if possible.
*/
object Enabled : FederationGatewayUsageForDP3TBackend()
/**
* Application signals to the DP-3T backend that it prefers the federation gateway to not be used if possible.
*/
object Disabled : FederationGatewayUsageForDP3TBackend()
/**
* Application does not signal any preference to the DP-3T backend on the federation gateway usage.
*/
object BackendDecides : FederationGatewayUsageForDP3TBackend()
}
package org.dpppt.android.app.domain.entity
import org.dpppt.android.app.QUERY_VALUE_EFGS_DISABLED
import org.dpppt.android.app.QUERY_VALUE_EFGS_ENABLED
import org.dpppt.android.app.common.util.exhaustive
sealed class FederationGatewayUsageForPatientPortal {
fun getRequestParamValue(): String {
return when (this) {
Disabled -> QUERY_VALUE_EFGS_DISABLED
Enabled -> QUERY_VALUE_EFGS_ENABLED
}.exhaustive
}
/**
* Application signals to PP to show the Federation gateway opt-in UI.
*/
object Enabled : FederationGatewayUsageForPatientPortal()
/**
* Application signals to PP to NOT to show the Federation gateway opt-in UI.
*/
object Disabled : FederationGatewayUsageForPatientPortal()
}
......@@ -4,7 +4,7 @@ import android.content.Context
import dagger.Reusable
import org.dpppt.android.app.common.util.exhaustive
import org.dpppt.android.app.domain.entity.CloseContactConfiguration
import org.dpppt.android.app.domain.entity.FederationGatewayUsage
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForDP3TBackend
import org.dpppt.android.app.domain.entity.GracePeriodConfiguration
import org.dpppt.android.app.pinning.SSLPinner
import org.dpppt.android.sdk.DP3T
......@@ -26,7 +26,7 @@ class GaenInitUseCase(
private val numberOfDaysToKeepExposedDaysSinceReportDate: Long,
private val numberOfDaysToConsiderForExposure: Long,
private val numberOfDP3TSyncsPerDay: Int,
private val federationGatewayUsage: FederationGatewayUsage
private val federationGatewayUsageForDP3TBackend: FederationGatewayUsageForDP3TBackend
) {
fun execute() {
configureSDKLogging()
......@@ -57,11 +57,11 @@ class GaenInitUseCase(
}
private fun configureFederationGatewayUsage() {
Timber.d("GaenInitUseCase - Federation Gateway usage: $federationGatewayUsage")
when (federationGatewayUsage) {
FederationGatewayUsage.BackendDecides -> DP3T.setWithFederationGateway(context, null)
FederationGatewayUsage.Disabled -> DP3T.setWithFederationGateway(context, false)
FederationGatewayUsage.Enabled -> DP3T.setWithFederationGateway(context, true)
Timber.d("GaenInitUseCase - Federation Gateway usage: $federationGatewayUsageForDP3TBackend")
when (federationGatewayUsageForDP3TBackend) {
FederationGatewayUsageForDP3TBackend.BackendDecides -> DP3T.setWithFederationGateway(context, null)
FederationGatewayUsageForDP3TBackend.Disabled -> DP3T.setWithFederationGateway(context, false)
FederationGatewayUsageForDP3TBackend.Enabled -> DP3T.setWithFederationGateway(context, true)
}.exhaustive
}
......
package org.dpppt.android.app.domain.usecase.infection.patientportal
import io.reactivex.rxjava3.core.Single
import org.dpppt.android.app.QUERY_PARAM_EFGS
import org.dpppt.android.app.QUERY_PARAM_KEY
import org.dpppt.android.app.QUERY_PARAM_LANGUAGE
import org.dpppt.android.app.domain.entity.ConfirmInfectionRequest
import org.dpppt.android.app.domain.entity.DomainException
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForPatientPortal
import org.dpppt.android.app.domain.entity.Language
import org.dpppt.android.app.domain.usecase.infection.request.GetActiveConfirmInfectionRequestUseCase
import org.dpppt.android.app.domain.usecase.language.GetActiveLanguageUseCase
......@@ -12,7 +14,8 @@ import org.dpppt.android.app.domain.usecase.language.GetActiveLanguageUseCase
class CreatePatientPortalUrlUseCase(
private val baseUrl: String,
private val getRequestUseCase: GetActiveConfirmInfectionRequestUseCase,
private val getLanguageUseCase: GetActiveLanguageUseCase
private val getLanguageUseCase: GetActiveLanguageUseCase,
private val federationGatewayUsageForPatientPortal: FederationGatewayUsageForPatientPortal
) {
fun execute(): Single<String> {
......@@ -20,7 +23,7 @@ class CreatePatientPortalUrlUseCase(
val request = getRequestUseCase.execute()
?: throw DomainException.ConfirmInfectionRequestNotFound()
validateRequest(request)
return@fromCallable createUrl(request, getLanguageUseCase.execute())
return@fromCallable createUrl(request, getLanguageUseCase.execute(), federationGatewayUsageForPatientPortal)
}
}
......@@ -30,8 +33,12 @@ class CreatePatientPortalUrlUseCase(
}
}
private fun createUrl(request: ConfirmInfectionRequest, language: Language): String {
private fun createUrl(
request: ConfirmInfectionRequest,
language: Language,
efgsUsage: FederationGatewayUsageForPatientPortal
): String {
// The baseurl already contains the query parameter start char '?'
return "$baseUrl$QUERY_PARAM_KEY=${request.key}&$QUERY_PARAM_LANGUAGE=${language.code}"
return "$baseUrl$QUERY_PARAM_KEY=${request.key}&$QUERY_PARAM_LANGUAGE=${language.code}&$QUERY_PARAM_EFGS=${efgsUsage.getRequestParamValue()}"
}
}
......@@ -118,6 +118,7 @@ class ConfirmInfectionPatientPortalViewModel @Inject constructor(
.backgroundToMain()
.subscribe(
{ url ->
Timber.d("preparePatientPortalUrlNavigation - start URL: $url")
_action.value = Event(Action.LoadUrl(url))
},
{ error ->
......
package org.dpppt.android.app
import org.dpppt.android.app.domain.entity.FederationGatewayUsage
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForDP3TBackend
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForPatientPortal
import org.dpppt.android.app.domain.entity.GracePeriodConfiguration
import org.dpppt.android.app.domain.entity.LocalizedUrl
import org.dpppt.android.sdk.internal.logger.LogLevel
......@@ -52,7 +53,8 @@ object TehikdevEnvironment : Environment {
override val crashAppOnUndeliverableException: Boolean = BuildConfig.DEBUG
override val showLongVersionInfo: Boolean = true
override val allowInfectionConfirmationStartWithoutGAEN: Boolean = BuildConfig.DEBUG
override val federationGatewayUsage: FederationGatewayUsage = FederationGatewayUsage.Enabled
override val federationGatewayUsageForDP3TBackend: FederationGatewayUsageForDP3TBackend = FederationGatewayUsageForDP3TBackend.Enabled
override val federationGatewayUsageForPatientPortal: FederationGatewayUsageForPatientPortal = FederationGatewayUsageForPatientPortal.Enabled
override val gotSickAbroadUrl: LocalizedUrl = LocalizedUrl(
et = "https://www.hoia.me/got-sick-abroad?source=app",
en = "https://www.hoia.me/got-sick-abroad/en?source=app",
......
package org.dpppt.android.app
import org.dpppt.android.app.domain.entity.FederationGatewayUsage
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForDP3TBackend
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForPatientPortal
import org.dpppt.android.app.domain.entity.GracePeriodConfiguration
import org.dpppt.android.app.domain.entity.LocalizedUrl
import org.dpppt.android.sdk.internal.logger.LogLevel
......@@ -58,7 +59,8 @@ object TehikprodEnvironment : Environment {
override val crashAppOnUndeliverableException: Boolean = false
override val showLongVersionInfo: Boolean = false // For Production we only show the short info
override val allowInfectionConfirmationStartWithoutGAEN: Boolean = BuildConfig.DEBUG
override val federationGatewayUsage: FederationGatewayUsage = FederationGatewayUsage.Enabled
override val federationGatewayUsageForDP3TBackend: FederationGatewayUsageForDP3TBackend = FederationGatewayUsageForDP3TBackend.Enabled
override val federationGatewayUsageForPatientPortal: FederationGatewayUsageForPatientPortal = FederationGatewayUsageForPatientPortal.Enabled
override val gotSickAbroadUrl: LocalizedUrl = LocalizedUrl(
et = "https://www.hoia.me/got-sick-abroad?source=app",
en = "https://www.hoia.me/got-sick-abroad/en?source=app",
......
package org.dpppt.android.app
import org.dpppt.android.app.domain.entity.FederationGatewayUsage
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForDP3TBackend
import org.dpppt.android.app.domain.entity.FederationGatewayUsageForPatientPortal
import org.dpppt.android.app.domain.entity.GracePeriodConfiguration
import org.dpppt.android.app.domain.entity.LocalizedUrl
import org.dpppt.android.sdk.internal.logger.LogLevel
......@@ -52,7 +53,8 @@ object TehiktestEnvironment : Environment {
override val crashAppOnUndeliverableException: Boolean = BuildConfig.DEBUG
override val showLongVersionInfo: Boolean = true
override val allowInfectionConfirmationStartWithoutGAEN: Boolean = BuildConfig.DEBUG
override val federationGatewayUsage: FederationGatewayUsage = FederationGatewayUsage.Enabled
override val federationGatewayUsageForDP3TBackend: FederationGatewayUsageForDP3TBackend = FederationGatewayUsageForDP3TBackend.Enabled
override val federationGatewayUsageForPatientPortal: FederationGatewayUsageForPatientPortal = FederationGatewayUsageForPatientPortal.Enabled
override val gotSickAbroadUrl: LocalizedUrl = LocalizedUrl(
et = "https://www.hoia.me/got-sick-abroad?source=app",
en = "https://www.hoia.me/got-sick-abroad/en?source=app",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment