Support truncating SSID on buggy old devices
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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]}" }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user