From ea78f504d713f005721c97db1c3dbc688611da1e Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Thu, 22 Sep 2022 15:28:26 +0300 Subject: [PATCH] Small refactoring. --- .../android/sdk/internal/network/UserAgentHolder.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt index e0611a1de6..92d00c3895 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/UserAgentHolder.kt @@ -56,6 +56,11 @@ internal class UserAgentHolder @Inject constructor( appPackageName } val appVersion = tryOrNull { pm.getPackageInfo(context.applicationContext.packageName, 0).versionName } + + if (appName.isNullOrEmpty() || appVersion.isNullOrEmpty()) { + userAgent = tryOrNull { System.getProperty("http.agent") } ?: ("Java" + System.getProperty("java.version")) + return + } val deviceManufacturer = Build.MANUFACTURER val deviceModel = Build.MODEL @@ -63,11 +68,6 @@ internal class UserAgentHolder @Inject constructor( val deviceBuildId = Build.DISPLAY val matrixSdkVersion = BuildConfig.SDK_VERSION - if (appName.isNullOrEmpty() || appVersion.isNullOrEmpty()) { - userAgent = tryOrNull { System.getProperty("http.agent") } ?: ("Java" + System.getProperty("java.version")) - return - } - userAgent = buildString { append(appName) append("/")