From 5a6e3423b969e0daaac0d739bd587a56126a7935 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Mon, 14 Nov 2022 20:04:18 +0800 Subject: [PATCH] =?UTF-8?q?connect=20wifi=20=E5=AE=9E=E7=8E=B0=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 4 ++++ uni_modules/uni-wifi/package.json | 3 ++- uni_modules/uni-wifi/utssdk/app-android/index.uts | 15 ++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index ea087bc..03c8c8a 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -13,6 +13,7 @@ + @@ -33,6 +34,9 @@ onMemoryWarning:function(res){ console.log(res); }, + testConnnectWifi(){ + uni.connectWifi({}); + }, testGetConnnectWifi(){ uni.getConnectedWifi({ partialInfo:false, diff --git a/uni_modules/uni-wifi/package.json b/uni_modules/uni-wifi/package.json index b46d512..d6b43d8 100644 --- a/uni_modules/uni-wifi/package.json +++ b/uni_modules/uni-wifi/package.json @@ -38,7 +38,8 @@ "stopWifi": "stopWifi", "getWifiList":"getWifiList", "onGetWifiList":"onGetWifiList", - "onWifiConnected":"onWifiConnected" + "onWifiConnected":"onWifiConnected", + "connectWifi":"connectWifi" } }, "dependencies": [], diff --git a/uni_modules/uni-wifi/utssdk/app-android/index.uts b/uni_modules/uni-wifi/utssdk/app-android/index.uts index e7114f9..9f96000 100644 --- a/uni_modules/uni-wifi/utssdk/app-android/index.uts +++ b/uni_modules/uni-wifi/utssdk/app-android/index.uts @@ -214,7 +214,8 @@ export function getWifiList(option: WifiOption) { // 还没调用startWifi 提示报错 var result = { errCode: 12000, - errMsg: "getWifiList:fail:not invoke startWifi" + errMsg: "getWifiList:fail:not invoke startWifi", + errSubject:"uni-wifi" } option.fail?.(result) option.complete?.(result) @@ -236,6 +237,7 @@ export function getWifiList(option: WifiOption) { } + /** * wifi 链接成功的回调注册 */ @@ -270,9 +272,15 @@ export function offGetWifiList(callback: UTSCallback) { } } -export function connectWifi(_option: WifiOption) { +export function connectWifi(_option: WifiConnectOption) { // todo console.log(_option) + if(_option.maunal == true){ + // 指定了手动模式 + let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS); + getUniActivity()!!.startActivity(manunalIntent); + } + } /** @@ -375,9 +383,6 @@ export function getConnectedWifi(option: GetConnectedWifiOptions) { return } - - - if (ActivityCompat.checkSelfPermission(getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // 尚不具备权限,返回错误 res.errCode = 12001 -- GitLab