gpt4 book ai didi

java - 在 Android 中为双 SIM 设备配置 EAP-SIM

转载 作者:行者123 更新时间:2023-12-01 13:40:43 24 4
gpt4 key购买 nike

我尝试为单个 SIM 设备配置 EAP-SIM 并成功连接。现在我想在双 SIM 设备上配置特定的 SIM 卡。

我的观察是在单个 SIM 设备中配置 EAP 时,没有规定指定 SIM 身份。那么如何使用特定的 SIM 配置 EAP?

为单个 SIM 设备配置 EAP-SIM:

    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiEnterpriseConfig enterpriseConfig = new WifiEnterpriseConfig();
WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = "\"" + ssid + "\"";
wifiConfig.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
wifiConfig.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.SIM);
wifiConfig.enterpriseConfig = enterpriseConfig;
int nid = wifi.addNetwork(wifiConfig);
wifi.saveConfiguration();
wifi.enableNetwork(nid, true);

最佳答案

这个答案对我帮助很大。
How to programmatically create and read WEP/EAP WiFi configurations in Android?
这就是您使用 EAP Sim 配置 Wifi 的方式。

        private fun getWifiConfigurationForAirtelEAP(ssId: String,sim:String):WifiConfiguration{
val wifiConfiguration = WifiConfiguration()
wifiConfiguration.SSID = String.format("\"%s\"", ssId);
wifiConfiguration.hiddenSSID = false
wifiConfiguration.BSSID = null

wifiConfiguration.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN)

wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP)
wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP)
wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104)
wifiConfiguration.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40)

wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP)
wifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X)

wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP)
wifiConfiguration.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP)

wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.RSN)
wifiConfiguration.allowedProtocols.set(WifiConfiguration.Protocol.WPA)

wifiConfiguration.enterpriseConfig = getWifiEnterpriseConfig(sim)

return wifiConfiguration
}

private fun getWifiEnterpriseConfig(sim: String): WifiEnterpriseConfig {
val enterpriseConfig = WifiEnterpriseConfig()
enterpriseConfig.eapMethod = WifiEnterpriseConfig.Eap.SIM
enterpriseConfig.anonymousIdentity = "NULL"
val field = enterpriseConfig.javaClass.getDeclaredField("mFields");
field.isAccessible =true
val values = (field.get(enterpriseConfig) as HashMap<String,String>)
values.put(SIM_NUM,"\""+sim+"\"")
values.put(CLIENT_CERT,"NULL")
values.put(KEY_ID,"NULL")
values.put(ENGINE,"0")
values.put(ENGINE_ID,"NULL")
values.put(IDENTITY,"NULL")
values.put(CA_PATH,"NULL")
values.put(DOMAIN_SUFFIX_MATCH,"NULL")
values.put(CA_CERT,"NULL")
values.put(PASSWORD,"NULL")
values.put(ANONYMOUS_IDENTITY,"NULL")
return enterpriseConfig
}

关于java - 在 Android 中为双 SIM 设备配置 EAP-SIM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33891083/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com