提交 23c87d0a 编写于 作者: 杜庆泉's avatar 杜庆泉

meizu 手机测试链接ok

上级 8d09e09e
...@@ -8,7 +8,6 @@ import ScanResult from "android.net.wifi.ScanResult"; ...@@ -8,7 +8,6 @@ import ScanResult from "android.net.wifi.ScanResult";
import BroadcastReceiver from "android.content.BroadcastReceiver"; import BroadcastReceiver from "android.content.BroadcastReceiver";
import ActivityCompat from "androidx.core.app.ActivityCompat"; import ActivityCompat from "androidx.core.app.ActivityCompat";
import IntentFilter from "android.content.IntentFilter"; import IntentFilter from "android.content.IntentFilter";
import Gson from "com.google.gson.Gson";
import JSONObject from "com.alibaba.fastjson.JSONObject"; import JSONObject from "com.alibaba.fastjson.JSONObject";
import Intent from "android.content.Intent"; import Intent from "android.content.Intent";
import Thread from "java.lang.Thread"; import Thread from "java.lang.Thread";
...@@ -89,13 +88,13 @@ function wrapWifiConfiguration(SSID:string ,password:string,passwordType:string) ...@@ -89,13 +88,13 @@ function wrapWifiConfiguration(SSID:string ,password:string,passwordType:string)
if ("NONE".equals(passwordType)) { if ("NONE".equals(passwordType)) {
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
} }
// // wep // wep
if ("WEP".equals(passwordType)) { if ("WEP".equals(passwordType)) {
if (!TextUtils.isEmpty(password)) { if (!TextUtils.isEmpty(password)) {
if (isHexWepKey(password)) { if (isHexWepKey(password)) {
config.wepKeys[0] = password; config.wepKeys[0] = password;
} else { } else {
config.wepKeys[0] = "\"" + password + "\""; config.wepKeys[0] = "\"".concat(password).concat("\"");
} }
} }
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN); config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
...@@ -105,20 +104,16 @@ function wrapWifiConfiguration(SSID:string ,password:string,passwordType:string) ...@@ -105,20 +104,16 @@ function wrapWifiConfiguration(SSID:string ,password:string,passwordType:string)
} }
// wpa // wpa
if ("WPA".equals(passwordType)) { if ("WPA".equals(passwordType)) {
config.preSharedKey = "\"" + password + "\""; config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
config.hiddenSSID = true;
config.allowedAuthAlgorithms
.set(WifiConfiguration.AuthAlgorithm.OPEN);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedPairwiseCiphers
.set(WifiConfiguration.PairwiseCipher.TKIP);
// 此处需要修改否则不能自动重联
config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
config.allowedPairwiseCiphers config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
.set(WifiConfiguration.PairwiseCipher.CCMP); config.preSharedKey = "\"".concat(password).concat("\"");
config.status = WifiConfiguration.Status.ENABLED;
} }
return config; return config;
...@@ -443,6 +438,7 @@ export function connectWifi(option: WifiConnectOption) { ...@@ -443,6 +438,7 @@ export function connectWifi(option: WifiConnectOption) {
if (existingConfig.SSID.equals("\"" + option.SSID + "\"")) { if (existingConfig.SSID.equals("\"" + option.SSID + "\"")) {
targetExistConfig = existingConfig targetExistConfig = existingConfig
} }
} }
if (targetExistConfig != null) { if (targetExistConfig != null) {
...@@ -450,11 +446,14 @@ export function connectWifi(option: WifiConnectOption) { ...@@ -450,11 +446,14 @@ export function connectWifi(option: WifiConnectOption) {
} }
try { try {
console.log(wifiConfigration);
let netID = wifiManager.addNetwork(wifiConfigration); let netID = wifiManager.addNetwork(wifiConfigration);
console.log("netID === " + netID);
let enabled = wifiManager.enableNetwork(netID, true); let enabled = wifiManager.enableNetwork(netID, true);
console.log("enabled === " + enabled);
let connected = wifiManager.reconnect(); let connected = wifiManager.reconnect();
console.log(enabled); console.log("connected === " + connected);
console.log(connected);
} catch (e) { } catch (e) {
// TODO: handle exception // TODO: handle exception
console.log(e); console.log(e);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册