Support OWE mode
This commit is contained in:
@@ -87,7 +87,14 @@ data class SoftApConfigurationCompat(
|
|||||||
*/
|
*/
|
||||||
private const val LEGACY_WPA2_PSK = 4
|
private const val LEGACY_WPA2_PSK = 4
|
||||||
|
|
||||||
val securityTypes = arrayOf("OPEN", "WPA2-PSK", "WPA3-SAE Transition mode", "WPA3-SAE")
|
val securityTypes = arrayOf(
|
||||||
|
"OPEN",
|
||||||
|
"WPA2-PSK",
|
||||||
|
"WPA3-SAE Transition mode",
|
||||||
|
"WPA3-SAE",
|
||||||
|
"WPA3-OWE Transition",
|
||||||
|
"WPA3-OWE",
|
||||||
|
)
|
||||||
|
|
||||||
private val qrSanitizer = Regex("([\\\\\":;,])")
|
private val qrSanitizer = Regex("([\\\\\":;,])")
|
||||||
|
|
||||||
@@ -304,6 +311,7 @@ data class SoftApConfigurationCompat(
|
|||||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK
|
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK
|
||||||
}
|
}
|
||||||
android.net.wifi.WifiConfiguration.KeyMgmt.SAE -> SoftApConfiguration.SECURITY_TYPE_WPA3_SAE
|
android.net.wifi.WifiConfiguration.KeyMgmt.SAE -> SoftApConfiguration.SECURITY_TYPE_WPA3_SAE
|
||||||
|
android.net.wifi.WifiConfiguration.KeyMgmt.OWE -> SoftApConfiguration.SECURITY_TYPE_WPA3_OWE
|
||||||
else -> android.net.wifi.WifiConfiguration.KeyMgmt.strings
|
else -> android.net.wifi.WifiConfiguration.KeyMgmt.strings
|
||||||
.getOrElse<String>(selected) { "?" }.let {
|
.getOrElse<String>(selected) { "?" }.let {
|
||||||
throw IllegalArgumentException("Unrecognized key management $it ($selected)")
|
throw IllegalArgumentException("Unrecognized key management $it ($selected)")
|
||||||
@@ -417,6 +425,8 @@ data class SoftApConfigurationCompat(
|
|||||||
// CHANGED: not actually converted in framework-wifi
|
// CHANGED: not actually converted in framework-wifi
|
||||||
SoftApConfiguration.SECURITY_TYPE_WPA3_SAE,
|
SoftApConfiguration.SECURITY_TYPE_WPA3_SAE,
|
||||||
SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION -> android.net.wifi.WifiConfiguration.KeyMgmt.SAE
|
SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION -> android.net.wifi.WifiConfiguration.KeyMgmt.SAE
|
||||||
|
SoftApConfiguration.SECURITY_TYPE_WPA3_OWE,
|
||||||
|
SoftApConfiguration.SECURITY_TYPE_WPA3_OWE_TRANSITION -> android.net.wifi.WifiConfiguration.KeyMgmt.OWE
|
||||||
else -> throw IllegalArgumentException("Convert fail, unsupported security type :$securityType")
|
else -> throw IllegalArgumentException("Convert fail, unsupported security type :$securityType")
|
||||||
})
|
})
|
||||||
result.allowedAuthAlgorithms.clear()
|
result.allowedAuthAlgorithms.clear()
|
||||||
@@ -463,11 +473,12 @@ data class SoftApConfigurationCompat(
|
|||||||
fun toQrCode() = StringBuilder("WIFI:").apply {
|
fun toQrCode() = StringBuilder("WIFI:").apply {
|
||||||
fun String.sanitize() = qrSanitizer.replace(this) { "\\${it.groupValues[1]}" }
|
fun String.sanitize() = qrSanitizer.replace(this) { "\\${it.groupValues[1]}" }
|
||||||
when (securityType) {
|
when (securityType) {
|
||||||
SoftApConfiguration.SECURITY_TYPE_OPEN -> { }
|
SoftApConfiguration.SECURITY_TYPE_OPEN, SoftApConfiguration.SECURITY_TYPE_WPA3_OWE_TRANSITION,
|
||||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK -> append("T:WPA;")
|
SoftApConfiguration.SECURITY_TYPE_WPA3_OWE -> { }
|
||||||
SoftApConfiguration.SECURITY_TYPE_WPA3_SAE, SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION -> {
|
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK, SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION -> {
|
||||||
append("T:SAE;")
|
append("T:WPA;")
|
||||||
}
|
}
|
||||||
|
SoftApConfiguration.SECURITY_TYPE_WPA3_SAE -> append("T:SAE;")
|
||||||
else -> throw IllegalArgumentException("Unsupported authentication type")
|
else -> throw IllegalArgumentException("Unsupported authentication type")
|
||||||
}
|
}
|
||||||
append("S:")
|
append("S:")
|
||||||
|
|||||||
@@ -170,18 +170,23 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) = error("Must select something")
|
override fun onNothingSelected(parent: AdapterView<*>?) = error("Must select something")
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
if (position != SoftApConfiguration.SECURITY_TYPE_OPEN) {
|
when (position) {
|
||||||
dialogView.passwordWrapper.isGone = false
|
SoftApConfiguration.SECURITY_TYPE_OPEN,
|
||||||
if (position == SoftApConfiguration.SECURITY_TYPE_WPA3_SAE) {
|
SoftApConfiguration.SECURITY_TYPE_WPA3_OWE_TRANSITION,
|
||||||
dialogView.passwordWrapper.isCounterEnabled = false
|
SoftApConfiguration.SECURITY_TYPE_WPA3_OWE -> dialogView.passwordWrapper.isGone = true
|
||||||
dialogView.passwordWrapper.counterMaxLength = 0
|
else -> {
|
||||||
dialogView.password.filters = emptyArray()
|
dialogView.passwordWrapper.isGone = false
|
||||||
} else {
|
if (position == SoftApConfiguration.SECURITY_TYPE_WPA3_SAE) {
|
||||||
dialogView.passwordWrapper.isCounterEnabled = true
|
dialogView.passwordWrapper.isCounterEnabled = false
|
||||||
dialogView.passwordWrapper.counterMaxLength = 63
|
dialogView.passwordWrapper.counterMaxLength = 0
|
||||||
dialogView.password.filters = arrayOf(InputFilter.LengthFilter(63))
|
dialogView.password.filters = emptyArray()
|
||||||
|
} else {
|
||||||
|
dialogView.passwordWrapper.isCounterEnabled = true
|
||||||
|
dialogView.passwordWrapper.counterMaxLength = 63
|
||||||
|
dialogView.password.filters = arrayOf(InputFilter.LengthFilter(63))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else dialogView.passwordWrapper.isGone = true
|
}
|
||||||
validate()
|
validate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -278,7 +283,8 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
} else dialogView.security.selectedItemPosition
|
} else dialogView.security.selectedItemPosition
|
||||||
// see also: https://android.googlesource.com/platform/frameworks/base/+/92c8f59/wifi/java/android/net/wifi/SoftApConfiguration.java#688
|
// see also: https://android.googlesource.com/platform/frameworks/base/+/92c8f59/wifi/java/android/net/wifi/SoftApConfiguration.java#688
|
||||||
val passwordValid = when (selectedSecurity) {
|
val passwordValid = when (selectedSecurity) {
|
||||||
SoftApConfiguration.SECURITY_TYPE_OPEN -> true
|
SoftApConfiguration.SECURITY_TYPE_OPEN, SoftApConfiguration.SECURITY_TYPE_WPA3_OWE_TRANSITION,
|
||||||
|
SoftApConfiguration.SECURITY_TYPE_WPA3_OWE -> true
|
||||||
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK, SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION -> {
|
SoftApConfiguration.SECURITY_TYPE_WPA2_PSK, SoftApConfiguration.SECURITY_TYPE_WPA3_SAE_TRANSITION -> {
|
||||||
dialogView.password.length() in 8..63
|
dialogView.password.length() in 8..63
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user