Automatically enable background mode when configuring a non sip.linphone.org account

This commit is contained in:
Sylvain Berfini 2020-11-03 14:02:45 +01:00
parent 3b24fcd097
commit 1c54678adc

View file

@ -24,6 +24,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.core.* import org.linphone.core.*
import org.linphone.core.tools.Log import org.linphone.core.tools.Log
import org.linphone.utils.Event import org.linphone.utils.Event
@ -134,6 +135,13 @@ class GenericLoginViewModel(private val accountCreator: AccountCreator) : ViewMo
} }
Log.i("[Assistant] [Generic Login] Proxy config created") Log.i("[Assistant] [Generic Login] Proxy config created")
// The following is required to keep the app alive
// and be able to receive calls while in background
if (domain.value.orEmpty() != corePreferences.defaultDomain) {
Log.i("[Assistant] [Generic Login] Background mode with foreground service automatically enabled")
corePreferences.keepServiceAlive = true
coreContext.notificationsManager.startForeground()
}
} }
private fun isLoginButtonEnabled(): Boolean { private fun isLoginButtonEnabled(): Boolean {