diff --git a/common/include/dialog_ui/js/BUILD.gn b/common/include/dialog_ui/js/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a1e858a5032ef0e978dea6bc65daa8d1850d4dd3 --- /dev/null +++ b/common/include/dialog_ui/js/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni") + +gen_sa_dialog_js("dialog_js_files_etc") { + project_path = "//foundation/distributedhardware/devicemanager/common/include/dialog_ui/js" + dialog_name = "config_dialog_service" + part_name = "device_manager_base" + subsystem_name = "distributedhardware" +} \ No newline at end of file diff --git a/common/include/dialog_ui/js/common/pincode.png b/common/include/dialog_ui/js/common/pincode.png new file mode 100644 index 0000000000000000000000000000000000000000..6616f7659fcf1d5da5ab6796863e32efbe086cdc Binary files /dev/null and b/common/include/dialog_ui/js/common/pincode.png differ diff --git a/common/include/dialog_ui/js/i18n/en-US.json b/common/include/dialog_ui/js/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..0714fc75f8420ac089a6ee1c24c8f2d8472ff511 --- /dev/null +++ b/common/include/dialog_ui/js/i18n/en-US.json @@ -0,0 +1,5 @@ +{ + "message":{ + "hello": "hello world" + } +} \ No newline at end of file diff --git a/common/include/dialog_ui/js/i18n/zh-CN.json b/common/include/dialog_ui/js/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..53afe2047da6ff0423e5eae8d9f9af9f73d85d0b --- /dev/null +++ b/common/include/dialog_ui/js/i18n/zh-CN.json @@ -0,0 +1,5 @@ +{ + "message": { + "hello": "你好世界" + } +} \ No newline at end of file diff --git a/common/include/dialog_ui/js/pages/index/index.css b/common/include/dialog_ui/js/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..d05cc469647ec6c7ff535a4f69cda0a2ff6765ba --- /dev/null +++ b/common/include/dialog_ui/js/pages/index/index.css @@ -0,0 +1,35 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + opacity: 0.8; + background-color: azure; +} + +.title { + font-size: 48px; + line-height: 70px; + font-weight: 800; +} + +.but { + margin: 10px 20px 10px 20px; +} + +.but1 { + width: 160px; + font-size: 26px; + height: 36px; +} + +.but2 { + width: 160px; + font-size: 26px; + height: 36px; +} + +.title-list { + font-size: 38px; + line-height: 40px; + font-weight: 800; +} diff --git a/common/include/dialog_ui/js/pages/index/index.hml b/common/include/dialog_ui/js/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..1ec849137ae94213c823575ffd172610ee3c45a6 --- /dev/null +++ b/common/include/dialog_ui/js/pages/index/index.hml @@ -0,0 +1,16 @@ +
+ + 是否允许{{ message }}连接本机 + + + 用于分享图片 + +
+ + +
+
diff --git a/common/include/dialog_ui/js/pages/index/index.js b/common/include/dialog_ui/js/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..85c42a6e66d7319f15ca304b73bacae1b9fa928b --- /dev/null +++ b/common/include/dialog_ui/js/pages/index/index.js @@ -0,0 +1,29 @@ +import router from '@ohos.router' + +var times = 60; +export default { + data: { + message: router.getParams().targetPkgName, + }, + onInit() { + console.info('getParams: ' + router.getParams()); + this.timeRemaining = times; + const next = () => { + --this.timeRemaining; + if (this.timeRemaining > 0) { + setTimeout(next, 1000) + } else { + onCancel(); + } + } + next() + }, + onConfirm() { + console.info('click confirm'); + callNativeHandler("EVENT_CONFIRM", "0"); + }, + onCancel() { + console.info('click cancel'); + callNativeHandler("EVENT_CANCEL", "1"); + } +} \ No newline at end of file diff --git a/ext/input_pin_dialog/dialog_ui/js/BUILD.gn b/ext/input_pin_dialog/dialog_ui/js/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f6ee3951e7568dd17d7c3096a853f9723c76c88d --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni") + +gen_sa_dialog_js("dialog_js_files_etc") { + project_path = "//foundation/distributedhardware/devicemanager/ext/input_pin_dialog/dialog_ui/js" + dialog_name = "input_pin_service" + part_name = "device_manager_base" + subsystem_name = "distributedhardware" +} diff --git a/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js b/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js new file mode 100644 index 0000000000000000000000000000000000000000..c3234a50dc7569ed8bf587f6ea22899f0671b0f2 --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js @@ -0,0 +1,86 @@ + +;(function(exports){ + var KeyBoard = function(input, options){ + var body = document.getElementsByTagName('body')[0]; + var DIV_ID = options && options.divId || '__w_l_h_v_c_z_e_r_o_divid'; + + if(document.getElementById(DIV_ID)){ + body.removeChild(document.getElementById(DIV_ID)); + } + + this.input = input; + this.el = document.createElement('div'); + + var self = this; + var zIndex = options && options.zIndex || 1000; + var width = options && options.width || '100%'; + var height = options && options.height || '193px'; + var fontSize = options && options.fontSize || '15px'; + var backgroundColor = options && options.backgroundColor || '#fff'; + var TABLE_ID = options && options.table_id || 'table_0909099'; + var mobile = typeof orientation !== 'undefined'; + + this.el.id = DIV_ID; + this.el.style.position = 'absolute'; + this.el.style.left = 0; + this.el.style.right = 0; + this.el.style.bottom = 0; + this.el.style.zIndex = zIndex; + this.el.style.width = width; + this.el.style.height = height; + this.el.style.backgroundColor = backgroundColor; + + //样式 + var cssStr = ''; + + //Button + var btnStr = '
完成
'; + + //table + var tableStr = ''; + tableStr += ''; + tableStr += ''; + tableStr += ''; + tableStr += ''; + tableStr += ''; + tableStr += '
123
456
789
.0删除
'; + this.el.innerHTML = cssStr + btnStr + tableStr; + + function addEvent(e){ + var ev = e || window.event; + var clickEl = ev.element || ev.target; + var value = clickEl.textContent || clickEl.innerText; + if(clickEl.tagName.toLocaleLowerCase() === 'td' && value !== "删除"){ + if(self.input){ + self.input.value += value; + } + }else if(clickEl.tagName.toLocaleLowerCase() === 'div' && value === "完成"){ + body.removeChild(self.el); + }else if(clickEl.tagName.toLocaleLowerCase() === 'td' && value === "删除"){ + var num = self.input.value; + if(num){ + var newNum = num.substr(0, num.length - 1); + self.input.value = newNum; + } + } + } + + if(mobile){ + this.el.ontouchstart = addEvent; + }else{ + this.el.onclick = addEvent; + } + body.appendChild(this.el); + } + + exports.KeyBoard = KeyBoard; + +})(window); \ No newline at end of file diff --git a/ext/input_pin_dialog/dialog_ui/js/common/index.hml b/ext/input_pin_dialog/dialog_ui/js/common/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..3566d9ba28b0696c15f59dcf87adaa6155fb5430 --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/common/index.hml @@ -0,0 +1,32 @@ +
+ + PIN码连接 + + + 请输入另一个设备显示的PIN码进行验证 + + + + + PIN码输入错误,请重新输入 + +
+ + +
+ + + +
diff --git a/ext/input_pin_dialog/dialog_ui/js/common/pincode.png b/ext/input_pin_dialog/dialog_ui/js/common/pincode.png new file mode 100644 index 0000000000000000000000000000000000000000..6616f7659fcf1d5da5ab6796863e32efbe086cdc Binary files /dev/null and b/ext/input_pin_dialog/dialog_ui/js/common/pincode.png differ diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..0714fc75f8420ac089a6ee1c24c8f2d8472ff511 --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json @@ -0,0 +1,5 @@ +{ + "message":{ + "hello": "hello world" + } +} \ No newline at end of file diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..53afe2047da6ff0423e5eae8d9f9af9f73d85d0b --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json @@ -0,0 +1,5 @@ +{ + "message": { + "hello": "你好世界" + } +} \ No newline at end of file diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..3a36572779ba49501574e5b9e3f50705727298fe --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css @@ -0,0 +1,48 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + opacity: 0.8; + background-color: azure; +} + +.title { + font-size: 48px; + line-height: 40px; + font-weight: 800; +} + +.title-list { + font-size: 30px; + line-height: 35px; + font-weight: 800; +} + +.title-error { + font-size: 15px; + line-height: 20px; + font-weight: 800; + color: #ff0000; +} + +.title-pin { + font-size: 30px; + line-height: 35px; + font-weight: 800; +} + +.but { + margin: 10px 20px 10px 20px; +} + +.but1 { + width: 160px; + height: 36px; + font-size: 26px; +} + +.but2 { + width: 160px; + height: 36px; + font-size: 26px; +} \ No newline at end of file diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..a8be01f5f8b8a937732bfbb676fa28289dbcca3d --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml @@ -0,0 +1,23 @@ +
+ + PIN码连接 + + + 请输入另一个设备显示的PIN码进行验证 + + + + + + PIN码输入错误,请重新输入 + +
+ + +
+ +
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..7e358fc5dd95ec6d026ce913ac4cf99a6b65fdcf --- /dev/null +++ b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js @@ -0,0 +1,36 @@ +import router from '@ohos.router' + +var numbs = 0; +export default { + data: { + pincode: router.getParams().pinCode, + }, + onInit() { + console.info('getParams: ' + router.getParams()); + document.getElementById("error").setAttribute("hidden",true); + }, + onConfirm() { + console.info('click confirm'); + numbs = numbs + 1; + if (numbs < 3){ + var input= document.getElementById("input").value; + console.info('input: ' + input); + console.info('pincode: ' + pincode); + if (input == pincode){ + console.info('pincode: = input'); + callNativeHandler(input, "0"); + } else { + console.info('pincode: != input'); + //刷新页面,提示输入错误 + document.getElementById("error").removeAttribute("hidden"); + } + } else { + console.info('click cancel'); + callNativeHandler("EVENT_CONFIRM", "1"); + } + }, + onCancel() { + console.info('click cancel'); + callNativeHandler("EVENT_CONFIRM", "1"); + } +} \ No newline at end of file diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 603d4ff14d53df50cfdca566af1ab3cae631d406..9f3239711ce2a124db0a91235586620433afe7ea 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -25,10 +25,38 @@ if (defined(ohos_lite)) { include_dirs = [ "include", "${common_path}/include", - "${services_path}/include/adapter", "${ext_path}/pin_auth/include/ability", + "${services_path}/include/dependency/timer", + "${services_path}/include/config", + "${services_path}/include/adapter", "${services_path}/include/authentication", + "${services_path}/include/ability", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "${services_path}/include/discovery", + "${services_path}/include/dependency/commonevent", + "${services_path}/include/dependency/hichain", + "${services_path}/include/dependency/softbus", + "${services_path}/include/dependency/timer", + "${services_path}/include/ipc", + "${services_path}/include/ipc/standard", "${utils_path}/include", + "${utils_path}/include/ipc/standard", + "${services_path}/include", + "${innerkits_path}/native_cpp/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/ipc/standard", + "//third_party/json/include", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "//base/notification/ces_standard/frameworks/core/include", + "//base/notification/ces_standard/interfaces/innerkits/native/include", + "//base/security/deviceauth/interfaces/innerkits", + "//base/startup/syspara_lite/interfaces/kits", + "//base/startup/syspara_lite/adapter/native/syspara/include", ] sources = [ @@ -37,21 +65,34 @@ if (defined(ohos_lite)) { "src/pin_auth_ui.cpp", ] - deps = [ + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", + "//base/security/deviceauth/services:deviceauth_sdk", "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", + "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "//utils/native/base:utils", + "//foundation/ace/ace_engine/interfaces/innerkits/ui_service_manager:ui_service_mgr", + "${ext_path}/input_pin_dialog/dialog_ui/js:dialog_js_files_etc", + "${ext_path}/show_pin_dialog/dialog_ui/js:dialog_js_files_etc", + "//foundation/windowmanager/wm:libwm", ] external_deps = [ - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", + "appexecfwk_standard:appexecfwk_base", + "appexecfwk_standard:appexecfwk_core", + "appexecfwk_standard:libeventhandler", + "ces_standard:cesfwk_core", + "ces_standard:cesfwk_innerkits", + "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", "startup_l2:syspara", + "startup_l2:syspara_watchagent", ] defines = [ diff --git a/ext/pin_auth/include/pin_auth.h b/ext/pin_auth/include/pin_auth.h index 2129c94a1a5cd949d018fdb30bcca668f5efc474..b2636e0afdd1ce1906183fe10649debb1a3825ea 100644 --- a/ext/pin_auth/include/pin_auth.h +++ b/ext/pin_auth/include/pin_auth.h @@ -20,6 +20,7 @@ #include #include "authentication.h" +#include "dm_auth_manager.h" #include "dm_ability_manager.h" #include "pin_auth_ui.h" @@ -29,8 +30,8 @@ class PinAuth : public IAuthentication { public: PinAuth(); ~PinAuth(); - int32_t ShowAuthInfo() override; - int32_t StartAuth(std::shared_ptr dmAbilityManager) override; + int32_t ShowAuthInfo(int32_t code) override; + int32_t StartAuth(int32_t code, std::shared_ptr authManager) override; int32_t VerifyAuthentication(std::string pinToken, int32_t code, const std::string &authParam) override; private: diff --git a/ext/pin_auth/include/pin_auth_ui.h b/ext/pin_auth/include/pin_auth_ui.h index f8910cba26fe134c29fd199449c8ba622da6018d..61575797f893e15ade0b58883a0820823fbe6fb8 100644 --- a/ext/pin_auth/include/pin_auth_ui.h +++ b/ext/pin_auth/include/pin_auth_ui.h @@ -18,6 +18,7 @@ #include +#include "dm_auth_manager.h" #include "dm_ability_manager.h" namespace OHOS { @@ -25,8 +26,8 @@ namespace DistributedHardware { class PinAuthUi { public: PinAuthUi(); - int32_t ShowPinDialog(); - int32_t InputPinDialog(std::shared_ptr dmAbilityManager); + int32_t ShowPinDialog(int32_t code); + int32_t InputPinDialog(int32_t code, std::shared_ptr authManager); private: int32_t StartFaUiService(std::shared_ptr dmAbilityManager); diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 5e123b0c550dc0f5b51059b318390dee00151e73..069ca58a7e40ec0c1a514e0f24391dfcb27cfad7 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -33,15 +33,15 @@ PinAuth::~PinAuth() { } -int32_t PinAuth::ShowAuthInfo() +int32_t PinAuth::ShowAuthInfo(int32_t code) { - return pinAuthUi_->ShowPinDialog(); + return pinAuthUi_->ShowPinDialog(code); } -int32_t PinAuth::StartAuth(std::shared_ptr dmAbilityManager) +int32_t PinAuth::StartAuth(int32_t code, std::shared_ptr authManager) { - times_ = 0; - return pinAuthUi_->InputPinDialog(dmAbilityManager); + // times_ = 0; + return pinAuthUi_->InputPinDialog(code, authManager); } int32_t PinAuth::VerifyAuthentication(std::string pinToken, int32_t code, const std::string &authParam) diff --git a/ext/pin_auth/src/pin_auth_ui.cpp b/ext/pin_auth/src/pin_auth_ui.cpp index 691e5005239562cdeed0aad76f73cabbbaf91826..a6b0a00e09517df6729bf62c00e4eb265882d1bd 100644 --- a/ext/pin_auth/src/pin_auth_ui.cpp +++ b/ext/pin_auth/src/pin_auth_ui.cpp @@ -18,6 +18,8 @@ #include "dm_ability_manager.h" #include "dm_constants.h" #include "dm_log.h" +#include "nlohmann/json.hpp" +#include "ui_service_mgr_client.h" namespace OHOS { namespace DistributedHardware { @@ -26,18 +28,56 @@ PinAuthUi::PinAuthUi() LOGI("AuthUi constructor"); } -int32_t PinAuthUi::ShowPinDialog() +int32_t PinAuthUi::ShowPinDialog(int32_t code) { + LOGI("ShowPinDialog start"); + //ַ + nlohmann::json jsonObj; + jsonObj[PIN_CODE_KEY] = code; + jsonObj.dump(); + const std::string params = jsonObj.dump(); + + Ace::UIServiceMgrClient::GetInstance()->ShowDialog( + "show_pin_service", + params, + OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, + 50, + 500, + 400, + 200, + [](int32_t id, const std::string& event, const std::string& params) { + LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); + }); + LOGI("ShowConfigDialog end"); return DM_OK; } -int32_t PinAuthUi::InputPinDialog(std::shared_ptr dmAbilityManager) +int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager) { - if (dmAbilityManager == nullptr) { - LOGE("PinAuthUi::dmAbilityManager is null"); - return DM_FAILED; - } - return StartFaUiService(dmAbilityManager); + LOGI("InputPinDialog start"); + //ַ + nlohmann::json jsonObj; + jsonObj[PIN_CODE_KEY] = code; + jsonObj.dump(); + const std::string params = jsonObj.dump(); + // std::shared_ptr authMgr_ = authManager; + + Ace::UIServiceMgrClient::GetInstance()->ShowDialog( + "input_pin_service", + params, + OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, + 50, + 500, + 400, + 200, + [authManager](int32_t id, const std::string& event, const std::string& params) { + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); + LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); + authManager->VerifyPinAuthAuthentication(params.c_str()); + }); + LOGI("ShowConfigDialog end"); + return DM_OK; } int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager) diff --git a/ext/show_pin_dialog/dialog_ui/js/BUILD.gn b/ext/show_pin_dialog/dialog_ui/js/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..745e0b78c608137affdfe96d13e563e33759c911 --- /dev/null +++ b/ext/show_pin_dialog/dialog_ui/js/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") +import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni") + +gen_sa_dialog_js("dialog_js_files_etc") { + project_path = "//foundation/distributedhardware/devicemanager/ext/show_pin_dialog/dialog_ui/js" + dialog_name = "show_pin_service" + part_name = "device_manager_base" + subsystem_name = "distributedhardware" +} diff --git a/ext/show_pin_dialog/dialog_ui/js/common/pincode.png b/ext/show_pin_dialog/dialog_ui/js/common/pincode.png new file mode 100644 index 0000000000000000000000000000000000000000..6616f7659fcf1d5da5ab6796863e32efbe086cdc Binary files /dev/null and b/ext/show_pin_dialog/dialog_ui/js/common/pincode.png differ diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..0714fc75f8420ac089a6ee1c24c8f2d8472ff511 --- /dev/null +++ b/ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json @@ -0,0 +1,5 @@ +{ + "message":{ + "hello": "hello world" + } +} \ No newline at end of file diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..53afe2047da6ff0423e5eae8d9f9af9f73d85d0b --- /dev/null +++ b/ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json @@ -0,0 +1,5 @@ +{ + "message": { + "hello": "你好世界" + } +} \ No newline at end of file diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..feb20b4fd6d734135fa8b35d2a8fce28b34b69f2 --- /dev/null +++ b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css @@ -0,0 +1,31 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; + opacity: 0.8; + background-color: azure; +} + +.title { + font-size: 48px; + line-height: 50px; + font-weight: 800; +} + +.title-list { + font-size: 38px; + line-height: 40px; + font-weight: 800; +} + +.title-pin { + font-size: 48px; + line-height: 50px; + font-weight: 800; +} + +.but { + width: 100%; + font-size: 26px; + height: 36px; +} \ No newline at end of file diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..4d68e3acfa9bba6a0b60252d9ba00a9e4a55a40b --- /dev/null +++ b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml @@ -0,0 +1,14 @@ +
+ + PIN码连接 + + + 请在设备端输入链接码进行验证 + + + {{ pincode.split('').join(' ') }} + + +
\ No newline at end of file diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..114655c3a4d334a82a2e5a2186be08df84bea372 --- /dev/null +++ b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js @@ -0,0 +1,14 @@ +import router from '@ohos.router' + +export default { + data: { + pincode: router.getParams().pinCode, + }, + onInit() { + console.info('getParams: ' + router.getParams()); + }, + onConfirm() { + console.info('click confirm'); + callNativeHandler("EVENT_CONFIRM", "1"); + } +} \ No newline at end of file diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index ea83ecfab54b6214efdd8262f65c7d32968768ea..fd1be0fc45bab4624df00a8729728a98c45d80ff 100644 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -57,6 +57,7 @@ if (defined(ohos_lite)) { "//base/startup/syspara_lite/interfaces/kits", "//base/startup/syspara_lite/adapter/native/syspara/include", "//third_party/json/include", + "//third_party/flutter/skia", ] sources = [ @@ -92,6 +93,9 @@ if (defined(ohos_lite)) { "//foundation/aafwk/standard/interfaces/innerkits/want:want", "//foundation/aafwk/standard/services/abilitymgr:abilityms", "//utils/native/base:utils", + "//foundation/ace/ace_engine/interfaces/innerkits/ui_service_manager:ui_service_mgr", + "${common_path}/include/dialog_ui/js:dialog_js_files_etc", + "//foundation/windowmanager/wm:libwm", ] defines = [ diff --git a/services/devicemanagerservice/include/authentication/dm_auth_manager.h b/services/devicemanagerservice/include/authentication/dm_auth_manager.h index 2ea42c9b7c8a6bbe7bff6a445610ba6f8ea97bf0..6b0298ec907ad3c7c70e83bf738b05e8cb741d5f 100644 --- a/services/devicemanagerservice/include/authentication/dm_auth_manager.h +++ b/services/devicemanagerservice/include/authentication/dm_auth_manager.h @@ -129,6 +129,7 @@ public: const std::string &extra); int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId); int32_t VerifyAuthentication(const std::string &authParam); + void VerifyPinAuthAuthentication(const std::string &action); void OnSessionOpened(int32_t sessionId, int32_t sessionSide, int32_t result); void OnSessionClosed(int32_t sessionId); void OnDataReceived(int32_t sessionId, std::string message); diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 0f11031b5c4829619d234ceaad7f3f039bba1f6c..908d79e7bf684e3257a40c8989a5614775836bb3 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -24,6 +24,9 @@ #include "dm_random.h" #include "nlohmann/json.hpp" #include "parameter.h" +#include "ui_service_mgr_client.h" +#include "dialog_callback_stub.h" +#include "dialog_callback.h" namespace OHOS { namespace DistributedHardware { @@ -652,27 +655,58 @@ int32_t DmAuthManager::GetPinCode() void DmAuthManager::ShowConfigDialog() { - std::shared_ptr authUi_ = std::make_shared(); - dmAbilityMgr_ = std::make_shared(); - authUi_->ShowConfirmDialog(dmAbilityMgr_); + LOGI("ShowConfigDialog start"); + //ַ + nlohmann::json jsonObj; + jsonObj[TAG_AUTH_TYPE] = AUTH_TYPE_PIN; + jsonObj[TAG_TOKEN] = authResponseContext_->token; + jsonObj[TARGET_PKG_NAME_KEY] = authResponseContext_->targetPkgName; + // jsonObj[business] = BUSINESS_FA_MIRGRATION; + jsonObj.dump(); + const std::string params = jsonObj.dump(); + std::shared_ptr authMgr_ = shared_from_this(); + + Ace::UIServiceMgrClient::GetInstance()->ShowDialog( + "config_dialog_service", + params, + OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, + 50, + 500, + 400, + 200, + [authMgr_](int32_t id, const std::string& event, const std::string& params) { + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); + LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); + authMgr_->StartAuthProcess(atoi(params.c_str())); + }); + LOGI("ShowConfigDialog end"); } void DmAuthManager::ShowAuthInfoDialog() { - return; + LOGI("DmAuthManager::ShowAuthInfoDialog start"); + //pin + authResponseContext_->code = GeneratePincode(); + std::shared_ptr ptr; + if (authenticationMap_.find(1) == authenticationMap_.end()) { + LOGE("DmAuthManager::authenticationMap_ is null"); + return; + } + ptr = authenticationMap_[1]; + LOGI("ShowAuthInfoDialog code:%d", authResponseContext_->code); + ptr->ShowAuthInfo(authResponseContext_->code); } void DmAuthManager::ShowStartAuthDialog() { LOGI("DmAuthManager::ShowStartAuthDialog start"); - dmAbilityMgr_ = std::make_shared(); std::shared_ptr ptr; if (authenticationMap_.find(1) == authenticationMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); return; } ptr = authenticationMap_[1]; - ptr->StartAuth(dmAbilityMgr_); + ptr->StartAuth(authResponseContext_->code,shared_from_this()); } int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam) @@ -737,5 +771,22 @@ void DmAuthManager::UserSwitchEventCallback (void) } } } + +void DmAuthManager::VerifyPinAuthAuthentication(const std::string &action) +{ + LOGI("DmAuthManager::VerifyPinAuthAuthentication"); + timerMap_[INPUT_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); + if (action == "0") + { + authRequestState_->TransitionTo(std::make_shared()); + } + if (action == "1") + { + authRequestContext_->reason = DM_AUTH_INPUT_FAILED; + authResponseContext_->state = authRequestState_->GetStateType(); + authRequestState_->TransitionTo(std::make_shared()); + } + LOGI("DmAuthManager::VerifyAuthentication complete"); +} } // namespace DistributedHardware } // namespace OHOS