diff --git a/app/src/main/assets/linphonerc_factory b/app/src/main/assets/linphonerc_factory index 3855f2db0..ca228ff95 100644 --- a/app/src/main/assets/linphonerc_factory +++ b/app/src/main/assets/linphonerc_factory @@ -1,8 +1,8 @@ ## Start of factory rc -#This file shall not contain path referencing package name, in order to be portable when app is renamed. -#Paths to resources must be set from LinphoneManager, after creating LinphoneCore. +# This file shall not contain path referencing package name, in order to be portable when app is renamed. +# Paths to resources must be set from LinphoneManager, after creating LinphoneCore. [net] mtu=1300 diff --git a/app/src/main/java/org/linphone/activities/main/settings/viewmodels/NetworkSettingsViewModel.kt b/app/src/main/java/org/linphone/activities/main/settings/viewmodels/NetworkSettingsViewModel.kt index 7c5ed940f..2e3af9d9a 100644 --- a/app/src/main/java/org/linphone/activities/main/settings/viewmodels/NetworkSettingsViewModel.kt +++ b/app/src/main/java/org/linphone/activities/main/settings/viewmodels/NetworkSettingsViewModel.kt @@ -46,6 +46,13 @@ class NetworkSettingsViewModel : GenericSettingsViewModel() { val pushNotifications = MutableLiveData() val pushNotificationsAvailable = MutableLiveData() + val legacyPushNotificationFormatListener = object : SettingListenerStub() { + override fun onBoolValueChanged(newValue: Boolean) { + prefs.useLegacyPushNotificationFormat = newValue + } + } + val legacyPushNotificationFormat = MutableLiveData() + val randomPortsListener = object : SettingListenerStub() { override fun onBoolValueChanged(newValue: Boolean) { val port = if (newValue) -1 else 5060 @@ -71,6 +78,7 @@ class NetworkSettingsViewModel : GenericSettingsViewModel() { allowIpv6.value = core.ipv6Enabled() pushNotifications.value = core.isPushNotificationEnabled pushNotificationsAvailable.value = core.isPushNotificationAvailable + legacyPushNotificationFormat.value = prefs.useLegacyPushNotificationFormat randomPorts.value = getSipPort() == -1 sipPort.value = getSipPort() } diff --git a/app/src/main/java/org/linphone/core/CoreContext.kt b/app/src/main/java/org/linphone/core/CoreContext.kt index 1f3314231..44047e80a 100644 --- a/app/src/main/java/org/linphone/core/CoreContext.kt +++ b/app/src/main/java/org/linphone/core/CoreContext.kt @@ -220,11 +220,12 @@ class CoreContext(val context: Context, coreConfig: Config) { notificationsManager.onCoreReady() core.addListener(listener) + if (isPush) { Log.i("[Context] Push received, assume in background") core.enterBackground() } - core.config.setBool("net", "use_legacy_push_notification_params", true) + core.start() configureCore() @@ -252,8 +253,8 @@ class CoreContext(val context: Context, coreConfig: Config) { private fun configureCore() { Log.i("[Context] Configuring Core") - core.zrtpSecretsFile = context.filesDir.absolutePath + "/zrtp_secrets" - core.callLogsDatabasePath = context.filesDir.absolutePath + "/linphone-log-history.db" + core.zrtpSecretsFile = corePreferences.zrtpSecretsPath + core.callLogsDatabasePath = corePreferences.callHistoryDatabasePath initUserCertificates() @@ -297,7 +298,7 @@ class CoreContext(val context: Context, coreConfig: Config) { } private fun initUserCertificates() { - val userCertsPath = context.filesDir.absolutePath + "/user-certs" + val userCertsPath = corePreferences.userCertificatesPath val f = File(userCertsPath) if (!f.exists()) { if (!f.mkdir()) { diff --git a/app/src/main/java/org/linphone/core/CorePreferences.kt b/app/src/main/java/org/linphone/core/CorePreferences.kt index e63a06215..87a89fba2 100644 --- a/app/src/main/java/org/linphone/core/CorePreferences.kt +++ b/app/src/main/java/org/linphone/core/CorePreferences.kt @@ -241,6 +241,12 @@ class CorePreferences constructor(private val context: Context) { config.setInt("app", "version_check_url_last_timestamp", value) } + var useLegacyPushNotificationFormat: Boolean + get() = config.getBool("net", "use_legacy_push_notification_params", false) + set(value) { + config.setBool("net", "use_legacy_push_notification_params", value) + } + /* Read only application settings, some were previously in non_localizable_custom */ val defaultDomain: String @@ -398,6 +404,15 @@ class CorePreferences constructor(private val context: Context) { val ringtonePath: String get() = context.filesDir.absolutePath + "/share/sounds/linphone/rings/notes_of_the_optimistic.mkv" + val userCertificatesPath: String + get() = context.filesDir.absolutePath + "/user-certs" + + val zrtpSecretsPath: String + get() = context.filesDir.absolutePath + "/zrtp_secrets" + + val callHistoryDatabasePath: String + get() = context.filesDir.absolutePath + "/linphone-log-history.db" + fun copyAssetsFromPackage() { copy("linphonerc_default", configPath) copy("linphonerc_factory", factoryConfigPath, true) diff --git a/app/src/main/res/layout/settings_network_fragment.xml b/app/src/main/res/layout/settings_network_fragment.xml index db2f84f1f..eb36f1cac 100644 --- a/app/src/main/res/layout/settings_network_fragment.xml +++ b/app/src/main/res/layout/settings_network_fragment.xml @@ -68,29 +68,37 @@ + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b7392fc5b..0271e76d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -425,13 +425,15 @@ Use WiFi only - + Allow IPv6 - + Enable push notifications - + + Use legacy push notification params + Required when using Flexisip < 2.0 Use random ports - + SIP port to use