mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Make sure device name used in user-agent doesn't contains any apostrophe
This commit is contained in:
parent
0ce886cb56
commit
49d8381705
5 changed files with 23 additions and 6 deletions
|
|
@ -842,12 +842,22 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
|
||||
@WorkerThread
|
||||
fun computeUserAgent() {
|
||||
if (corePreferences.deviceName.isEmpty()) {
|
||||
val savedDeviceName = corePreferences.deviceName
|
||||
val deviceName = if (savedDeviceName.isEmpty()) {
|
||||
Log.i("$TAG Device name not fetched yet, doing it now")
|
||||
corePreferences.deviceName = AppUtils.getDeviceName(context)
|
||||
Log.i("$TAG Fetched device name is [${corePreferences.deviceName}]")
|
||||
AppUtils.getDeviceName(context)
|
||||
} else if (savedDeviceName.contains("'")) {
|
||||
// Some VoIP providers such as voip.ms seem to not like apostrophe in user-agent
|
||||
// https://github.com/BelledonneCommunications/linphone-android/issues/2287
|
||||
Log.i("$TAG Found an apostrophe in device name, removing it")
|
||||
savedDeviceName.replace("'", "")
|
||||
} else {
|
||||
savedDeviceName
|
||||
}
|
||||
val deviceName = corePreferences.deviceName
|
||||
if (savedDeviceName != deviceName) {
|
||||
corePreferences.deviceName = deviceName
|
||||
}
|
||||
Log.i("$TAG Device name for user-agent is [$deviceName]")
|
||||
|
||||
val appName = context.getString(org.linphone.R.string.app_name)
|
||||
val androidVersion = BuildConfig.VERSION_NAME
|
||||
|
|
|
|||
|
|
@ -161,14 +161,19 @@ class AppUtils {
|
|||
Settings.Global.DEVICE_NAME
|
||||
)
|
||||
if (name == null) {
|
||||
Log.w("$TAG Failed to obtain device name, trying to get bluetooth name")
|
||||
name = Settings.Secure.getString(
|
||||
context.contentResolver,
|
||||
"bluetooth_name"
|
||||
)
|
||||
}
|
||||
if (name == null) {
|
||||
name = Build.MANUFACTURER + " " + Build.MODEL
|
||||
Log.w("$TAG Failed to obtain bluetooth name, using device's manufacturer & model")
|
||||
name = "${Build.MANUFACTURER} ${Build.MODEL}"
|
||||
}
|
||||
|
||||
// Some VoIP providers such as voip.ms seem to not like apostrophe in user-agent
|
||||
name = name.replace("'", "")
|
||||
return name
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@
|
|||
android:maxLines="1"
|
||||
android:background="@drawable/edit_text_background"
|
||||
android:inputType="text|textUri"
|
||||
android:hint="@string/settings_advanced_device_id"
|
||||
android:hint="@string/settings_advanced_device_id_hint"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintWidth_max="@dimen/text_input_max_width"
|
||||
app:layout_constraintTop_toBottomOf="@id/device_id_label"
|
||||
|
|
|
|||
|
|
@ -255,6 +255,7 @@
|
|||
<string name="settings_advanced_title">Paramètres avancés</string>
|
||||
<string name="settings_advanced_keep_alive_service_title">Garder l\'app en vie via un Service</string>
|
||||
<string name="settings_advanced_device_id">Nom du périphérique</string>
|
||||
<string name="settings_advanced_device_id_hint">Caractères alpha-numériques uniquement</string>
|
||||
<string name="settings_advanced_media_encryption_title">Chiffrement du média</string>
|
||||
<string name="settings_advanced_media_encryption_mandatory_title">Rendre le chiffrement du média obligatoire</string>
|
||||
<string name="settings_advanced_remote_provisioning_url">URL de configuration distante</string>
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@
|
|||
<string name="settings_advanced_title">Advanced settings</string>
|
||||
<string name="settings_advanced_keep_alive_service_title">Keep app alive using Service</string>
|
||||
<string name="settings_advanced_device_id">Device ID</string>
|
||||
<string name="settings_advanced_device_id_hint">Alpha-numerical characters only</string>
|
||||
<string name="settings_advanced_media_encryption_title">Media encryption</string>
|
||||
<string name="settings_advanced_media_encryption_mandatory_title">Media encryption mandatory</string>
|
||||
<string name="settings_advanced_remote_provisioning_url">Remote provisioning URL</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue