Hide push notification setting in third party SIP accounts parameters, they won't work anyway + disable push for existing third party SIP accounts when migrating to 6.0.4

This commit is contained in:
Sylvain Berfini 2025-04-09 10:19:56 +02:00
parent c08157b659
commit 26df085df3
5 changed files with 37 additions and 9 deletions

View file

@ -602,6 +602,8 @@ class CoreContext
if (oldVersion < 600000) { // 6.0.0 initial release
configurationMigration5To6()
} else if (oldVersion < 600004) { // 6.0.4
disablePushNotificationsFromThirdPartySipAccounts()
}
if (core.logCollectionUploadServerUrl.isNullOrEmpty()) {
@ -1043,6 +1045,21 @@ class CoreContext
logcatEnabled = enable
}
// Migration between versions related
@WorkerThread
private fun disablePushNotificationsFromThirdPartySipAccounts() {
for (account in core.accountList) {
val params = account.params
if (params.identityAddress?.domain != corePreferences.defaultDomain && params.pushNotificationAllowed) {
val clone = params.clone()
clone.pushNotificationAllowed = false
Log.w("$TAG Updating account [${params.identityAddress?.asStringUriOnly()}] params to disable push notifications, they won't work and may cause issues when used with UDP transport protocol")
account.params = clone
}
}
}
@WorkerThread
private fun configurationMigration5To6() {
val policy = core.videoActivationPolicy.clone()
@ -1069,7 +1086,7 @@ class CoreContext
for (account in core.accountList) {
val params = account.params
if (params.domain == corePreferences.defaultDomain && params.limeAlgo.isNullOrEmpty()) {
if (params.identityAddress?.domain == corePreferences.defaultDomain && params.limeAlgo.isNullOrEmpty()) {
val clone = params.clone()
clone.limeAlgo = "c25519"
Log.i("$TAG Updating account [${params.identityAddress?.asStringUriOnly()}] params to use LIME algo c25519")

View file

@ -24,6 +24,7 @@ import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import java.util.Locale
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.core.AVPFMode
import org.linphone.core.Account
import org.linphone.core.AuthInfo
@ -45,6 +46,8 @@ class AccountSettingsViewModel
val expandNatPolicySettings = MutableLiveData<Boolean>()
val isOnDefaultDomain = MutableLiveData<Boolean>()
val pushNotificationsAvailable = MutableLiveData<Boolean>()
val pushNotificationsEnabled = MutableLiveData<Boolean>()
@ -129,11 +132,16 @@ class AccountSettingsViewModel
account = found
val params = account.params
pushNotificationsAvailable.postValue(core.isPushNotificationAvailable)
pushNotificationsEnabled.postValue(
core.isPushNotificationAvailable && params.pushNotificationAllowed
)
val defaultDomain = params.identityAddress?.domain == corePreferences.defaultDomain
isOnDefaultDomain.postValue(defaultDomain)
if (defaultDomain) {
pushNotificationsAvailable.postValue(core.isPushNotificationAvailable)
pushNotificationsEnabled.postValue(
core.isPushNotificationAvailable && params.pushNotificationAllowed
)
} else {
Log.w("$TAG Account isn't on default domain [${corePreferences.defaultDomain}], do not show push notification settings")
}
imEncryptionMandatory.postValue(params.instantMessagingEncryptionMandatory)
@ -199,7 +207,8 @@ class AccountSettingsViewModel
if (::account.isInitialized) {
val newParams = account.params.clone()
newParams.pushNotificationAllowed = pushNotificationsEnabled.value == true
newParams.pushNotificationAllowed = core.isPushNotificationAvailable && pushNotificationsEnabled.value == true
newParams.instantMessagingEncryptionMandatory = imEncryptionMandatory.value == true

View file

@ -82,6 +82,7 @@
android:layout_marginEnd="16dp"
android:enabled="@{viewModel.pushNotificationsAvailable}"
android:checked="@={viewModel.pushNotificationsEnabled}"
android:visibility="@{viewModel.isOnDefaultDomain ? View.VISIBLE : View.GONE}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
@ -96,6 +97,7 @@
android:text="@{viewModel.pushNotificationsAvailable ? @string/account_settings_push_notification_title : @string/account_settings_push_notification_not_available_title, default=@string/account_settings_push_notification_title}"
android:maxLines="2"
android:ellipsize="end"
android:visibility="@{viewModel.isOnDefaultDomain ? View.VISIBLE : View.GONE}"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="@id/push_notifications_switch"
app:layout_constraintStart_toStartOf="parent"

View file

@ -118,7 +118,7 @@
<string name="assistant_already_have_an_account">Vous avez déjà un compte ?</string>
<string name="assistant_sip_account_transport_protocol">Transport</string>
<string name="assistant_third_party_sip_account_warning_explanation">Certaines fonctionnalités telles que les conversations de groupe, les vidéo-conférences, etc… nécessitent un compte &appName;.\n\nCes fonctionnalités seront masquées si vous utilisez un compte SIP tiers.\n\nPour les activer dans un projet commercial, merci de nous contacter.</string>
<string name="assistant_third_party_sip_account_create_linphone_account">Je préfère créer un compte</string>
<string name="assistant_third_party_sip_account_create_linphone_account">Je préfère créer un compte &appName;</string>
<string name="assistant_third_party_sip_account_warning_ok">J\'ai compris</string>
<string name="assistant_account_register_unavailable_no_push_toast">Notifications push indisponible, la création de compte est donc désactivée.</string>
<string name="assistant_account_register_push_notification_not_received_error">Notification push non reçue, merci de réessayer plus tard</string>

View file

@ -158,7 +158,7 @@
<string name="assistant_already_have_an_account">Already have an account?</string>
<string name="assistant_sip_account_transport_protocol">Transport</string>
<string name="assistant_third_party_sip_account_warning_explanation">Some features require a &appName; account, such as group messaging, video conferences…\n\nThese features are hidden when you register with a third party SIP account.\n\nTo enable it in a commercial project, please contact us.</string>
<string name="assistant_third_party_sip_account_create_linphone_account">I prefer to create an account</string>
<string name="assistant_third_party_sip_account_create_linphone_account">I prefer to create a &appName; account</string>
<string name="assistant_third_party_sip_account_warning_ok">I understand</string>
<string name="assistant_account_register_unavailable_no_push_toast">Push notifications not available, account creation disabled</string>
<string name="assistant_account_register_push_notification_not_received_error">Push notification with auth token not received in 5 seconds, please try again later</string>