Take into account the value of FeatureFlags.SignInWithClassic
This commit is contained in:
parent
82cec2016e
commit
fafaad6b6c
2 changed files with 37 additions and 0 deletions
|
|
@ -28,6 +28,8 @@ import io.element.android.libraries.androidutils.service.ServiceBinder
|
|||
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||
import io.element.android.libraries.core.uri.ensureProtocol
|
||||
import io.element.android.libraries.di.annotations.AppCoroutineScope
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.matrix.api.auth.ElementClassicSession
|
||||
import io.element.android.libraries.matrix.api.auth.HomeServerLoginCompatibilityChecker
|
||||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
|
||||
|
|
@ -69,6 +71,7 @@ class DefaultElementClassicConnection(
|
|||
private val coroutineScope: CoroutineScope,
|
||||
private val matrixAuthenticationService: MatrixAuthenticationService,
|
||||
private val homeServerLoginCompatibilityChecker: HomeServerLoginCompatibilityChecker,
|
||||
private val featureFlagService: FeatureFlagService,
|
||||
) : ElementClassicConnection {
|
||||
// Messenger for communicating with the service.
|
||||
private var messenger: Messenger? = null
|
||||
|
|
@ -116,6 +119,10 @@ class DefaultElementClassicConnection(
|
|||
override fun start() {
|
||||
Timber.tag(loggerTag.value).d("start()")
|
||||
coroutineScope.launch {
|
||||
if (!featureFlagService.isFeatureEnabled(FeatureFlags.SignInWithClassic)) {
|
||||
Timber.tag(loggerTag.value).d("Login with Element Classic is disabled, not starting connection")
|
||||
return@launch
|
||||
}
|
||||
// Establish a connection with the service. We use an explicit
|
||||
// class name because there is no reason to be able to let other
|
||||
// applications replace our component.
|
||||
|
|
@ -151,6 +158,11 @@ class DefaultElementClassicConnection(
|
|||
override fun requestSession() {
|
||||
Timber.tag(loggerTag.value).d("requestSession()")
|
||||
coroutineScope.launch {
|
||||
if (!featureFlagService.isFeatureEnabled(FeatureFlags.SignInWithClassic)) {
|
||||
Timber.tag(loggerTag.value).d("Login with Element Classic is disabled")
|
||||
emitState(ElementClassicConnectionState.Error("The feature is disabled"))
|
||||
return@launch
|
||||
}
|
||||
val finalMessenger = messenger
|
||||
if (finalMessenger == null) {
|
||||
Timber.tag(loggerTag.value).d("The messenger is null, can't request data")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue