Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
12c6e1c2
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看板
提交
12c6e1c2
编写于
11月 12, 2022
作者:
打打卡夫卡
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复部分告警信息
上级
2f2476d5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
54 addition
and
53 deletion
+54
-53
pages/index/index.vue
pages/index/index.vue
+2
-2
uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
...odules/uni-usercapturescreen/utssdk/app-android/index.uts
+2
-1
uni_modules/uni-wifi/utssdk/app-android/index.uts
uni_modules/uni-wifi/utssdk/app-android/index.uts
+50
-50
未找到文件。
pages/index/index.vue
浏览文件 @
12c6e1c2
...
...
@@ -9,11 +9,11 @@
<button
@
tap=
"testGetBatteryInfo"
>
获取电池电量
</button>
<button
@
tap=
"testonMemoryWarning"
>
开启内存不足告警监听
</button>
<button
@
tap=
"testoffMemoryWarning"
>
关闭内存不足告警监听
</button>
<button
@
tap=
"testStartWifi"
>
startWifi
</button>
<button
@
tap=
"testStartWifi"
>
初始化wifi模块
</button>
<button
@
tap=
"testGetWifiList"
>
获取当前wifi列表
</button>
<button
@
tap=
"testGetConnnectWifi"
>
获取当前连接的wifi
</button>
<button
@
tap=
"testStopWifi"
>
stopWifi
</button>
<button
@
tap=
"testStopWifi"
>
关闭wifi模块
</button>
</view>
</
template
>
...
...
uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
浏览文件 @
12c6e1c2
...
...
@@ -45,8 +45,9 @@ class ScreenFileObserver extends FileObserver {
constructor(screenFile: string) {
super(
screenFile
)
super(
File(allScreen)
)
this.allScreen = new File(screenFile);
}
...
...
uni_modules/uni-wifi/utssdk/app-android/index.uts
浏览文件 @
12c6e1c2
...
...
@@ -59,7 +59,7 @@ class UniWifiInfo {
// 是否安全,微信的标准是是否需要密码。 来源:https://developers.weixin.qq.com/community/develop/doc/00064cf1790458db19cddf9925ac00?highLine=WifiInfo
this.secure = false;
let capabilities = scanResult.capabilities.trim();
if (
capabilities != null &&
(capabilities.equals(Global.WIFI_AUTH_OPEN) || capabilities.equals(Global.WIFI_AUTH_ROAM))) {
if ((capabilities.equals(Global.WIFI_AUTH_OPEN) || capabilities.equals(Global.WIFI_AUTH_ROAM))) {
this.secure = false;
} else {
this.secure = true;
...
...
@@ -76,22 +76,20 @@ class UniWifiInfo {
if (connectInfo.getBSSID() == null) {
return
}
if (connectInfo != null) {
if (connectInfo.getSSID() != null) {
let s = connectInfo.getSSID();
// 微信不带,这里需要去掉引号
if (s.length > 2 && s.charAt(0) == '"' && s.charAt(s.length - 1) == '"') {
s = s.substring(1, s.length - 1);
}
this.SSID = s;
if (connectInfo.getSSID() != null) {
let s = connectInfo.getSSID();
// 微信不带,这里需要去掉引号
if (s.length > 2 && s.charAt(0) == '"' && s.charAt(s.length - 1) == '"') {
s = s.substring(1, s.length - 1);
}
this.SSID = s;
}
this.BSSID = connectInfo.getBSSID();
//Android返回的值是-100~0,而微信API规范是0~100,值越大信号越好,需要+100拉齐
this.signalStrength = connectInfo.getRssi() + 100;
this.frequency = connectInfo.getFrequency();
this.BSSID = connectInfo.getBSSID();
//Android返回的值是-100~0,而微信API规范是0~100,值越大信号越好,需要+100拉齐
this.signalStrength = connectInfo.getRssi() + 100;
this.frequency = connectInfo.getFrequency();
}
}
...
...
@@ -147,10 +145,11 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
setTimeout(function() {
// BroadcastReceiver 中不能执行耗时任务,需要使用setTimeout
console.log(Thread.currentThread().getName())
// @ts-ignore
let winfo = this.mWifiManager!.getConnectionInfo();
while (winfo.bssid == null) {
Thread.sleep(1000)
winfo = this.mWifiManager!
!
.getConnectionInfo();
winfo = this.mWifiManager!.getConnectionInfo();
}
// 封装成数据对象
...
...
@@ -160,7 +159,6 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
errCode: 0,
wifi: uniWifiInfo
}
console.log("Global.onWifiConnectCallbackList == " + Global.onWifiConnectCallbackList.length);
// wifi状态可用了,分发当前的链接状态给已注册的监听集合
for (let perCallback in Global.onWifiConnectCallbackList) {
perCallback(res);
...
...
@@ -216,7 +214,7 @@ export function getWifiList(option: WifiOption) {
// 还没调用startWifi 提示报错
var result = {
errCode: 12000,
errMsg: "getWifiList:fail
fail:not init,you shall call startWifi first
"
errMsg: "getWifiList:fail
:not invoke startWifi
"
}
option.fail?.(result)
option.complete?.(result)
...
...
@@ -232,8 +230,8 @@ export function getWifiList(option: WifiOption) {
errCode: 0,
errMsg: "getWifiList:ok"
}
option
?
.success?.(ret)
option
?
.complete?.(ret)
option.success?.(ret)
option.complete?.(ret)
}
...
...
@@ -272,8 +270,9 @@ export function offGetWifiList(callback: UTSCallback) {
}
}
export function connectWifi(option: WifiOption) {
export function connectWifi(_option: WifiOption) {
// todo
console.log(_option)
}
/**
...
...
@@ -281,20 +280,20 @@ export function connectWifi(option: WifiOption) {
*/
export function startWifi(option: WifiOption) {
// 需要先开启wifi,才能使用后续的功能
let requestCode = 1001;
let permissionWifi = arrayOf("android.permission.ACCESS_FINE_LOCATION");
var result = {
errCode: 12001,
errMsg: "startWifi:premission loss"
}
// 检查权限
if (ActivityCompat.checkSelfPermission(getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getUniActivity()!, permissionWifi, requestCode)
// 尚不具备权限,返回错误
var result = {
errNo: 0,
errCode: 0,
errMsg: "startWifi:premission loss"
}
option.fail?.(result)
option.complete?.(result)
...
...
@@ -311,16 +310,16 @@ export function startWifi(option: WifiOption) {
let filter = new IntentFilter()
filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)
// @ts-ignore
filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION)
// @ts-ignore
filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
getUniActivity()!.registerReceiver(Global.mReceiver, filter)
wifiManager.startScan()
var result = {
errNo: 0,
errCode: 0,
errMsg: "startWifi:ok"
}
result.errCode = 0
result.errMsg = "startWifi:ok"
option.success?.(result)
option.complete?.(result)
...
...
@@ -360,30 +359,30 @@ export function stopWifi(option: WifiOption) {
*/
export function getConnectedWifi(option: GetConnectedWifiOptions) {
let wifiInfo = new UniWifiInfo(null)
var res = {
errCode: 12000,
errMsg: "getConnectedWifi:fail:not invoke startWifi",
wifi:wifiInfo
}
if (Global.mReceiver == null) {
var result = {
errNo: 12000,
errCode: 12000,
errMsg: "startWifi:not init"
}
option.fail?.(result)
option.complete?.(result)
// 还没调用startWifi 提示报错
option.fail?.(res)
option.complete?.(res)
return
}
let WifiInfo = new UniWifiInfo(null)
let res = {
errMsg: 'getConnectedWifi:fail. please check permission about location or enable wifi or connect wifi',
errCode: -1,
wifi: WifiInfo
}
if (ActivityCompat.checkSelfPermission(getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 尚不具备权限,返回错误
res.errCode = 12001
res.errMsg = "getConnectedWifi:permission loss"
option.fail?.(res)
option.complete?.(res)
return;
...
...
@@ -397,13 +396,14 @@ export function getConnectedWifi(option: GetConnectedWifiOptions) {
Context.WIFI_SERVICE
) as WifiManager;
// 测试android 12上可以使用
//@ts-ignore
const winfo = wm.getConnectionInfo();
// 封装成数据对象
W
ifiInfo.wrapConnectInfo(winfo);
w
ifiInfo.wrapConnectInfo(winfo);
res.errCode = 0
res.errMsg = "getConnectedWifi:ok"
res.wifi =
W
ifiInfo;
res.wifi =
w
ifiInfo;
option.success?.(res)
option.complete?.(res)
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录