Make sure friend lists subscruptions are enabled for sip.linphone.org accounts and disabled for others

This commit is contained in:
Sylvain Berfini 2024-01-29 14:52:24 +01:00
parent 44af8bb340
commit 254d8619fe
3 changed files with 19 additions and 3 deletions

View file

@ -30,7 +30,4 @@
<entry name="media_encryption" overwrite="true">zrtp</entry>
<entry name="media_encryption_mandatory" overwrite="true">1</entry>
</section>
<section name="net">
<entry name="friendlist_subscription_enabled" overwrite="true">1</entry>
</section>
</config>

View file

@ -238,6 +238,8 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
core.videoCodecPriorityPolicy = CodecPriorityPolicy.Auto
updateFriendListsSubscriptionDependingOnDefaultAccount()
computeUserAgent()
Log.i("$TAG Core has been created with user-agent [${core.userAgent}], starting it")
core.start()
@ -473,6 +475,22 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
context.startActivity(intent)
}
@WorkerThread
fun updateFriendListsSubscriptionDependingOnDefaultAccount() {
val account = core.defaultAccount
if (account != null) {
val enabled = account.params.domain == corePreferences.defaultDomain
if (enabled != core.isFriendListSubscriptionEnabled) {
core.isFriendListSubscriptionEnabled = enabled
Log.i(
"$TAG Friend list(s) subscription are now ${if (enabled) "enabled" else "disabled"}"
)
}
} else {
Log.e("$TAG Default account is null, do not touch friend lists subscription")
}
}
@WorkerThread
private fun computeUserAgent() {
val deviceName = AppUtils.getDeviceName(context)

View file

@ -188,6 +188,7 @@ class MainViewModel @UiThread constructor() : ViewModel() {
Log.i(
"$TAG Default account changed, now is [${account.params.identityAddress?.asStringUriOnly()}]"
)
coreContext.updateFriendListsSubscriptionDependingOnDefaultAccount()
if (defaultAccountRegistrationFailed && account.state != RegistrationState.Failed) {
Log.i(