mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Reworked Core startup & configuration
This commit is contained in:
parent
0238de5b3b
commit
aab5863b57
4 changed files with 51 additions and 40 deletions
|
|
@ -87,7 +87,7 @@ android {
|
|||
applicationId = packageName
|
||||
minSdk = 28
|
||||
targetSdk = 34
|
||||
versionCode = 60000
|
||||
versionCode = 600000 // 6.00.000
|
||||
versionName = "6.0.0"
|
||||
|
||||
manifestPlaceholders["appAuthRedirectScheme"] = "org.linphone"
|
||||
|
|
|
|||
|
|
@ -132,6 +132,12 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
@WorkerThread
|
||||
override fun onGlobalStateChanged(core: Core, state: GlobalState, message: String) {
|
||||
Log.i("$TAG Global state changed [$state]")
|
||||
|
||||
if (state == GlobalState.On) {
|
||||
// Wait for GlobalState.ON as some settings modification won't be saved
|
||||
// in RC file if Core isn't ON
|
||||
onCoreStarted()
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -366,48 +372,57 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
|
||||
@WorkerThread
|
||||
fun startCore() {
|
||||
Log.i("$TAG Configuring Core")
|
||||
core.videoCodecPriorityPolicy = CodecPriorityPolicy.Auto
|
||||
|
||||
val oldVersion = corePreferences.linphoneConfigurationVersion
|
||||
if (oldVersion < CorePreferences.CURRENT_VERSION) {
|
||||
Log.i(
|
||||
"$TAG Migrating configuration from [$oldVersion] to [${CorePreferences.CURRENT_VERSION}]"
|
||||
)
|
||||
val policy = core.videoActivationPolicy.clone()
|
||||
policy.automaticallyInitiate = false
|
||||
policy.automaticallyAccept = true
|
||||
policy.automaticallyAcceptDirection = MediaDirection.RecvOnly
|
||||
core.videoActivationPolicy = policy
|
||||
|
||||
core.isFecEnabled = true
|
||||
}
|
||||
|
||||
val videoPolicy = core.videoActivationPolicy
|
||||
Log.i(
|
||||
"$TAG Core's video policy is: auto initiate [${videoPolicy.automaticallyInitiate}], auto accept [${videoPolicy.automaticallyAccept}], accept direction [${videoPolicy.automaticallyAcceptDirection}]"
|
||||
)
|
||||
|
||||
Log.i("$TAG Starting Core")
|
||||
updateFriendListsSubscriptionDependingOnDefaultAccount()
|
||||
|
||||
computeUserAgent()
|
||||
Log.i("$TAG Core has been configured with user-agent [${core.userAgent}], starting it")
|
||||
core.start()
|
||||
|
||||
contactsManager.onCoreStarted(core)
|
||||
telecomManager.onCoreStarted(core)
|
||||
notificationsManager.onCoreStarted(core)
|
||||
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
audioManager.registerAudioDeviceCallback(audioDeviceCallback, coreThread)
|
||||
|
||||
corePreferences.linphoneConfigurationVersion = CorePreferences.CURRENT_VERSION
|
||||
computeUserAgent()
|
||||
Log.i("$TAG Core has been configured with user-agent [${core.userAgent}], starting it")
|
||||
core.start()
|
||||
}
|
||||
|
||||
Log.i("$TAG Report Core created and started")
|
||||
@WorkerThread
|
||||
fun onCoreStarted() {
|
||||
Log.i("$TAG Core started, updating configuration if required")
|
||||
core.videoCodecPriorityPolicy = CodecPriorityPolicy.Auto
|
||||
|
||||
val currentVersion = BuildConfig.VERSION_CODE
|
||||
val oldVersion = corePreferences.linphoneConfigurationVersion
|
||||
Log.w("$TAG Current configuration version is [$oldVersion]")
|
||||
|
||||
if (oldVersion < currentVersion) {
|
||||
Log.w("$TAG Migrating configuration to [$currentVersion]")
|
||||
|
||||
if (oldVersion < 600000) { // 6.0.0 initial release
|
||||
val policy = core.videoActivationPolicy.clone()
|
||||
policy.automaticallyInitiate = false
|
||||
policy.automaticallyAccept = true
|
||||
policy.automaticallyAcceptDirection = MediaDirection.RecvOnly
|
||||
core.videoActivationPolicy = policy
|
||||
Log.i(
|
||||
"$TAG Updated video activation policy to disable auto initiate, enable auto accept with media direction RecvOnly"
|
||||
)
|
||||
|
||||
core.isFecEnabled = true
|
||||
Log.i("$TAG Video FEC has been enabled")
|
||||
}
|
||||
|
||||
corePreferences.linphoneConfigurationVersion = currentVersion
|
||||
Log.w(
|
||||
"$TAG Core configuration updated to version [${corePreferences.linphoneConfigurationVersion}]"
|
||||
)
|
||||
}
|
||||
|
||||
if (corePreferences.keepServiceAlive) {
|
||||
startKeepAliveService()
|
||||
}
|
||||
|
||||
contactsManager.onCoreStarted(core)
|
||||
telecomManager.onCoreStarted(core)
|
||||
notificationsManager.onCoreStarted(core, oldVersion < 600000) // Re-create channels when migrating from a non 6.0 version
|
||||
Log.i("$TAG Started contacts, telecom & notifications managers")
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
private const val TAG = "[Preferences]"
|
||||
|
||||
const val CONFIG_FILE_NAME = ".linphonerc"
|
||||
const val CURRENT_VERSION = 60000
|
||||
}
|
||||
|
||||
private var _config: Config? = null
|
||||
|
|
@ -140,7 +139,7 @@ class CorePreferences @UiThread constructor(private val context: Context) {
|
|||
|
||||
@get:WorkerThread @set:WorkerThread
|
||||
var linphoneConfigurationVersion: Int
|
||||
get() = config.getInt("app", "config_version", 50200)
|
||||
get() = config.getInt("app", "config_version", 52005)
|
||||
set(value) {
|
||||
config.setInt("app", "config_version", value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ import org.linphone.core.Core
|
|||
import org.linphone.core.CoreForegroundService
|
||||
import org.linphone.core.CoreKeepAliveThirdPartyAccountsService
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.CorePreferences
|
||||
import org.linphone.core.Friend
|
||||
import org.linphone.core.MediaDirection
|
||||
import org.linphone.core.tools.Log
|
||||
|
|
@ -450,13 +449,11 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
}
|
||||
|
||||
@WorkerThread
|
||||
fun onCoreStarted(core: Core) {
|
||||
fun onCoreStarted(core: Core, clearChannels: Boolean) {
|
||||
Log.i("$TAG Core has been started")
|
||||
|
||||
val rcVersion = corePreferences.linphoneConfigurationVersion
|
||||
val clearPreviousChannels = rcVersion < CorePreferences.CURRENT_VERSION
|
||||
coreContext.postOnMainThread {
|
||||
createChannels(clearPreviousChannels)
|
||||
createChannels(clearChannels)
|
||||
}
|
||||
|
||||
core.addListener(coreListener)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue