Fixed NAT policy account settings changes not saved/restored when app restarts

This commit is contained in:
Sylvain Berfini 2022-12-05 10:43:36 +01:00
parent b511867e62
commit 54a65f713a
2 changed files with 11 additions and 14 deletions

View file

@ -14,8 +14,7 @@ static def getPackageName() {
def firebaseEnabled = new File(projectDir.absolutePath +'/google-services.json').exists()
def crashlyticsEnabled = false//new File(projectDir.absolutePath +'/google-services.json').exists() && new File(LinphoneSdkBuildDir + '/libs/').exists() && new File(LinphoneSdkBuildDir + '/libs-debug/').exists()
def crashlyticsEnabled = new File(projectDir.absolutePath +'/google-services.json').exists() && new File(LinphoneSdkBuildDir + '/libs/').exists() && new File(LinphoneSdkBuildDir + '/libs-debug/').exists()
if (firebaseEnabled) {
apply plugin: 'com.google.gms.google-services'

View file

@ -312,19 +312,14 @@ class AccountSettingsViewModel(val account: Account) : GenericSettingsViewModel(
val stunServerListener = object : SettingListenerStub() {
override fun onTextValueChanged(newValue: String) {
val params = account.params.clone()
if (params.natPolicy == null) {
Log.w("[Account Settings] No NAT Policy object in account params yet")
val natPolicy = core.createNatPolicy()
natPolicy.stunServer = newValue
natPolicy.isStunEnabled = newValue.isNotEmpty()
params.natPolicy = natPolicy
} else {
params.natPolicy?.stunServer = newValue
params.natPolicy?.isStunEnabled = newValue.isNotEmpty()
}
val natPolicy = params.natPolicy
val newNatPolicy = natPolicy?.clone() ?: core.createNatPolicy()
newNatPolicy.stunServer = newValue
newNatPolicy.isStunEnabled = newValue.isNotEmpty()
params.natPolicy = newNatPolicy
account.params = params
if (newValue.isEmpty()) ice.value = false
stunServer.value = newValue
account.params = params
}
}
val stunServer = MutableLiveData<String>()
@ -332,7 +327,10 @@ class AccountSettingsViewModel(val account: Account) : GenericSettingsViewModel(
val iceListener = object : SettingListenerStub() {
override fun onBoolValueChanged(newValue: Boolean) {
val params = account.params.clone()
params.natPolicy?.isIceEnabled = newValue
val natPolicy = params.natPolicy
val newNatPolicy = natPolicy?.clone() ?: core.createNatPolicy()
newNatPolicy.isIceEnabled = newValue
params.natPolicy = newNatPolicy
account.params = params
}
}