Support truncating SSID on buggy old devices
This commit is contained in:
@@ -354,7 +354,7 @@ data class SoftApConfigurationCompat(
|
|||||||
@Deprecated("Class deprecated in framework")
|
@Deprecated("Class deprecated in framework")
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
fun android.net.wifi.WifiConfiguration.toCompat() = SoftApConfigurationCompat(
|
fun android.net.wifi.WifiConfiguration.toCompat() = SoftApConfigurationCompat(
|
||||||
WifiSsidCompat.fromUtf8Text(SSID),
|
WifiSsidCompat.fromUtf8Text(SSID, true),
|
||||||
BSSID?.let { MacAddress.fromString(it) },
|
BSSID?.let { MacAddress.fromString(it) },
|
||||||
preSharedKey,
|
preSharedKey,
|
||||||
hiddenSSID,
|
hiddenSSID,
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ data class WifiSsidCompat(val bytes: ByteArray) : Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Contract("null -> null; !null -> !null")
|
@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]}" }
|
fun toMeCard(text: String) = qrSanitizer.replace(text) { "\\${it.groupValues[1]}" }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user