diff --git a/.gitignore b/.gitignore
index 6901566aebd35b42051ec78860f239341e1c4bd6..f2126b3be1e90e9ea4198685c9f1c01c9f6afd61 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,10 @@
/.hbuilderx
/.vite
.DS_Store
+<<<<<<< HEAD
+=======
+>>>>>>> dev
env.js
jest.config.js
autotest.reporter.js
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 87b239c900741462ccd85877896df7d099eff9ac..744af7ffc94e5bd2b74235b4ed356636a123cc7c 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -19,7 +19,7 @@
-
+
@@ -32,7 +32,8 @@
memListener:null,
setUserCaptureScreenFlag: false,
setUserCaptureScreenText: '禁止截屏',
- permissionGranted: false
+ permissionGranted: false,
+ id:0
}
},
onLoad() {
@@ -45,24 +46,37 @@
fn:function(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() {
- const fn = res => console.log('onGetWifiList res', res)
- uni.startWifi({success(){
- uni.onGetWifiList(fn)
- uni.getWifiList({
- success() {
- console.log('getWifiList success');
- uni.offGetWifiList(fn)
- uni.stopWifi({
- success() {},
- fail(e) {
- console.log("stopWifi fail: ",e);
- }
- })
- }
- })
- }})
- },
+ console.log(" ------- onGetWifiList2_assert0: ",this.id);
+ const fn = res => console.log('onGetWifiList res', res)
+ uni.startWifi({success(){
+ uni.onGetWifiList(fn)
+ uni.getWifiList({
+ success() {
+ console.log('getWifiList success');
+ uni.offGetWifiList(fn)
+ uni.stopWifi({
+ success() {},
+ fail(e) {
+ console.log("stopWifi fail: ",e);
+ }
+ })
+ }
+ })
+ }})
+ this.id++
+ },
testConnnectWifi(){
diff --git a/uni_modules/uni-getLocation-tencent/utssdk/interface.uts b/uni_modules/uni-getLocation-tencent/utssdk/interface.uts
index 3ed7b507912373ebc6817f5f3ecd8e823391dcf4..ca1ce9300640c8510da574018aaaa6bf42feb2e8 100644
--- a/uni_modules/uni-getLocation-tencent/utssdk/interface.uts
+++ b/uni_modules/uni-getLocation-tencent/utssdk/interface.uts
@@ -4,7 +4,7 @@ export interface Uni {
*
* @tutorial http://uniapp.dcloud.io/api/location/location?id=getlocation
*/
- getLocation: GetLocation;
+ getLocation(options: GetLocationOptions) : void;
}
export type GetLocation = (options: GetLocationOptions) => void;
diff --git a/uni_modules/uni-getbatteryinfo/changelog.md b/uni_modules/uni-getbatteryinfo/changelog.md
index 1a6be2cec42ff7bfdf36e6e1d11b9579723dc135..03f2110d87b74dec98a92f48f4e18b227cff4fad 100644
--- a/uni_modules/uni-getbatteryinfo/changelog.md
+++ b/uni_modules/uni-getbatteryinfo/changelog.md
@@ -1,5 +1,12 @@
+## 1.3.1(2023-09-15)
+app端适配使用UniError
+
+## 1.3.0(2023-05-30)
+新增 同步获取电量api
+
## 1.2.0(2022-10-17)
实现百度小程序/支付宝小程序/QQ小程序获取电量
+
## 1.1.0(2022-10-17)
实现ios平台获取电量
diff --git a/uni_modules/uni-getbatteryinfo/package.json b/uni_modules/uni-getbatteryinfo/package.json
index 094b6ba10af62c8c059abc9b878820be1963484a..0fc760c92199662311d098a5213e48fd6c81c37f 100644
--- a/uni_modules/uni-getbatteryinfo/package.json
+++ b/uni_modules/uni-getbatteryinfo/package.json
@@ -1,14 +1,14 @@
{
"id": "uni-getbatteryinfo",
"displayName": "uni-getbatteryinfo",
- "version": "1.2.0",
+ "version": "1.3.1",
"description": "使用uts开发,实现在多个平台获取电池电量功能",
"keywords": [
"battery"
],
"repository": "",
"engines": {
- "HBuilderX": "^3.6.0"
+ "HBuilderX": "^3.9.0"
},
"dcloudext": {
"type": "uts",
@@ -32,7 +32,12 @@
},
"uni_modules": {
"uni-ext-api": {
- "uni": ["getBatteryInfo", "getBatteryInfoSync"]
+ "uni": {
+ "getBatteryInfo": "getBatteryInfo",
+ "getBatteryInfoSync": {
+ "web": false
+ }
+ }
},
"dependencies": [],
"encrypt": [],
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
index d7fe8aca5235bf8fc0a22638bc8c9fbd4d15ef59..060043b8662663d4b6ce54b71974de7089599503 100644
--- a/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
+++ b/uni_modules/uni-getbatteryinfo/utssdk/app-android/index.uts
@@ -1,13 +1,17 @@
import Context from "android.content.Context";
import BatteryManager from "android.os.BatteryManager";
-import { UTSAndroid } from "io.dcloud.uts";
-import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoFail, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts'
+import { GetBatteryInfo, GetBatteryInfoOptions, GetBatteryInfoSuccess, GetBatteryInfoResult,GetBatteryInfoSync } from '../interface.uts'
+import IntentFilter from 'android.content.IntentFilter';
+import Intent from 'android.content.Intent';
+
+
/**
* 异步获取电量
- * @param {Object} options
*/
-export const getBatteryInfo : GetBatteryInfo = function (options) {
+export const getBatteryInfo : GetBatteryInfo = function (options : GetBatteryInfoOptions) {
+
+
const context = UTSAndroid.getAppContext();
if (context != null) {
const manager = context.getSystemService(
@@ -15,21 +19,22 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
) as BatteryManager;
const level = manager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CAPACITY
- );
+ );
+
+ let ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ let batteryStatus = context.registerReceiver(null, ifilter);
+ let status = batteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+ let isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
+
const res : GetBatteryInfoSuccess = {
errMsg: 'getBatteryInfo:ok',
level,
- isCharging: manager.isCharging()
+ isCharging: isCharging
}
options.success?.(res)
options.complete?.(res)
} else {
- const res : GetBatteryInfoFail = {
- errSubject: "uni-getBatteryInfo",
- errCode: 1001,
- errMsg: 'getBatteryInfo:fail getAppContext is null',
- cause: null
- }
+ const res = new UniError("uni-getBatteryInfo", 1001, "getBatteryInfo:fail getAppContext is null")
options.fail?.(res)
options.complete?.(res)
}
@@ -39,31 +44,40 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
* 同步获取电量示例
*/
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
-
+
const context = UTSAndroid.getAppContext();
- if (context != null) {
+ if (context != null) {
+
+
const manager = context.getSystemService(
Context.BATTERY_SERVICE
) as BatteryManager;
const level = manager.getIntProperty(
BatteryManager.BATTERY_PROPERTY_CAPACITY
);
-
- const res : GetBatteryInfoResult = {
- level: level,
- isCharging: manager.isCharging()
- };
- return res;
- } else {
- /**
- * 无有效上下文
- */
- const res : GetBatteryInfoResult = {
- level: -1,
- isCharging: false
- };
- return res;
+
+ let ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ let batteryStatus = context.registerReceiver(null, ifilter);
+ let status = batteryStatus?.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+ let isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
+
+ const res : GetBatteryInfoResult = {
+ level: level,
+ isCharging: isCharging
+ };
+
+ return res;
+ }
+ else {
+ /**
+ * 无有效上下文
+ */
+ const res : GetBatteryInfoResult = {
+ level: -1,
+ isCharging: false
+ };
+ return res;
}
-
-
-}
\ No newline at end of file
+
+
+}
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/config.json b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..721b81e0240705a87ec0761aa9eb6f4e188769cb
--- /dev/null
+++ b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/config.json
@@ -0,0 +1,3 @@
+{
+ "deploymentTarget": "9"
+}
\ No newline at end of file
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
index 4c0362d1fabc46bb0f8a87e8cba8336dc962db4c..e33ab29913aa1586d6a6cbfd1bda3fa4438a8932 100644
--- a/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
+++ b/uni_modules/uni-getbatteryinfo/utssdk/app-ios/index.uts
@@ -2,7 +2,7 @@
import { UIDevice } from "UIKit";
import { Int } from 'Swift';
-import { GetBatteryInfo, GetBatteryInfoSuccess } from '../interface.uts';
+import { GetBatteryInfo, GetBatteryInfoSuccess, GetBatteryInfoResult, GetBatteryInfoSync } from '../interface.uts';
/**
* 导出 获取电量方法
@@ -20,8 +20,8 @@ export const getBatteryInfo : GetBatteryInfo = function (options) {
};
options.success?.(res);
options.complete?.(res);
-}
-
+}
+
export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryInfoResult {
// 开启电量检测
@@ -33,4 +33,4 @@ export const getBatteryInfoSync : GetBatteryInfoSync = function (): GetBatteryIn
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
};
return res;
-}
+}
\ No newline at end of file
diff --git a/uni_modules/uni-getbatteryinfo/index.d.ts b/uni_modules/uni-getbatteryinfo/utssdk/index.d.ts
similarity index 88%
rename from uni_modules/uni-getbatteryinfo/index.d.ts
rename to uni_modules/uni-getbatteryinfo/utssdk/index.d.ts
index 60b511f68f86e4fff522ee27ff04f3d5713a9645..9f0b83c4e53a1a27957eb4b291cf3b1fc032f7d8 100644
--- a/uni_modules/uni-getbatteryinfo/index.d.ts
+++ b/uni_modules/uni-getbatteryinfo/utssdk/index.d.ts
@@ -34,4 +34,9 @@ declare interface Uni {
* 文档: [https://uniapp.dcloud.net.cn/api/system/batteryInfo.html](https://uniapp.dcloud.net.cn/api/system/batteryInfo.html)
*/
getBatteryInfo(option?: UniNamespace.GetBatteryInfoOption): void;
+
+ /**
+ * 同步获取电池电量信息
+ */
+ getBatteryInfoSync(): UniNamespace.GetBatteryInfoSuccessCallbackResult;
}
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts
index b62d62cc6cd6eea509583fd31fafad317b532b81..d674221a16620c90639a24de95efbe59177ffa9d 100644
--- a/uni_modules/uni-getbatteryinfo/utssdk/interface.uts
+++ b/uni_modules/uni-getbatteryinfo/utssdk/interface.uts
@@ -10,24 +10,24 @@ export type GetBatteryInfoSuccess = {
isCharging : boolean
}
-export type GetBatteryInfoFail = {
- /**
- * 错误码
- */
- errCode : number,
- /**
- * 调用API的名称
- */
- errSubject : string,
- /**
- * 错误的详细信息
- */
- errMsg : string,
- /**
- * 错误来源
- */
- cause : any | null
-}
+// export type GetBatteryInfoFail = {
+// /**
+// * 错误码
+// */
+// errCode : number,
+// /**
+// * 调用API的名称
+// */
+// errSubject : string,
+// /**
+// * 错误的详细信息
+// */
+// errMsg : string,
+// /**
+// * 错误来源
+// */
+// cause : any | null
+// }
@@ -39,7 +39,7 @@ export type GetBatteryInfoOptions = {
/**
* 接口调用失败的回调函数
*/
- fail ?: (res : GetBatteryInfoFail) => void
+ fail ?: (res : UniError) => void
/**
* 接口调用成功的回调
*/
@@ -60,12 +60,12 @@ export type GetBatteryInfoResult = {
/**
* 获取电量信息
* @param {GetBatteryInfoOptions} options
-*
+*
*
* @tutorial https://uniapp.dcloud.net.cn/api/system/batteryInfo.html
* @platforms APP-IOS = ^9.0,APP-ANDROID = ^22
* @since 3.6.11
-*
+*
* @assert () => success({errCode: 0, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:ok", level: 60, isCharging: false })
* @assert () => fail({errCode: 1001, errSubject: "uni-getBatteryInfo", errMsg: "getBatteryInfo:fail getAppContext is null" })
*/
@@ -79,7 +79,7 @@ interface Uni {
/**
* 获取电池电量信息
* @description 获取电池电量信息
- * @param {GetBatteryInfoOptions} options
+ * @param {GetBatteryInfoOptions} options
* @example
* ```typescript
* uni.getBatteryInfo({
@@ -107,7 +107,7 @@ interface Uni {
* @uniVueVersion 2,3 //支持的vue版本
*
*/
- getBatteryInfo : GetBatteryInfo,
+ getBatteryInfo (options : GetBatteryInfoOptions) : void,
/**
* 同步获取电池电量信息
* @description 获取电池电量信息
@@ -134,6 +134,6 @@ interface Uni {
* @uniVueVersion 2,3 //支持的vue版本
*
*/
- getBatteryInfoSync: GetBatteryInfoSync
+ getBatteryInfoSync():GetBatteryInfoResult
-}
\ No newline at end of file
+}
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js
index 4fdced2ee3aa9d80eafdffdc5f06d522c7a1f08a..473f1a07d3f5b227f9bb1caa1099ddfd99d254da 100644
--- a/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js
+++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-alipay/index.js
@@ -1,3 +1,6 @@
export function getBatteryInfo(options) {
return my.getBatteryInfo(options)
}
+export function getBatteryInfoSync(options) {
+ return my.getBatteryInfoSync(options)
+}
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js
index 5944a774bdc27de75cbe441c1af274dfef4ab8ac..1ee373a514964b33fd47e1bd59170fb22661c0d9 100644
--- a/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js
+++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-baidu/index.js
@@ -1,3 +1,6 @@
export function getBatteryInfo(options) {
return swan.getBatteryInfo(options)
}
+export function getBatteryInfoSync(options) {
+ return swan.getBatteryInfoSync(options)
+}
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js
index 06287bc468d46e1c12f79e455a934fcbea7c52c5..6eabfcff9737dcd28de56bdb67dbb9c96287dcb8 100644
--- a/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js
+++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-qq/index.js
@@ -1,3 +1,6 @@
export function getBatteryInfo(options) {
return qq.getBatteryInfo(options)
}
+export function getBatteryInfoSync(options) {
+ return qq.getBatteryInfoSync(options)
+}
diff --git a/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js b/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js
index 5124b3de21a08a351d2d7eb631aaf96a600aa147..3bdfa9184b26d8df7a53aa9eb61c1ef37d66a8a9 100644
--- a/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js
+++ b/uni_modules/uni-getbatteryinfo/utssdk/mp-weixin/index.js
@@ -1,3 +1,6 @@
export function getBatteryInfo(options) {
return wx.getBatteryInfo(options)
}
+export function getBatteryInfoSync(options) {
+ return wx.getBatteryInfoSync(options)
+}
diff --git a/uni_modules/uni-memorywarning/package.json b/uni_modules/uni-memorywarning/package.json
index aa015a936ea73d8161f8d52e97c5bb3da080584c..9bda0f8f3a00c636c1afcc32507cf221ac38d8ea 100644
--- a/uni_modules/uni-memorywarning/package.json
+++ b/uni_modules/uni-memorywarning/package.json
@@ -5,7 +5,7 @@
"description": "UTS 实现内存警告监听",
"keywords": [
"onMemoryWarning"
-],
+ ],
"repository": "",
"engines": {
"HBuilderX": "^3.6.11"
@@ -31,18 +31,16 @@
"npmurl": ""
},
"uni_modules": {
- "uni-ext-api":{
- "uni": {
- "onMemoryWarning": "onMemoryWarning",
- "offMemoryWarning":"offMemoryWarning"
- },
- "mp-weixin":false,
- "mp-alipay":false,
- "mp-baidu":false,
- "mp-qq":false,
- "mp-kuaishou":false,
- "mp-jd":false
- },
+ "uni-ext-api": {
+ "uni": {
+ "onMemoryWarning": {
+ "web": false
+ },
+ "offMemoryWarning": {
+ "web": false
+ }
+ }
+ },
"dependencies": [],
"encrypt": [],
"platforms": {
@@ -58,10 +56,10 @@
"App": {
"app-android": {
"minVersion": "19"
- },
+ },
"app-ios": {
"minVersion": "9"
- }
+ }
},
"H5-mobile": {
"Safari": "n",
@@ -94,4 +92,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts b/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
index 46d024eaf91997461e71c7f4b61a5386e22fca4f..60ee47f5749bf69643f221b9d3ac18f7badaa9f1 100644
--- a/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
+++ b/uni_modules/uni-memorywarning/utssdk/app-ios/index.uts
@@ -46,6 +46,7 @@ class MemoryWarningTool {
}
}
+
// 开启监听内存警告
export const onMemoryWarning : OnMemoryWarning = function (callback: UTSCallback) {
MemoryWarningTool.listenMemoryWarning(callback)
diff --git a/uni_modules/uni-memorywarning/utssdk/interface.uts b/uni_modules/uni-memorywarning/utssdk/interface.uts
index dd75bf6c0314a3ed501b53401539e179b0e22326..5e11ec45b24fb0ba56d204fc2a9eab50d255b807 100644
--- a/uni_modules/uni-memorywarning/utssdk/interface.uts
+++ b/uni_modules/uni-memorywarning/utssdk/interface.uts
@@ -24,9 +24,10 @@ export interface Uni {
* }
* }
* @uniVersion 3.7.7
- * @uniVueVersion 2,3 //支持的vue版本
+ * @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- onMemoryWarning : OnMemoryWarning,
+ onMemoryWarning(callback: UTSCallback) : void,
/**
* 取消监听内存不足告警事件
*
@@ -47,7 +48,8 @@ export interface Uni {
* }
* }
* @uniVersion 3.7.7
- * @uniVueVersion 2,3 //支持的vue版本
+ * @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- offMemoryWarning : OffMemoryWarning
+ offMemoryWarning(callback : UTSCallback | null) : void
}
\ No newline at end of file
diff --git a/uni_modules/uni-usercapturescreen/package.json b/uni_modules/uni-usercapturescreen/package.json
index f1e4ca2eaedcc64ede2d0c88fc5449574a426877..6b099cfa62b02781730789c0102b698f2305ddd3 100644
--- a/uni_modules/uni-usercapturescreen/package.json
+++ b/uni_modules/uni-usercapturescreen/package.json
@@ -33,9 +33,16 @@
"uni_modules": {
"uni-ext-api":{
"uni": {
- "onUserCaptureScreen": "onUserCaptureScreen",
- "offUserCaptureScreen": "offUserCaptureScreen",
- "setUserCaptureScreen": "setUserCaptureScreen"
+ "onUserCaptureScreen": {
+ "web": false
+ },
+ "offUserCaptureScreen": {
+ "web": false
+ },
+ "setUserCaptureScreen": {
+ "web": false,
+ "mp-weixin": false
+ }
}
},
"dependencies": [],
diff --git a/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts b/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
index 99cf531e58733d6ae0c68ace8dc08e7c0d99b530..c5c1bd484d3c61dccd778f6bf0c8bad9fe06c46a 100644
--- a/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
+++ b/uni_modules/uni-usercapturescreen/utssdk/app-android/index.uts
@@ -9,6 +9,7 @@ import Environment from "android.os.Environment";
import System from 'java.lang.System';
import WindowManager from 'android.view.WindowManager';
import { OnUserCaptureScreenCallbackResult, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreenSuccess, SetUserCaptureScreenOptions, SetUserCaptureScreen } from "../interface.uts";
+import string from 'android.R.string';
/**
@@ -34,9 +35,9 @@ class ScreenFileObserver extends FileObserver {
*/
private screenFile : File;
- constructor(screenFile : File) {
- super(screenFile);
- this.screenFile = screenFile;
+ constructor(screenFileStr : string) {
+ super(screenFileStr);
+ this.screenFile = new File(screenFileStr);
}
override onEvent(event : Int, path : string | null) : void {
@@ -83,7 +84,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
}
// 先结束监听 再开启监听
observer?.stopWatching();
- observer = new ScreenFileObserver(directory_screenshot);
+ observer = new ScreenFileObserver(directory_screenshot.getPath());
observer?.startWatching();
@@ -92,7 +93,6 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
observer = null
})
-
}
/**
diff --git a/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts b/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts
index 544fb212e6caecc98a1d9a7ac34481234fe49fa2..003f572da4802a00268e8114746d34fec0b4b587 100644
--- a/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts
+++ b/uni_modules/uni-usercapturescreen/utssdk/app-ios/index.uts
@@ -3,7 +3,7 @@ import { CGRect } from "CoreFoundation";
import { UIApplication, UIView, UITextField, UIScreen, UIDevice } from "UIKit"
import { UTSiOS } from "DCloudUTSFoundation"
import { DispatchQueue } from 'Dispatch';
-import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess, SetUserCaptureScreenFail } from "../interface.uts"
+import { SetUserCaptureScreenOptions, OnUserCaptureScreenCallbackResult, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreen, UserCaptureScreenCallback, SetUserCaptureScreenSuccess } from "../interface.uts"
/**
* 定义监听截屏事件工具类
@@ -119,20 +119,12 @@ export const offUserCaptureScreen : OffUserCaptureScreen = function (callback :
*/
export const setUserCaptureScreen : SetUserCaptureScreen = function (options : SetUserCaptureScreenOptions) {
if (UIDevice.current.systemVersion < "13.0") {
- let res: SetUserCaptureScreenFail = {
- errCode: 12001,
- errSubject: "uni-usercapturescreen",
- errMsg: "setUserCaptureScreen:system not support"
- }
+ let res = new UniError("uni-usercapturescreen", 12001, "setUserCaptureScreen:system not support")
options.fail?.(res);
options.complete?.(res);
} else if (UIDevice.current.systemVersion == "15.1") {
- let res: SetUserCaptureScreenFail = {
- errCode: 12010,
- errSubject: "uni-usercapturescreen",
- errMsg: "setUserCaptureScreen:system internal error"
- }
+ let res = new UniError("uni-usercapturescreen", 12010, "setUserCaptureScreen:system internal error")
options.fail?.(res);
options.complete?.(res);
} else {
diff --git a/uni_modules/uni-usercapturescreen/utssdk/interface.uts b/uni_modules/uni-usercapturescreen/utssdk/interface.uts
index 889adb049074fea680c252bdeef372afcc2912d1..ad625eeabe1b50007ac3eff7d7f5211f105c406d 100644
--- a/uni_modules/uni-usercapturescreen/utssdk/interface.uts
+++ b/uni_modules/uni-usercapturescreen/utssdk/interface.uts
@@ -23,25 +23,6 @@ export type OffUserCaptureScreen = (callback : UserCaptureScreenCallback | null)
export type SetUserCaptureScreenSuccess = {
}
-/**
- * uni.setUserCaptureScreen失败回调参数
- */
-export type SetUserCaptureScreenFail = {
- /**
- * 错误码
- * 12001:system not support
- * 12010:system internal error
- */
- errCode : number,
- /**
- * 调用API的名称
- */
- errSubject : string,
- /**
- * 错误的详细信息
- */
- errMsg : string,
-}
/**
* uni.setUserCaptureScreen成功回调函数定义
@@ -51,7 +32,7 @@ export type SetUserCaptureScreenSuccessCallback = (res : SetUserCaptureScreenSuc
/**
* uni.setUserCaptureScreen失败回调函数定义
*/
-export type SetUserCaptureScreenFailCallback = (res : SetUserCaptureScreenFail) => void
+export type SetUserCaptureScreenFailCallback = (res : UniError) => void
/**
* uni.setUserCaptureScreen完成回调函数定义
@@ -107,9 +88,10 @@ export interface Uni {
* }
* }
* @uniVersion 3.7.7
- * @uniVueVersion 2,3 //支持的vue版本
+ * @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- onUserCaptureScreen : OnUserCaptureScreen,
+ onUserCaptureScreen(callback : UserCaptureScreenCallback | null) : void,
/**
* 关闭截屏监听
*
@@ -130,9 +112,10 @@ export interface Uni {
* }
* }
* @uniVersion 3.7.7
- * @uniVueVersion 2,3 //支持的vue版本
+ * @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- offUserCaptureScreen : OffUserCaptureScreen,
+ offUserCaptureScreen(callback : UserCaptureScreenCallback | null) : void,
/**
* 设置防截屏
*
@@ -155,5 +138,5 @@ export interface Uni {
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
*/
- setUserCaptureScreen : SetUserCaptureScreen
+ setUserCaptureScreen(options : SetUserCaptureScreenOptions) : void
}
\ No newline at end of file
diff --git a/uni_modules/uni-wifi/package.json b/uni_modules/uni-wifi/package.json
index b44e757fe040858cc150902d83ea207a4e6df987..c4a2ce639111079ab7342a30884d2435be5f9ca3 100644
--- a/uni_modules/uni-wifi/package.json
+++ b/uni_modules/uni-wifi/package.json
@@ -5,7 +5,7 @@
"description": "wifi管理",
"keywords": [
"wifi"
-],
+ ],
"repository": "",
"engines": {
"HBuilderX": "^3.6.11"
@@ -31,21 +31,43 @@
"npmurl": ""
},
"uni_modules": {
- "uni-ext-api":{
- "uni": {
- "startWifi": "startWifi",
- "stopWifi": "stopWifi",
- "connectWifi":"connectWifi",
- "getConnectedWifi": "getConnectedWifi",
- "getWifiList":"getWifiList",
- "onGetWifiList":"onGetWifiList",
- "offGetWifiList":"offGetWifiList",
- "onWifiConnected":"onWifiConnected",
- "offWifiConnected":"offWifiConnected",
- "onWifiConnectedWithPartialInfo":"onWifiConnectedWithPartialInfo",
- "offWifiConnectedWithPartialInfo":"offWifiConnectedWithPartialInfo"
- }
- },
+ "uni-ext-api": {
+ "uni": {
+ "startWifi": {
+ "web": false
+ },
+ "stopWifi": {
+ "web": false
+ },
+ "connectWifi": {
+ "web": false
+ },
+ "getConnectedWifi": {
+ "web": false
+ },
+ "getWifiList": {
+ "web": false
+ },
+ "onGetWifiList": {
+ "web": false
+ },
+ "offGetWifiList": {
+ "web": false
+ },
+ "onWifiConnected": {
+ "web": false
+ },
+ "offWifiConnected": {
+ "web": false
+ },
+ "onWifiConnectedWithPartialInfo": {
+ "web": false
+ },
+ "offWifiConnectedWithPartialInfo": {
+ "web": false
+ }
+ }
+ },
"dependencies": [],
"encrypt": [],
"platforms": {
@@ -61,10 +83,10 @@
"App": {
"app-android": {
"minVersion": "19"
- },
+ },
"app-ios": {
"minVersion": "9"
- }
+ }
},
"H5-mobile": {
"Safari": "n",
@@ -97,4 +119,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/uni_modules/uni-wifi/utssdk/app-android/config.json b/uni_modules/uni-wifi/utssdk/app-android/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..7ed4299898bcce833a4b7b6de7c4ef4d4ac999da
--- /dev/null
+++ b/uni_modules/uni-wifi/utssdk/app-android/config.json
@@ -0,0 +1,3 @@
+{
+ "minSdkVersion": "19"
+}
\ No newline at end of file
diff --git a/uni_modules/uni-wifi/utssdk/app-android/index.uts b/uni_modules/uni-wifi/utssdk/app-android/index.uts
index 6e49e9b1f78e5f36173f436b95391c2e911a928e..40312b401248242f92eb46fd6c7bd3c3030dbc06 100644
--- a/uni_modules/uni-wifi/utssdk/app-android/index.uts
+++ b/uni_modules/uni-wifi/utssdk/app-android/index.uts
@@ -210,8 +210,8 @@ function wrapWifiConfiguration(SSID : string, password ?: string, passwordType :
/**
- * 判断当前wifi的加密类型
- */
+ * 判断当前wifi的加密类型
+ */
function getSecurityType(result : ScanResult) : string {
if (result.capabilities.contains("WEP")) {
return "WEP";
@@ -306,17 +306,8 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
if (intent.action == WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) {
startWifiScaning = false;
- let ret : UniWifiResult = {
- errCode: 0,
- errSubject: "uni-getWifiList",
- errMsg: "getWifiList:ok"
- }
- if(Global.supendGetWifiSuccess != null){
- Global.supendGetWifiSuccess?.(ret)
- }
- if(Global.supendGetWifiComplete != null){
- Global.supendGetWifiComplete?.(ret)
- }
+
+
// wifi 扫描结果回调
let results = this.mWifiManager!.scanResults;
@@ -336,15 +327,27 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
const data = new JSONObject();
data["wifiList"] = Global.scanList
Global.onGetWifiListCallback?.(data);
+ /**
+ * 确保onGetWifiList 只会被执行一次
+ */
+ Global.onGetWifiListCallback = null
}
- // for (let perCallback in Global.onGetWifiListCallback) {
- // const data = new JSONObject();
- // data["wifiList"] = Global.scanList
- // perCallback(data);
- // }
}
+ let ret : UniWifiResult = {
+ errCode: 0,
+ errSubject: "uni-getWifiList",
+ errMsg: "getWifiList:ok"
+ }
+ if(Global.supendGetWifiSuccess != null){
+ Global.supendGetWifiSuccess?.(ret)
+ Global.supendGetWifiSuccess = null
+ }
+ if(Global.supendGetWifiComplete != null){
+ Global.supendGetWifiComplete?.(ret)
+ Global.supendGetWifiComplete = null
+ }
}
}
@@ -367,18 +370,21 @@ export function startWifi(option : WifiOption) {
// 需要先开启wifi,才能使用后续的功能
let requestCode = 1001;
let permissionWifi = arrayOf("android.permission.ACCESS_FINE_LOCATION");
- var result : UniWifiResult = {
+
+ let result : UniWifiResult = {
errCode: 12001,
errMsg: "startWifi:premission loss",
errSubject: "uni-startWifi"
}
+
// 检查权限
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(UTSAndroid.getUniActivity()!, permissionWifi, requestCode.toInt())
// 尚不具备权限,返回错误
- option.fail?.(result)
- option.complete?.(result)
+ let err = new UniError("uni-startWifi",12001,"startWifi:premission loss");
+ option.fail?.(err)
+ option.complete?.(err)
return;
}
@@ -389,11 +395,9 @@ export function startWifi(option : WifiOption) {
// 用户没有开启wifi 总开关
if (!wifiManager.isWifiEnabled()) {
// wifi 没开启
- result.errCode = 12005;
- result.errMsg = "wifi not turned on";
-
- option.fail?.(result);
- option.complete?.(result);
+ let err = new UniError("uni-startWifi",12005,"wifi not turned on");
+ option.fail?.(err);
+ option.complete?.(err);
return;
}
// 初始化wifi 状态广播监听,后续所有的api,均基于此
@@ -453,16 +457,13 @@ export function startWifi(option : WifiOption) {
@Suppress("DEPRECATION")
export function getWifiList(option : WifiOption) {
- var result : UniWifiResult = {
- errCode: 12000,
- errMsg: "getWifiList:fail:not invoke startWifi",
- errSubject: "uni-getWifiList"
- }
if (Global.mReceiver == null) {
// 还没调用startWifi 提示报错
- option.fail?.(result)
- option.complete?.(result)
+ let err = new UniError("uni-getWifiList",12000,"getWifiList:fail:not invoke startWifi");
+
+ option.fail?.(err)
+ option.complete?.(err)
return
}
@@ -547,11 +548,13 @@ export function offGetWifiList(callback? : UTSCallback) {
/**
* 真正执行wifi链接逻辑
*/
-function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
+function realWifiConnect(option : WifiConnectOption){
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
}
@@ -566,8 +569,9 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
if (scanWifiInfo == null) {
// 不在扫描列表中返回错误
- 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
}
@@ -593,16 +597,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
// add since 2023-03-28,如果当前系统大于等于android10, 则明确当前系统不支持
if(Build.VERSION.SDK_INT > 28){
// 系统大于android 9
- result.errCode = 12001
- result.errMsg = "connectWifi:system not support"
+ let err = new UniError("uni-connectWifi",12001,"connectWifi:system not support");
+ option.fail?.(err)
+ option.complete?.(err)
}else{
// 移除之前的配置失败了,返回错误,需要用户手动取消保存一下
- result.errCode = 12013
- result.errMsg = "connectWifi:wifi config may be expired"
+ let err = new UniError("uni-connectWifi",12013,"connectWifi:wifi config may be expired");
+ option.fail?.(err)
+ option.complete?.(err)
}
- option.fail?.(result)
- option.complete?.(result)
return
}
@@ -623,11 +627,11 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
let netID = wifiManager.addNetwork(wifiConfigration);
// 如果-1 说明没添加上,报错即可
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.complete?.(result)
+ option.fail?.(err)
+ option.complete?.(err)
return
}
@@ -636,11 +640,10 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
let enabled = wifiManager.enableNetwork(netID, true);
if (!enabled) {
- result.errCode = 12007
- result.errMsg = "connectWifi:user denied"
-
- option.fail?.(result)
- option.complete?.(result)
+ let err = new UniError("uni-connectWifi",12007,"connectWifi:user denied");
+
+ option.fail?.(err)
+ option.complete?.(err)
return
}
@@ -654,14 +657,18 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
if (!connected) {
// 出错了,返回错误
// 兜底的报错
- result.errCode = 12010
- result.errMsg = "connectWifi:fail:unknown error"
-
- option.fail?.(result)
- option.complete?.(result)
+ let err = new UniError("uni-connectWifi",12010,"connectWifi:fail:unknown error");
+ option.fail?.(err)
+ option.complete?.(err)
return
}
+ let result : UniWifiResult = {
+ errCode: 0,
+ errMsg: "connectWifi:ok",
+ errSubject: "uni-connectWifi",
+ }
+
wifiManager.saveConfiguration()
//scanWifiInfo 根据 partialInfo 填充给返回字段
if (option.partialInfo != null && option.partialInfo == true) {
@@ -673,9 +680,6 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo)
}
- // result.wifi = scanWifiInfo.toUTSJSON(option.partialInfo)
- result.errCode = 0
- result.errMsg = "connectWifi:ok"
option.success?.(result)
option.complete?.(result)
@@ -687,20 +691,16 @@ function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
@Suppress("UNUSED_PARAMETER", "DEPRECATION")
export function connectWifi(option : WifiConnectOption) {
-
- var result : UniWifiResult = {
- errCode: 12000,
- errMsg: "connectWifi:fail:not invoke startWifi",
- errSubject: "uni-connectWifi",
- }
-
if (option.maunal == true) {
// 指定了手动模式
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
UTSAndroid.getUniActivity()!.startActivity(manunalIntent);
- result.errCode = 0
- result.errMsg = "connectWifi:ok"
+ let result : UniWifiResult = {
+ errCode: 0,
+ errMsg: "connectWifi:ok",
+ errSubject: "uni-connectWifi",
+ }
option.success?.(result)
option.complete?.(result)
@@ -719,7 +719,7 @@ export function connectWifi(option : WifiConnectOption) {
if(taskCount >= 5 || startWifiScaning == false){
// 超过10s了。或者扫描过程结束了
clearInterval(taskId)
- realWifiConnect(option,result)
+ realWifiConnect(option)
}
},2000)
@@ -727,7 +727,7 @@ export function connectWifi(option : WifiConnectOption) {
clearInterval(taskId)
});
}else{
- realWifiConnect(option,result)
+ realWifiConnect(option)
}
@@ -741,13 +741,9 @@ export function connectWifi(option : WifiConnectOption) {
export function stopWifi(option : WifiOption) {
// 需要先开启wifi,才能使用后续的功能
if (Global.mReceiver == null) {
- var result : UniWifiResult = {
- errCode: 12000,
- errSubject: "uni-stopWifi",
- errMsg: "stopWifi:not init"
- }
- option.fail?.(result)
- option.complete?.(result)
+ let err = new UniError("uni-stopWifi",12000,"stopWifi:not init");
+ option.fail?.(err)
+ option.complete?.(err)
return
}
@@ -768,6 +764,7 @@ export function stopWifi(option : WifiOption) {
errSubject: "uni-stopWifi",
errMsg: "stopWifi:ok"
}
+
option.success?.(result)
option.complete?.(result)
@@ -783,16 +780,12 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
SSID: ""
}
- var res : UniWifiResult = {
- errCode: 12000,
- errMsg: "getConnectedWifi:fail:not invoke startWifi",
- errSubject: "uni-getConnectedWifi",
- }
-
+
if (Global.mReceiver == null) {
// 还没调用startWifi 提示报错
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:fail:not invoke startWifi");
+ option.fail?.(err)
+ option.complete?.(err)
return
}
@@ -800,14 +793,14 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
// 需要先校验权限,没有位置权限无法获取wifi
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 尚不具备权限,返回错误
- res.errCode = 12001
- res.errMsg = "getConnectedWifi:permission loss"
-
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getConnectedWifi",12001,"getConnectedWifi:permission loss");
+ option.fail?.(err)
+ option.complete?.(err)
return;
}
+
+
const context = UTSAndroid.getAppContext();
if (context != null) {
const wm = context.getSystemService(
@@ -818,31 +811,37 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
const winfo = wm.getConnectionInfo();
wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo);
+
+ let res : UniWifiResult = {
+ errCode: 0,
+ errMsg: "getConnectedWifi:ok",
+ errSubject: "uni-getConnectedWifi",
+ }
+
// 判断一下是否wifi 关闭了
- if (option.partialInfo != null && option.partialInfo == true) {
+ if (option.partialInfo!= null) {
let ret : UniWifiInfo = {
SSID: wifiInfo.SSID
}
res.wifi = ret;
} else {
if (wifiInfo.BSSID == null || zeroCountNum(wifiInfo.BSSID) > 3) {
- res.errCode = 12005
- res.errMsg = "getConnectedWifi:fail:wifi is disable"
-
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getConnectedWifi",12005,"getConnectedWifi:fail:wifi is disable");
+ option.fail?.(err)
+ option.complete?.(err)
return
}
res.wifi = wifiInfo;
}
- res.errCode = 0
- res.errMsg = "getConnectedWifi:ok"
option.success?.(res)
option.complete?.(res)
return
}
- option.fail?.(res)
- option.complete?.(res)
-}
\ No newline at end of file
+
+ let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:fail:not invoke startWifi");
+ option.fail?.(err)
+ option.complete?.(err)
+}
+
diff --git a/uni_modules/uni-wifi/utssdk/app-ios/index.uts b/uni_modules/uni-wifi/utssdk/app-ios/index.uts
index b1e94f3ea97acd22a10b6e23bd417a007c54c579..a2ccfe4e1427ea14500bc41a2a1c0b0b1502e9be 100644
--- a/uni_modules/uni-wifi/utssdk/app-ios/index.uts
+++ b/uni_modules/uni-wifi/utssdk/app-ios/index.uts
@@ -114,24 +114,14 @@ function fetchConnectedWifiWithLocationPromise(option: GetConnectedWifiOptions)
option.success?.(res)
option.complete?.(res)
}else {
- const res: UniWifiResult = {
- errSubject: "uni-getConnectedWifi",
- errCode: 12010,
- errMsg: "getConnectedWifi:system internal error",
- wifi: null
- }
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getConnectedWifi",12010,"getConnectedWifi:system internal error");
+ option.fail?.(err)
+ option.complete?.(err)
}
}else {
- const res: UniWifiResult = {
- errSubject: "uni-getConnectedWifi",
- errCode: 12010,
- errMsg: "getConnectedWifi:system internal error",
- wifi: null
- }
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getConnectedWifi",12010,"getConnectedWifi:system internal error");
+ option.fail?.(err)
+ option.complete?.(err)
}
}
@@ -174,7 +164,7 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
errCode: 0,
errMsg: "stopWifi:ok",
wifi: null
- }
+ }
option.success?.(res)
option.complete?.(res)
}
@@ -183,14 +173,9 @@ export const stopWifi: StopWifi = function (option: WifiOption) {
* 获取wifi列表, 在调用之前需要引导用户跳转到系统设置-WIFI设置页面,系统搜索周边wifi后app才能接收到回调
*/
export const getWifiList: GetWifiList = function (option: WifiOption) {
- let res: UniWifiResult = {
- errSubject: "uni-getWifiList",
- errCode: 12001,
- errMsg: "getWifiList:system not support",
- wifi: null
- }
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getWifiList",12001,"getWifiList:system not support");
+ option.fail?.(err)
+ option.complete?.(err)
}
/* 获取wifi列表的回调
@@ -213,28 +198,18 @@ export const offGetWifiList: OffGetWifiList = function (callback: UniWifiCallbac
*/
export const getConnectedWifi: GetConnectedWifi = function (option: GetConnectedWifiOptions) {
if (UniWiFiModuleGloabInfo.alreadyStartWifi == false) {
- let res: UniWifiResult = {
- errSubject: "uni-getConnectedWifi",
- errCode: 12000,
- errMsg: "getConnectedWifi:not init",
- wifi: null
- }
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getConnectedWifi",12000,"getConnectedWifi:not init");
+ option.fail?.(err)
+ option.complete?.(err)
} else{
if (UIDevice.current.systemVersion >= "13.0") {
requestLocationPromise((success) => {
if (success == true) {
fetchConnectedWifiWithLocationPromise(option)
}else {
- let res: UniWifiResult = {
- errSubject: "uni-getConnectedWifi",
- errCode: 12007,
- errMsg: "getConnectedWifi:user denied",
- wifi: null
- }
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-getConnectedWifi",12007,"getConnectedWifi:user denied");
+ option.fail?.(err)
+ option.complete?.(err)
}
})
} else{
@@ -247,14 +222,10 @@ export const getConnectedWifi: GetConnectedWifi = function (option: GetConnected
* 连接wifi
*/
export const connectWifi: ConnectWifi = function (option: WifiConnectOption) {
- let res: UniWifiResult = {
- errSubject: "uni-connectWifi",
- errCode: 12001,
- errMsg: "connectWifi:system not support",
- wifi: null
- }
- option.fail?.(res)
- option.complete?.(res)
+
+ let err = new UniError("uni-connectWifi",12001,"connectWifi:system not support");
+ option.fail?.(err)
+ option.complete?.(err)
}
@@ -290,12 +261,7 @@ export const onOffWifiConnectedWithPartialInfo: OnOffWifiConnectedWithPartialInf
* 设置 wifiList 中 AP 的相关信息。在 onGetWifiList 回调后调用,iOS特有接口。
*/
export const setWifiList: SetWifiList = function (option: WifiOption) {
- let res: UniWifiResult = {
- errSubject: "uni-setWifiList",
- errCode: 12001,
- errMsg: "setWifiList:system not support",
- wifi: null
- }
- option.fail?.(res)
- option.complete?.(res)
+ let err = new UniError("uni-setWifiList",12001,"setWifiList:system not support");
+ option.fail?.(err)
+ option.complete?.(err)
}
\ No newline at end of file
diff --git a/uni_modules/uni-wifi/utssdk/interface.uts b/uni_modules/uni-wifi/utssdk/interface.uts
index 45f92790a6761f9443a0bc72f23849b92b1cedb1..14cdbf0f704f04044bc195e35a9efb2af80e62bb 100644
--- a/uni_modules/uni-wifi/utssdk/interface.uts
+++ b/uni_modules/uni-wifi/utssdk/interface.uts
@@ -1,45 +1,45 @@
/**
* Wifi 函数通用入参封装
*/
- export type WifiOption = {
- success?: (res: UniWifiResult) => void;
- fail?: (res: UniWifiResult) => void;
- complete?: (res: UniWifiResult) => void;
+export type WifiOption = {
+ success ?: (res : UniWifiResult) => void;
+ fail ?: (res : UniError) => void;
+ complete ?: (res : any) => void;
};
/**
* Wifi 链接参数封装
*/
export type WifiConnectOption = {
- SSID?: string;
- BSSID?: string;
- password?: string;
- maunal?: boolean;
- partialInfo?: boolean; //ios不生效
- success?: (res: UniWifiResult) => void;
- fail?: (res: UniWifiResult) => void;
- complete?: (res: UniWifiResult) => void;
+ SSID ?: string;
+ BSSID ?: string;
+ password ?: string;
+ maunal ?: boolean;
+ partialInfo ?: boolean; //ios不生效
+ success ?: (res : UniWifiResult) => void;
+ fail ?: (res : UniError) => void;
+ complete ?: (res : any) => void;
}
/**
* 获取当前链接的wifi信息
*/
export type GetConnectedWifiOptions = {
- partialInfo?: boolean
- success?: (res: UniWifiResult) => void
- fail?: (res: UniWifiResult) => void
- complete?: (res: UniWifiResult) => void
+ partialInfo ?: boolean
+ success ?: (res : UniWifiResult) => void
+ fail ?: (res : UniError) => void
+ complete ?: (res : any) => void
}
/*
* 对外暴露的wifi信息
*/
export type UniWifiInfo = {
- SSID: string;
- BSSID?: string;
- secure?: boolean;
- signalStrength?: number;
- frequency?: number;
+ SSID : string;
+ BSSID ?: string;
+ secure ?: boolean;
+ signalStrength ?: number;
+ frequency ?: number;
}
@@ -47,35 +47,35 @@ export type UniWifiResult = {
errCode : number,
errSubject : string,
errMsg : string,
- wifi: UniWifiInfo | null
+ wifi : UniWifiInfo | null
}
export type UniWifiCallback = () => void
-export type StartWifi = (option: WifiOption) => void
+export type StartWifi = (option : WifiOption) => void
-export type StopWifi = (option: WifiOption) => void
+export type StopWifi = (option : WifiOption) => void
-export type GetWifiList = (option: WifiOption) => void
+export type GetWifiList = (option : WifiOption) => void
-export type OnGetWifiList = (callback: UniWifiCallback) => void
+export type OnGetWifiList = (callback : UniWifiCallback) => void
-export type OffGetWifiList = (callback: UniWifiCallback) => void
+export type OffGetWifiList = (callback : UniWifiCallback) => void
-export type GetConnectedWifi = (option: GetConnectedWifiOptions) => void
+export type GetConnectedWifi = (option : GetConnectedWifiOptions) => void
-export type ConnectWifi = (option: WifiConnectOption) => void
+export type ConnectWifi = (option : WifiConnectOption) => void
-export type OnWifiConnected = (callback: UniWifiCallback) => void
+export type OnWifiConnected = (callback : UniWifiCallback) => void
-export type OnWifiConnectedWithPartialInfo = (callback: UniWifiCallback) => void
+export type OnWifiConnectedWithPartialInfo = (callback : UniWifiCallback) => void
-export type OffWifiConnected = (callback: UniWifiCallback | null) => void
+export type OffWifiConnected = (callback : UniWifiCallback | null) => void
-export type OnOffWifiConnectedWithPartialInfo = (callback: UniWifiCallback | null) => void
+export type OnOffWifiConnectedWithPartialInfo = (callback : UniWifiCallback | null) => void
-export type SetWifiList = (option: WifiOption) => void
+export type SetWifiList = (option : WifiOption) => void
interface Uni {
/**
@@ -99,8 +99,9 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { after: 'stopWifi' }
*/
- startWifi : StartWifi,
+ startWifi(option : WifiOption): void,
/**
* 关闭 Wi-Fi 模块
*
@@ -122,15 +123,16 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { before: 'startWifi' }
*/
- stopWifi : StopWifi,
+ stopWifi(option : WifiOption) : void,
/**
* @param {WifiConnectOption} option
* @tutorial https://uniapp.dcloud.net.cn/api/system/wifi.html#connectWifi
* @uniPlatform {
* "app": {
* "android": {
- * "osVer": "4.4.4",
+ * "osVer": ">=4.4 && <10.0",
* "uniVer": "3.7.0",
* "unixVer": "3.9.0"
* },
@@ -163,7 +165,7 @@ interface Uni {
]
}
*/
- connectWifi : ConnectWifi,
+ connectWifi(option : WifiConnectOption) : void,
/**
* 请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。
* @param {WifiOption} option
@@ -184,17 +186,9 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
- * @autotest {
- generated: false,
- cases:[
- {
- before: 'startWifi',
- after: 'stopWifi'
- }
- ]
- }
+ * @autotest { before: 'startWifi', after: 'stopWifi' }
*/
- getWifiList : GetWifiList,
+ getWifiList(option : WifiOption) : void,
/**
* 监听获取到 Wi-Fi 列表数据事件。
*
@@ -216,8 +210,25 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
+ * @autotest {
+ generated: false,
+ pollution: false,
+ expectCallback: true,
+ before: 'startWifi',
+ after: 'onGetWifiListAfter',
+ cases: [
+ {
+ output: {
+ value: 0,
+ returnKey: '.wifiList.length',
+ jestExpectSyntax: 'toBeGreaterThan'
+ },
+ }
+ ]
+ }
*/
- onGetWifiList : OnGetWifiList,
+ onGetWifiList(callback : UniWifiCallback) : void,
/**
* 移除获取到 Wi-Fi 列表数据事件的监听函数。
*
@@ -239,8 +250,9 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- offGetWifiList : OffGetWifiList,
+ offGetWifiList(callback : UniWifiCallback) : void,
/**
* 获取已连接的 Wi-Fi 信息
*
@@ -262,8 +274,9 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { before: 'startWifi', after: 'stopWifi' }
*/
- getConnectedWifi : GetConnectedWifi,
+ getConnectedWifi(option : GetConnectedWifiOptions) : void,
/**
* 监听连接上 Wi-Fi 的事件
*
@@ -285,8 +298,9 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- onWifiConnected : OnWifiConnected,
+ onWifiConnected(callback : UniWifiCallback) : void,
/**
* 监听连接上 Wi-Fi 的事件。
*
@@ -308,8 +322,9 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- onWifiConnectedWithPartialInfo : OnWifiConnectedWithPartialInfo,
+ onWifiConnectedWithPartialInfo(callback : UniWifiCallback) : void,
/**
* 移除连接上 Wi-Fi 的事件的监听函数。
*
@@ -331,8 +346,9 @@ interface Uni {
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- offWifiConnected : OffWifiConnected,
+ offWifiConnected(callback : UniWifiCallback | null) : void,
/**
* 移除连接上 Wi-Fi 的事件的监听函数。
*
@@ -341,20 +357,39 @@ interface Uni {
* @uniPlatform {
* "app": {
* "android": {
- * "osVer": "4.4.4",
- * "uniVer": "3.7.0",
- * "unixVer": "3.9.0"
+ * "osVer": "x",
+ * "uniVer": "x",
+ * "unixVer": "x"
* },
* "ios": {
- * "osVer": "9.0",
- * "uniVer": "3.7.7",
- * "unixVer": "3.9.0"
+ * "osVer": "x",
+ * "uniVer": "x",
+ * "unixVer": "x"
* }
* }
* }
* @uniVersion 3.7.7
* @uniVueVersion 2,3 //支持的vue版本
+ * @autotest { expectCallback: true }
*/
- onOffWifiConnectedWithPartialInfo : OnOffWifiConnectedWithPartialInfo,
- setWifiList : SetWifiList,
-}
+ onOffWifiConnectedWithPartialInfo(callback : UniWifiCallback | null) : void,
+ /**
+ * SetWifiList 暂未实现
+ *
+ * @uniPlatform {
+ * "app": {
+ * "android": {
+ * "osVer": "x",
+ * "uniVer": "x",
+ * "unixVer": "x"
+ * },
+ * "ios": {
+ * "osVer": "x",
+ * "uniVer": "x",
+ * "unixVer": "x"
+ * }
+ * }
+ * }
+ */
+ setWifiList(option : WifiOption) : void,
+}
\ No newline at end of file
diff --git a/uni_modules/uni-wifi/utssdk/uni.autotest.js b/uni_modules/uni-wifi/utssdk/uni.autotest.js
new file mode 100644
index 0000000000000000000000000000000000000000..7f0ac09aca2495568be791c7c702e84a986e48e9
--- /dev/null
+++ b/uni_modules/uni-wifi/utssdk/uni.autotest.js
@@ -0,0 +1,35 @@
+export function startWifi() {
+ return new Promise((resolve, reject) => {
+ uni.startWifi({
+ success: () => {
+ console.log('startWifi success');
+ resolve()
+ },
+ complete: () => {
+ console.log('startWifi fail');
+ resolve()
+ }
+ })
+ })
+}
+
+export function stopWifi() {
+ return new Promise((resolve, reject) => {
+ uni.stopWifi({
+ complete: resolve
+ })
+ })
+}
+
+export function onGetWifiListAfter() {
+ return new Promise((resolve, reject) => {
+ uni.getWifiList({
+ success() {
+ setTimeout(resolve, 500)
+ },
+ complete() {
+ stopWifi().finally(resolve)
+ }
+ })
+ })
+}
\ No newline at end of file