Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
23c87d0a
U
uni-api
项目概览
DCloud
/
uni-api
通知
677
Star
23
Fork
12
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
23c87d0a
编写于
11月 30, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
meizu 手机测试链接ok
上级
8d09e09e
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
16 addition
and
17 deletion
+16
-17
uni_modules/uni-wifi/utssdk/app-android/index.uts
uni_modules/uni-wifi/utssdk/app-android/index.uts
+16
-17
未找到文件。
uni_modules/uni-wifi/utssdk/app-android/index.uts
浏览文件 @
23c87d0a
...
@@ -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(
enabl
ed);
console.log(
"connected === " + connect
ed);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录