问题描述
我有添加新 Passpoint 的代码。 它使用 addNetworksSuggestions 在 Android 11 中工作。
但是,在 Android 10 中,它因 IllegalArgumentException 而失败
val config = PasspointConfiguration().apply {
credential = Credential().apply {
userCredential = Credential.UserCredential().apply {
this.username = username
this.password = Base64.getEncoder().encodetoString(password.toByteArray())
this.eapType = eapType
this.nonEapInnerMethod = nonEapInnerMethod
}
this.realm = realm
this.certCredential = null
this.caCertificate = caCertificate
this.clientPrivateKey = null
this.clientCertificateChain = null
}
homeSp = HomeSp().apply {
this.fqdn = fqdn
this.friendlyName = friendlyName
}
}
val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val suggestion = WifiNetworkSuggestion.Builder()
.setPasspointConfig(config)
.setIsAppInteractionrequired(true)
.build()
val suggestionsList = arraylistof(suggestion)
val result = wifiManager.addNetworkSuggestions(suggestionsList)
} else {
wifiManager.addOrUpdatePasspointConfiguration(config)
}
}
catch (e: Exception) {
e.printstacktrace()
}
caCertifcate 绝对正确,因为 Android 11 没有问题。
我错过了什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)