diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/ParseDeviceUserAgentUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/ParseDeviceUserAgentUseCase.kt index 4cc1bf5c9f..2876d7e855 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/ParseDeviceUserAgentUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/ParseDeviceUserAgentUseCase.kt @@ -75,17 +75,12 @@ class ParseDeviceUserAgentUseCase @Inject constructor() { private fun parseDesktopUserAgent(userAgent: String): DeviceExtendedInfo { val browserInfo = parseBrowserInfoFromDesktopUserAgent(userAgent) + val operatingSystem = parseOperatingSystemFromDesktopUserAgent(userAgent) - val deviceOperatingSystemSegments = userAgent.substringAfter("(").substringBefore(")").split("; ") - val deviceOperatingSystem = if (deviceOperatingSystemSegments.getOrNull(1)?.startsWith("Android").orFalse()) { - deviceOperatingSystemSegments.getOrNull(1) - } else { - deviceOperatingSystemSegments.getOrNull(0) - } return DeviceExtendedInfo( deviceType = DeviceType.DESKTOP, deviceModel = null, - deviceOperatingSystem = deviceOperatingSystem, + deviceOperatingSystem = operatingSystem, clientName = browserInfo.name, clientVersion = browserInfo.version, ) @@ -131,6 +126,15 @@ class ParseDeviceUserAgentUseCase @Inject constructor() { } } + private fun parseOperatingSystemFromDesktopUserAgent(userAgent: String): String? { + val deviceOperatingSystemSegments = userAgent.substringAfter("(").substringBefore(")").split("; ") + return if (deviceOperatingSystemSegments.getOrNull(1)?.startsWith("Android").orFalse()) { + deviceOperatingSystemSegments.getOrNull(1) + } else { + deviceOperatingSystemSegments.getOrNull(0) + } + } + private fun parseWebUserAgent(userAgent: String): DeviceExtendedInfo { return parseDesktopUserAgent(userAgent).copy( deviceType = DeviceType.WEB