fix app locked on splash
This commit is contained in:
parent
4ee53ad9d0
commit
6b3d1f185d
|
@ -49,7 +49,9 @@ class FdroidFcmHelper @Inject constructor(
|
||||||
|
|
||||||
override fun onEnterForeground(activeSessionHolder: ActiveSessionHolder) {
|
override fun onEnterForeground(activeSessionHolder: ActiveSessionHolder) {
|
||||||
// try to stop all regardless of background mode
|
// try to stop all regardless of background mode
|
||||||
activeSessionHolder.getSafeActiveSession()?.syncService()?.stopAnyBackgroundSync()
|
activeSessionHolder.getSafeActiveSessionAsync {
|
||||||
|
it?.syncService()?.stopAnyBackgroundSync()
|
||||||
|
}
|
||||||
AlarmSyncBroadcastReceiver.cancelAlarm(context)
|
AlarmSyncBroadcastReceiver.cancelAlarm(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,9 +190,12 @@ class VectorApplication :
|
||||||
override fun onResume(owner: LifecycleOwner) {
|
override fun onResume(owner: LifecycleOwner) {
|
||||||
Timber.i("App entered foreground")
|
Timber.i("App entered foreground")
|
||||||
fcmHelper.onEnterForeground(activeSessionHolder)
|
fcmHelper.onEnterForeground(activeSessionHolder)
|
||||||
activeSessionHolder.getSafeActiveSession()?.also {
|
activeSessionHolder.getSafeActiveSessionAsync {
|
||||||
it.syncService().stopAnyBackgroundSync()
|
it?.syncService()?.stopAnyBackgroundSync()
|
||||||
}
|
}
|
||||||
|
// activeSessionHolder.getSafeActiveSession()?.also {
|
||||||
|
// it.syncService().stopAnyBackgroundSync()
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause(owner: LifecycleOwner) {
|
override fun onPause(owner: LifecycleOwner) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.core.di
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import im.vector.app.ActiveSessionDataSource
|
import im.vector.app.ActiveSessionDataSource
|
||||||
|
import im.vector.app.core.dispatchers.CoroutineDispatchers
|
||||||
import im.vector.app.core.pushers.UnregisterUnifiedPushUseCase
|
import im.vector.app.core.pushers.UnregisterUnifiedPushUseCase
|
||||||
import im.vector.app.core.services.GuardServiceStarter
|
import im.vector.app.core.services.GuardServiceStarter
|
||||||
import im.vector.app.core.session.ConfigureAndStartSessionUseCase
|
import im.vector.app.core.session.ConfigureAndStartSessionUseCase
|
||||||
|
@ -26,7 +27,10 @@ import im.vector.app.features.crypto.keysrequest.KeyRequestHandler
|
||||||
import im.vector.app.features.crypto.verification.IncomingVerificationRequestHandler
|
import im.vector.app.features.crypto.verification.IncomingVerificationRequestHandler
|
||||||
import im.vector.app.features.notifications.PushRuleTriggerListener
|
import im.vector.app.features.notifications.PushRuleTriggerListener
|
||||||
import im.vector.app.features.session.SessionListener
|
import im.vector.app.features.session.SessionListener
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.android.sdk.api.auth.AuthenticationService
|
import org.matrix.android.sdk.api.auth.AuthenticationService
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
|
@ -51,6 +55,8 @@ class ActiveSessionHolder @Inject constructor(
|
||||||
private val authenticationService: AuthenticationService,
|
private val authenticationService: AuthenticationService,
|
||||||
private val configureAndStartSessionUseCase: ConfigureAndStartSessionUseCase,
|
private val configureAndStartSessionUseCase: ConfigureAndStartSessionUseCase,
|
||||||
private val unregisterUnifiedPushUseCase: UnregisterUnifiedPushUseCase,
|
private val unregisterUnifiedPushUseCase: UnregisterUnifiedPushUseCase,
|
||||||
|
private val applicationCoroutineScope: CoroutineScope,
|
||||||
|
private val coroutineDispatchers: CoroutineDispatchers,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var activeSessionReference: AtomicReference<Session?> = AtomicReference()
|
private var activeSessionReference: AtomicReference<Session?> = AtomicReference()
|
||||||
|
@ -96,6 +102,13 @@ class ActiveSessionHolder @Inject constructor(
|
||||||
return runBlocking { getOrInitializeSession() }
|
return runBlocking { getOrInitializeSession() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getSafeActiveSessionAsync(withSession: ((Session?) -> Unit)) {
|
||||||
|
applicationCoroutineScope.launch(coroutineDispatchers.io) {
|
||||||
|
val session = getOrInitializeSession()
|
||||||
|
withSession(session)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun getActiveSession(): Session {
|
fun getActiveSession(): Session {
|
||||||
return getSafeActiveSession()
|
return getSafeActiveSession()
|
||||||
?: throw IllegalStateException("You should authenticate before using this")
|
?: throw IllegalStateException("You should authenticate before using this")
|
||||||
|
|
Loading…
Reference in New Issue