Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
15db17d5
U
uni-api
项目概览
DCloud
/
uni-api
通知
670
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看板
提交
15db17d5
编写于
9月 06, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uniError add
上级
bfe51f67
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
127 addition
and
178 deletion
+127
-178
pages/index/index.vue
pages/index/index.vue
+12
-1
uni_modules/uni-getLocation-tencent/utssdk/app-android/index.uts
...ules/uni-getLocation-tencent/utssdk/app-android/index.uts
+5
-20
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
+1
-9
uni_modules/uni-wifi/utssdk/app-android/index.uts
uni_modules/uni-wifi/utssdk/app-android/index.uts
+80
-85
uni_modules/uni-wifi/utssdk/app-ios/index.uts
uni_modules/uni-wifi/utssdk/app-ios/index.uts
+23
-57
uni_modules/uni-wifi/utssdk/interface.uts
uni_modules/uni-wifi/utssdk/interface.uts
+6
-6
未找到文件。
pages/index/index.vue
浏览文件 @
15db17d5
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<button
@
tap=
"testGetBatteryInfoSync"
>
同步获取电池电量
</button>
<button
@
tap=
"testGetBatteryInfoSync"
>
同步获取电池电量
</button>
<button
@
tap=
"testonMemoryWarning"
>
开启内存不足告警监听
</button>
<button
@
tap=
"testonMemoryWarning"
>
开启内存不足告警监听
</button>
<button
@
tap=
"testoffMemoryWarning"
>
关闭内存不足告警监听
</button>
<button
@
tap=
"testoffMemoryWarning"
>
关闭内存不足告警监听
</button>
<button
@
tap=
"getLocationTest"
style=
"width: 100%;"
>
获取定位
</button>
</view>
</view>
</
template
>
</
template
>
...
@@ -46,6 +46,17 @@
...
@@ -46,6 +46,17 @@
fn
:
function
(
res
){
fn
:
function
(
res
){
console
.
log
(
res
)
console
.
log
(
res
)
},
},
getLocationTest
()
{
console
.
log
(
"
------- getLocationTest:
"
);
uni
.
getLocation
({
type
:
'
gcj02
'
,
success
(
res
)
{
console
.
log
(
"
success
"
,
res
);
},
fail
(
res
)
{
console
.
log
(
"
fail
"
,
res
);
}
})
},
onGetWifiList2_assert0
()
{
onGetWifiList2_assert0
()
{
console
.
log
(
"
------- onGetWifiList2_assert0:
"
,
this
.
id
);
console
.
log
(
"
------- onGetWifiList2_assert0:
"
,
this
.
id
);
const
fn
=
res
=>
console
.
log
(
'
onGetWifiList res
'
,
res
)
const
fn
=
res
=>
console
.
log
(
'
onGetWifiList res
'
,
res
)
...
...
uni_modules/uni-getLocation-tencent/utssdk/app-android/index.uts
浏览文件 @
15db17d5
...
@@ -21,21 +21,14 @@ export const getLocation : GetLocation = function (options : GetLocationOptions)
...
@@ -21,21 +21,14 @@ export const getLocation : GetLocation = function (options : GetLocationOptions)
if(!checkHasIntegration()){
if(!checkHasIntegration()){
// 当前没有集成腾讯sdk,提示需要打包
// 当前没有集成腾讯sdk,提示需要打包
let ret : GetLocationFail = {
let ret = new UniError("uni-getLocation-tencent",-10,"需要打自定义基座");
errCode: -10,
errMsg: "需要打自定义基座",
errSubject: "uni-getLocation-tencent"
}
options.fail?.(ret)
options.fail?.(ret)
options.complete?.(ret)
options.complete?.(ret)
return;
return;
}
}
if (!checkLocationConfig()) {
if (!checkLocationConfig()) {
let ret : GetLocationFail = {
let ret = new UniError("uni-getLocation-tencent",-20,"未通过配置预校验,通常是app key 配置错误");
errCode: -20,
errMsg: "未通过配置预校验,通常是app key 配置错误",
errSubject: "uni-getLocation-tencent"
}
options.fail?.(ret)
options.fail?.(ret)
options.complete?.(ret)
options.complete?.(ret)
return;
return;
...
@@ -52,11 +45,7 @@ export const getLocation : GetLocation = function (options : GetLocationOptions)
...
@@ -52,11 +45,7 @@ export const getLocation : GetLocation = function (options : GetLocationOptions)
}
}
}, function (_doNotAskAgain:boolean,_grantedList:string[]) {
}, function (_doNotAskAgain:boolean,_grantedList:string[]) {
console.log("用户拒绝了部分权限:")
console.log("用户拒绝了部分权限:")
let ret : GetLocationFail = {
let ret = new UniError("uni-getLocation-tencent",-30,"permission missed.");
errCode: -30,
errMsg: "permission missed.",
errSubject: "uni-getLocation-tencent"
}
options.fail?.(ret)
options.fail?.(ret)
options.complete?.(ret)
options.complete?.(ret)
})
})
...
@@ -181,11 +170,7 @@ function getLocationImpl(locationOptions : GetLocationOptions) {
...
@@ -181,11 +170,7 @@ function getLocationImpl(locationOptions : GetLocationOptions) {
if(locationOptions.type != null && locationOptions.type!.toUpperCase() != 'GCJ-02' && locationOptions.type!.toUpperCase() != 'GCJ02'){
if(locationOptions.type != null && locationOptions.type!.toUpperCase() != 'GCJ-02' && locationOptions.type!.toUpperCase() != 'GCJ02'){
// 腾讯定位只支持GCJ-02,如果不是则报错
// 腾讯定位只支持GCJ-02,如果不是则报错
let ret : GetLocationFail = {
let ret = new UniError("uni-getLocation-tencent",-1,"GCJ-02 support only.");
errCode: -1,
errMsg: "GCJ-02 support only.",
errSubject: "uni-getLocation-tencent"
}
locationOptions.fail?.(ret)
locationOptions.fail?.(ret)
locationOptions.complete?.(ret)
locationOptions.complete?.(ret)
return
return
...
...
uni_modules/uni-getLocation-tencent/utssdk/interface.uts
浏览文件 @
15db17d5
...
@@ -43,15 +43,7 @@ export type GetLocationSuccess = {
...
@@ -43,15 +43,7 @@ export type GetLocationSuccess = {
address: any | null
address: any | null
};
};
type GetLocationSuccessCallback = (result: GetLocationSuccess) => void;
type GetLocationSuccessCallback = (result: GetLocationSuccess) => void;
export type GetLocationFail = UniError;
type GetLocationFailCallback = (result: UniError) => void;
type UniError = {
errSubject: string,
errCode: number,
errMsg: string,
data: object | null,
cause: any | null
};
type GetLocationFailCallback = (result: GetLocationFail) => void;
type GetLocationComplete = any;
type GetLocationComplete = any;
type GetLocationCompleteCallback = (result: GetLocationComplete) => void;
type GetLocationCompleteCallback = (result: GetLocationComplete) => void;
export type GetLocationOptions = {
export type GetLocationOptions = {
...
...
uni_modules/uni-wifi/utssdk/app-android/index.uts
浏览文件 @
15db17d5
...
@@ -210,8 +210,8 @@ function wrapWifiConfiguration(SSID : string, password ?: string, passwordType :
...
@@ -210,8 +210,8 @@ function wrapWifiConfiguration(SSID : string, password ?: string, passwordType :
/**
/**
* 判断当前wifi的加密类型
* 判断当前wifi的加密类型
*/
*/
function getSecurityType(result : ScanResult) : string {
function getSecurityType(result : ScanResult) : string {
if (result.capabilities.contains("WEP")) {
if (result.capabilities.contains("WEP")) {
return "WEP";
return "WEP";
...
@@ -370,18 +370,21 @@ export function startWifi(option : WifiOption) {
...
@@ -370,18 +370,21 @@ export function startWifi(option : WifiOption) {
// 需要先开启wifi,才能使用后续的功能
// 需要先开启wifi,才能使用后续的功能
let requestCode = 1001;
let requestCode = 1001;
let permissionWifi = arrayOf("android.permission.ACCESS_FINE_LOCATION");
let permissionWifi = arrayOf("android.permission.ACCESS_FINE_LOCATION");
var result : UniWifiResult = {
let result : UniWifiResult = {
errCode: 12001,
errCode: 12001,
errMsg: "startWifi:premission loss",
errMsg: "startWifi:premission loss",
errSubject: "uni-startWifi"
errSubject: "uni-startWifi"
}
}
// 检查权限
// 检查权限
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, permissionWifi, requestCode.toInt())
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, permissionWifi, requestCode.toInt())
// 尚不具备权限,返回错误
// 尚不具备权限,返回错误
option.fail?.(result)
let err = new UniError("uni-startWifi",12001,"startWifi:premission loss");
option.complete?.(result)
option.fail?.(err)
option.complete?.(err)
return;
return;
}
}
...
@@ -392,11 +395,9 @@ export function startWifi(option : WifiOption) {
...
@@ -392,11 +395,9 @@ export function startWifi(option : WifiOption) {
// 用户没有开启wifi 总开关
// 用户没有开启wifi 总开关
if (!wifiManager.isWifiEnabled()) {
if (!wifiManager.isWifiEnabled()) {
// wifi 没开启
// wifi 没开启
result.errCode = 12005;
let err = new UniError("uni-startWifi",12005,"wifi not turned on");
result.errMsg = "wifi not turned on";
option.fail?.(err);
option.complete?.(err);
option.fail?.(result);
option.complete?.(result);
return;
return;
}
}
// 初始化wifi 状态广播监听,后续所有的api,均基于此
// 初始化wifi 状态广播监听,后续所有的api,均基于此
...
@@ -456,16 +457,13 @@ export function startWifi(option : WifiOption) {
...
@@ -456,16 +457,13 @@ export function startWifi(option : WifiOption) {
@Suppress("DEPRECATION")
@Suppress("DEPRECATION")
export function getWifiList(option : WifiOption) {
export function getWifiList(option : WifiOption) {
var result : UniWifiResult = {
errCode: 12000,
errMsg: "getWifiList:fail:not invoke startWifi",
errSubject: "uni-getWifiList"
}
if (Global.mReceiver == null) {
if (Global.mReceiver == null) {
// 还没调用startWifi 提示报错
// 还没调用startWifi 提示报错
option.fail?.(result)
let err = new UniError("uni-getWifiList",12000,"getWifiList:fail:not invoke startWifi");
option.complete?.(result)
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -550,11 +548,13 @@ export function offGetWifiList(callback? : UTSCallback) {
...
@@ -550,11 +548,13 @@ export function offGetWifiList(callback? : UTSCallback) {
/**
/**
* 真正执行wifi链接逻辑
* 真正执行wifi链接逻辑
*/
*/
function realWifiConnect(option : WifiConnectOption
,result : UniWifiResult
){
function realWifiConnect(option : WifiConnectOption){
if (Global.mReceiver == null || Global.scanList.length < 1) {
if (Global.mReceiver == null || Global.scanList.length < 1) {
option.fail?.(result)
option.complete?.(result)
let err = new UniError("uni-connectWifi",12000,"connectWifi:fail:not invoke startWifi");
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -569,8 +569,9 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -569,8 +569,9 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
if (scanWifiInfo == null) {
if (scanWifiInfo == null) {
// 不在扫描列表中返回错误
// 不在扫描列表中返回错误
option.fail?.(result)
let err = new UniError("uni-connectWifi",12000,"connectWifi:fail:not invoke startWifi");
option.complete?.(result)
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -596,16 +597,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -596,16 +597,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
// add since 2023-03-28,如果当前系统大于等于android10, 则明确当前系统不支持
// add since 2023-03-28,如果当前系统大于等于android10, 则明确当前系统不支持
if(Build.VERSION.SDK_INT > 28){
if(Build.VERSION.SDK_INT > 28){
// 系统大于android 9
// 系统大于android 9
result.errCode = 12001
let err = new UniError("uni-connectWifi",12001,"connectWifi:system not support");
result.errMsg = "connectWifi:system not support"
option.fail?.(err)
option.complete?.(err)
}else{
}else{
// 移除之前的配置失败了,返回错误,需要用户手动取消保存一下
// 移除之前的配置失败了,返回错误,需要用户手动取消保存一下
result.errCode = 12013
let err = new UniError("uni-connectWifi",12013,"connectWifi:wifi config may be expired");
result.errMsg = "connectWifi:wifi config may be expired"
option.fail?.(err)
option.complete?.(err)
}
}
option.fail?.(result)
option.complete?.(result)
return
return
}
}
...
@@ -626,11 +627,11 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -626,11 +627,11 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
let netID = wifiManager.addNetwork(wifiConfigration);
let netID = wifiManager.addNetwork(wifiConfigration);
// 如果-1 说明没添加上,报错即可
// 如果-1 说明没添加上,报错即可
if (netID < 0) {
if (netID < 0) {
result.errCode = 12002
result.errMsg = "connectWifi:password error Wi-Fi"
let err = new UniError("uni-connectWifi",12002,"connectWifi:password error Wi-Fi");
option.fail?.(
result
)
option.fail?.(
err
)
option.complete?.(
result
)
option.complete?.(
err
)
return
return
}
}
...
@@ -639,11 +640,10 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -639,11 +640,10 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
let enabled = wifiManager.enableNetwork(netID, true);
let enabled = wifiManager.enableNetwork(netID, true);
if (!enabled) {
if (!enabled) {
result.errCode = 12007
let err = new UniError("uni-connectWifi",12007,"connectWifi:user denied");
result.errMsg = "connectWifi:user denied"
option.fail?.(err)
option.fail?.(result)
option.complete?.(err)
option.complete?.(result)
return
return
}
}
...
@@ -657,14 +657,18 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -657,14 +657,18 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
if (!connected) {
if (!connected) {
// 出错了,返回错误
// 出错了,返回错误
// 兜底的报错
// 兜底的报错
result.errCode = 12010
let err = new UniError("uni-connectWifi",12010,"connectWifi:fail:unknown error");
result.errMsg = "connectWifi:fail:unknown error"
option.fail?.(err)
option.complete?.(err)
option.fail?.(result)
option.complete?.(result)
return
return
}
}
let result : UniWifiResult = {
errCode: 0,
errMsg: "connectWifi:ok",
errSubject: "uni-connectWifi",
}
wifiManager.saveConfiguration()
wifiManager.saveConfiguration()
//scanWifiInfo 根据 partialInfo 填充给返回字段
//scanWifiInfo 根据 partialInfo 填充给返回字段
if (option.partialInfo != null && option.partialInfo == true) {
if (option.partialInfo != null && option.partialInfo == true) {
...
@@ -676,9 +680,6 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -676,9 +680,6 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo)
result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo)
}
}
// result.wifi = scanWifiInfo.toUTSJSON(option.partialInfo)
result.errCode = 0
result.errMsg = "connectWifi:ok"
option.success?.(result)
option.success?.(result)
option.complete?.(result)
option.complete?.(result)
...
@@ -690,20 +691,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
...
@@ -690,20 +691,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
@Suppress("UNUSED_PARAMETER", "DEPRECATION")
@Suppress("UNUSED_PARAMETER", "DEPRECATION")
export function connectWifi(option : WifiConnectOption) {
export function connectWifi(option : WifiConnectOption) {
var result : UniWifiResult = {
errCode: 12000,
errMsg: "connectWifi:fail:not invoke startWifi",
errSubject: "uni-connectWifi",
}
if (option.maunal == true) {
if (option.maunal == true) {
// 指定了手动模式
// 指定了手动模式
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
UTSAndroid.getUniActivity()!.startActivity(manunalIntent);
UTSAndroid.getUniActivity()!.startActivity(manunalIntent);
result.errCode = 0
let result : UniWifiResult = {
result.errMsg = "connectWifi:ok"
errCode: 0,
errMsg: "connectWifi:ok",
errSubject: "uni-connectWifi",
}
option.success?.(result)
option.success?.(result)
option.complete?.(result)
option.complete?.(result)
...
@@ -722,7 +719,7 @@ export function connectWifi(option : WifiConnectOption) {
...
@@ -722,7 +719,7 @@ export function connectWifi(option : WifiConnectOption) {
if(taskCount >= 5 || startWifiScaning == false){
if(taskCount >= 5 || startWifiScaning == false){
// 超过10s了。或者扫描过程结束了
// 超过10s了。或者扫描过程结束了
clearInterval(taskId)
clearInterval(taskId)
realWifiConnect(option
,result
)
realWifiConnect(option)
}
}
},2000)
},2000)
...
@@ -730,7 +727,7 @@ export function connectWifi(option : WifiConnectOption) {
...
@@ -730,7 +727,7 @@ export function connectWifi(option : WifiConnectOption) {
clearInterval(taskId)
clearInterval(taskId)
});
});
}else{
}else{
realWifiConnect(option
,result
)
realWifiConnect(option)
}
}
...
@@ -744,13 +741,9 @@ export function connectWifi(option : WifiConnectOption) {
...
@@ -744,13 +741,9 @@ export function connectWifi(option : WifiConnectOption) {
export function stopWifi(option : WifiOption) {
export function stopWifi(option : WifiOption) {
// 需要先开启wifi,才能使用后续的功能
// 需要先开启wifi,才能使用后续的功能
if (Global.mReceiver == null) {
if (Global.mReceiver == null) {
var result : UniWifiResult = {
let err = new UniError("uni-stopWifi",12000,"stopWifi:not init");
errCode: 12000,
option.fail?.(err)
errSubject: "uni-stopWifi",
option.complete?.(err)
errMsg: "stopWifi:not init"
}
option.fail?.(result)
option.complete?.(result)
return
return
}
}
...
@@ -771,6 +764,7 @@ export function stopWifi(option : WifiOption) {
...
@@ -771,6 +764,7 @@ export function stopWifi(option : WifiOption) {
errSubject: "uni-stopWifi",
errSubject: "uni-stopWifi",
errMsg: "stopWifi:ok"
errMsg: "stopWifi:ok"
}
}
option.success?.(result)
option.success?.(result)
option.complete?.(result)
option.complete?.(result)
...
@@ -786,16 +780,12 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
@@ -786,16 +780,12 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
SSID: ""
SSID: ""
}
}
var res : UniWifiResult = {
errCode: 12000,
errMsg: "getConnectedWifi:fail:not invoke startWifi",
errSubject: "uni-getConnectedWifi",
}
if (Global.mReceiver == null) {
if (Global.mReceiver == null) {
// 还没调用startWifi 提示报错
// 还没调用startWifi 提示报错
option.fail?.(res)
let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:fail:not invoke startWifi");
option.complete?.(res)
option.fail?.(err)
option.complete?.(err)
return
return
}
}
...
@@ -803,14 +793,14 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
@@ -803,14 +793,14 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
// 需要先校验权限,没有位置权限无法获取wifi
// 需要先校验权限,没有位置权限无法获取wifi
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 尚不具备权限,返回错误
// 尚不具备权限,返回错误
res.errCode = 12001
let err = new UniError("uni-getConnectedWifi",12001,"getConnectedWifi:permission loss");
res.errMsg = "getConnectedWifi:permission loss"
option.fail?.(err)
option.complete?.(err)
option.fail?.(res)
option.complete?.(res)
return;
return;
}
}
const context = UTSAndroid.getAppContext();
const context = UTSAndroid.getAppContext();
if (context != null) {
if (context != null) {
const wm = context.getSystemService(
const wm = context.getSystemService(
...
@@ -821,6 +811,13 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
@@ -821,6 +811,13 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
const winfo = wm.getConnectionInfo();
const winfo = wm.getConnectionInfo();
wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo);
wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo);
let res : UniWifiResult = {
errCode: 0,
errMsg: "getConnectedWifi:ok",
errSubject: "uni-getConnectedWifi",
}
// 判断一下是否wifi 关闭了
// 判断一下是否wifi 关闭了
if (option.partialInfo!= null) {
if (option.partialInfo!= null) {
let ret : UniWifiInfo = {
let ret : UniWifiInfo = {
...
@@ -829,24 +826,22 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
@@ -829,24 +826,22 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
res.wifi = ret;
res.wifi = ret;
} else {
} else {
if (wifiInfo.BSSID == null || zeroCountNum(wifiInfo.BSSID) > 3) {
if (wifiInfo.BSSID == null || zeroCountNum(wifiInfo.BSSID) > 3) {
res.errCode = 12005
let err = new UniError("uni-getConnectedWifi",12005,"getConnectedWifi:fail:wifi is disable");
res.errMsg = "getConnectedWifi:fail:wifi is disable"
option.fail?.(err)
option.complete?.(err)
option.fail?.(res)
option.complete?.(res)
return
return
}
}
res.wifi = wifiInfo;
res.wifi = wifiInfo;
}
}
res.errCode = 0
res.errMsg = "getConnectedWifi:ok"
option.success?.(res)
option.success?.(res)
option.complete?.(res)
option.complete?.(res)
return
return
}
}
option.fail?.(res)
option.complete?.(res)
let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:fail:not invoke startWifi");
option.fail?.(err)
option.complete?.(err)
}
}
uni_modules/uni-wifi/utssdk/app-ios/index.uts
浏览文件 @
15db17d5
...
@@ -114,24 +114,14 @@ function fetchConnectedWifiWithLocationPromise(option: GetConnectedWifiOptions)
...
@@ -114,24 +114,14 @@ function fetchConnectedWifiWithLocationPromise(option: GetConnectedWifiOptions)
option.success?.(res)
option.success?.(res)
option.complete?.(res)
option.complete?.(res)
}else {
}else {
const res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12010,"getConnectedWifi:system internal error");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12010,
option.complete?.(err)
errMsg: "getConnectedWifi:system internal error",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
}else {
}else {
const res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12010,"getConnectedWifi:system internal error");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12010,
option.complete?.(err)
errMsg: "getConnectedWifi:system internal error",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
}
}
...
@@ -174,7 +164,7 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
...
@@ -174,7 +164,7 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
errCode: 0,
errCode: 0,
errMsg: "stopWifi:ok",
errMsg: "stopWifi:ok",
wifi: null
wifi: null
}
}
option.success?.(res)
option.success?.(res)
option.complete?.(res)
option.complete?.(res)
}
}
...
@@ -183,14 +173,9 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
...
@@ -183,14 +173,9 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
* 获取wifi列表, 在调用之前需要引导用户跳转到系统设置-WIFI设置页面,系统搜索周边wifi后app才能接收到回调
* 获取wifi列表, 在调用之前需要引导用户跳转到系统设置-WIFI设置页面,系统搜索周边wifi后app才能接收到回调
*/
*/
export const getWifiList: GetWifiList = function (option: WifiOption) {
export const getWifiList: GetWifiList = function (option: WifiOption) {
let res: UniWifiResult = {
let err = new UniError("uni-getWifiList",12001,"getWifiList:system not support");
errSubject: "uni-getWifiList",
option.fail?.(err)
errCode: 12001,
option.complete?.(err)
errMsg: "getWifiList:system not support",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
/* 获取wifi列表的回调
/* 获取wifi列表的回调
...
@@ -213,28 +198,18 @@ export const offGetWifiList: OffGetWifiList = function (callback: UniWifiCallbac
...
@@ -213,28 +198,18 @@ export const offGetWifiList: OffGetWifiList = function (callback: UniWifiCallbac
*/
*/
export const getConnectedWifi: GetConnectedWifi = function (option: GetConnectedWifiOptions) {
export const getConnectedWifi: GetConnectedWifi = function (option: GetConnectedWifiOptions) {
if (UniWiFiModuleGloabInfo.alreadyStartWifi == false) {
if (UniWiFiModuleGloabInfo.alreadyStartWifi == false) {
let res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:not init");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12000,
option.complete?.(err)
errMsg: "getConnectedWifi:not init",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
} else{
} else{
if (UIDevice.current.systemVersion >= "13.0") {
if (UIDevice.current.systemVersion >= "13.0") {
requestLocationPromise((success) => {
requestLocationPromise((success) => {
if (success == true) {
if (success == true) {
fetchConnectedWifiWithLocationPromise(option)
fetchConnectedWifiWithLocationPromise(option)
}else {
}else {
let res: UniWifiResult = {
let err = new UniError("uni-getConnectedWifi",12007,"getConnectedWifi:user denied");
errSubject: "uni-getConnectedWifi",
option.fail?.(err)
errCode: 12007,
option.complete?.(err)
errMsg: "getConnectedWifi:user denied",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
})
})
} else{
} else{
...
@@ -247,14 +222,10 @@ export const getConnectedWifi: GetConnectedWifi = function (option: GetConnected
...
@@ -247,14 +222,10 @@ export const getConnectedWifi: GetConnectedWifi = function (option: GetConnected
* 连接wifi
* 连接wifi
*/
*/
export const connectWifi: ConnectWifi = function (option: WifiConnectOption) {
export const connectWifi: ConnectWifi = function (option: WifiConnectOption) {
let res: UniWifiResult = {
errSubject: "uni-connectWifi",
let err = new UniError("uni-connectWifi",12001,"connectWifi:system not support");
errCode: 12001,
option.fail?.(err)
errMsg: "connectWifi:system not support",
option.complete?.(err)
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
...
@@ -290,12 +261,7 @@ export const onOffWifiConnectedWithPartialInfo: OnOffWifiConnectedWithPartialInf
...
@@ -290,12 +261,7 @@ export const onOffWifiConnectedWithPartialInfo: OnOffWifiConnectedWithPartialInf
* 设置 wifiList 中 AP 的相关信息。在 onGetWifiList 回调后调用,iOS特有接口。
* 设置 wifiList 中 AP 的相关信息。在 onGetWifiList 回调后调用,iOS特有接口。
*/
*/
export const setWifiList: SetWifiList = function (option: WifiOption) {
export const setWifiList: SetWifiList = function (option: WifiOption) {
let res: UniWifiResult = {
let err = new UniError("uni-setWifiList",12001,"setWifiList:system not support");
errSubject: "uni-setWifiList",
option.fail?.(err)
errCode: 12001,
option.complete?.(err)
errMsg: "setWifiList:system not support",
wifi: null
}
option.fail?.(res)
option.complete?.(res)
}
}
\ No newline at end of file
uni_modules/uni-wifi/utssdk/interface.uts
浏览文件 @
15db17d5
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*/
*/
export type WifiOption = {
export type WifiOption = {
success ?: (res : UniWifiResult) => void;
success ?: (res : UniWifiResult) => void;
fail ?: (res : Uni
WifiResult
) => void;
fail ?: (res : Uni
Error
) => void;
complete ?: (res :
UniWifiResult
) => void;
complete ?: (res :
any
) => void;
};
};
/**
/**
...
@@ -17,8 +17,8 @@ export type WifiConnectOption = {
...
@@ -17,8 +17,8 @@ export type WifiConnectOption = {
maunal ?: boolean;
maunal ?: boolean;
partialInfo ?: boolean; //ios不生效
partialInfo ?: boolean; //ios不生效
success ?: (res : UniWifiResult) => void;
success ?: (res : UniWifiResult) => void;
fail ?: (res : Uni
WifiResult
) => void;
fail ?: (res : Uni
Error
) => void;
complete ?: (res :
UniWifiResult
) => void;
complete ?: (res :
any
) => void;
}
}
/**
/**
...
@@ -27,8 +27,8 @@ export type WifiConnectOption = {
...
@@ -27,8 +27,8 @@ export type WifiConnectOption = {
export type GetConnectedWifiOptions = {
export type GetConnectedWifiOptions = {
partialInfo ?: boolean
partialInfo ?: boolean
success ?: (res : UniWifiResult) => void
success ?: (res : UniWifiResult) => void
fail ?: (res : Uni
WifiResult
) => void
fail ?: (res : Uni
Error
) => void
complete ?: (res :
UniWifiResult
) => void
complete ?: (res :
any
) => void
}
}
/*
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录