From 307f47f878e8bacc645ac9816bd6161d1736c2d7 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Thu, 2 Feb 2023 08:16:25 +0200 Subject: [PATCH] Improved WiFi hotspot address detection --- app/src/main/kotlin/com/tutpro/baresip/Utils.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt index 17238dc3..f7c295df 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt @@ -433,16 +433,14 @@ object Utils { while (interfaces.hasMoreElements()) { val iface: NetworkInterface = interfaces.nextElement() val ifName = iface.name - if (ifName.startsWith("ap") || ifName.startsWith("wlan")) { - val addresses: Enumeration = iface.inetAddresses - while (addresses.hasMoreElements()) { - val inetAddress: InetAddress = addresses.nextElement() - if (inetAddress.hostAddress != null && !inetAddress.isLoopbackAddress && - !inetAddress.isLinkLocalAddress) - result[inetAddress.hostAddress!!] = ifName - } - if (result.isNotEmpty()) return result + Log.d(TAG, "Found interface with name $ifName") + val addresses: Enumeration = iface.inetAddresses + while (addresses.hasMoreElements()) { + val inetAddress: InetAddress = addresses.nextElement() + if (inetAddress.isSiteLocalAddress) + result[inetAddress.hostAddress!!] = ifName } + if (result.isNotEmpty()) return result } } catch (ex: SocketException) { Log.e(TAG, ex.toString())