Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
D-GSQ
uni-api
提交
23c87d0a
U
uni-api
项目概览
D-GSQ
/
uni-api
与 Fork 源项目一致
Fork自
DCloud / uni-api
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
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";
import BroadcastReceiver from "android.content.BroadcastReceiver";
import ActivityCompat from "androidx.core.app.ActivityCompat";
import IntentFilter from "android.content.IntentFilter";
import Gson from "com.google.gson.Gson";
import JSONObject from "com.alibaba.fastjson.JSONObject";
import Intent from "android.content.Intent";
import Thread from "java.lang.Thread";
...
...
@@ -89,13 +88,13 @@ function wrapWifiConfiguration(SSID:string ,password:string,passwordType:string)
if ("NONE".equals(passwordType)) {
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
}
//
//
wep
// wep
if ("WEP".equals(passwordType)) {
if (!TextUtils.isEmpty(password)) {
if (isHexWepKey(password)) {
config.wepKeys[0] = password;
} else {
config.wepKeys[0] = "\""
+ password + "\""
;
config.wepKeys[0] = "\""
.concat(password).concat("\"")
;
}
}
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
...
...
@@ -105,20 +104,16 @@ function wrapWifiConfiguration(SSID:string ,password:string,passwordType:string)
}
// wpa
if ("WPA".equals(passwordType)) {
config.preSharedKey = "\"" + password + "\"";
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.RSN);
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.allowedPairwiseCiphers
.set(WifiConfiguration.PairwiseCipher.CCMP);
config.status = WifiConfiguration.Status.ENABLED;
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.preSharedKey = "\"".concat(password).concat("\"");
}
return config;
...
...
@@ -443,6 +438,7 @@ export function connectWifi(option: WifiConnectOption) {
if (existingConfig.SSID.equals("\"" + option.SSID + "\"")) {
targetExistConfig = existingConfig
}
}
if (targetExistConfig != null) {
...
...
@@ -450,11 +446,14 @@ export function connectWifi(option: WifiConnectOption) {
}
try {
console.log(wifiConfigration);
let netID = wifiManager.addNetwork(wifiConfigration);
console.log("netID === " + netID);
let enabled = wifiManager.enableNetwork(netID, true);
console.log("enabled === " + enabled);
let connected = wifiManager.reconnect();
console.log(
enabl
ed);
console.log(connected);
console.log(
"connected === " + connect
ed);
} catch (e) {
// TODO: handle exception
console.log(e);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录