diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt index 72ab71ea..52f189a4 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt @@ -354,7 +354,7 @@ data class SoftApConfigurationCompat( @Deprecated("Class deprecated in framework") @Suppress("DEPRECATION") fun android.net.wifi.WifiConfiguration.toCompat() = SoftApConfigurationCompat( - WifiSsidCompat.fromUtf8Text(SSID), + WifiSsidCompat.fromUtf8Text(SSID, true), BSSID?.let { MacAddress.fromString(it) }, preSharedKey, hiddenSSID, diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiSsidCompat.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiSsidCompat.kt index 060242ba..c8fa1e8f 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiSsidCompat.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiSsidCompat.kt @@ -24,7 +24,9 @@ data class WifiSsidCompat(val bytes: ByteArray) : Parcelable { } @Contract("null -> null; !null -> !null") - fun fromUtf8Text(text: CharSequence?) = text?.toString()?.toByteArray()?.let { WifiSsidCompat(it) } + fun fromUtf8Text(text: CharSequence?, truncate: Boolean = false) = text?.toString()?.toByteArray()?.let { + WifiSsidCompat(if (truncate && it.size > 32) it.sliceArray(0 until 32) else it) + } fun toMeCard(text: String) = qrSanitizer.replace(text) { "\\${it.groupValues[1]}" }