Refine apKeyManagement

This commit is contained in:
Mygod
2019-06-01 07:39:23 +08:00
parent c0e40436df
commit d168dea613

View File

@@ -65,9 +65,9 @@ fun channelToFrequency(channel: Int) = when (channel) {
else -> throw IllegalArgumentException("Invalid channel $channel") else -> throw IllegalArgumentException("Invalid channel $channel")
} }
val WifiConfiguration.apKeyManagement get() = allowedKeyManagement.nextSetBit(0).also { selected -> val WifiConfiguration.apKeyManagement get() = allowedKeyManagement.nextSetBit(0).let { selected ->
check(selected >= 0) { "No key management selected" }
check(allowedKeyManagement.nextSetBit(selected + 1) < 0) { "More than 1 key managements supplied" } check(allowedKeyManagement.nextSetBit(selected + 1) < 0) { "More than 1 key managements supplied" }
if (selected < 0) WifiConfiguration.KeyMgmt.NONE else selected // getAuthType returns NONE if nothing is selected
} }
private val qrSanitizer = Regex("([\\\\\":;,])") private val qrSanitizer = Regex("([\\\\\":;,])")