diff --git a/bundle.json b/bundle.json
index 06952ef47384abcef9ebebef2d5cf7b62fefc703..050c155dd3eb555c98edece46d49327dba3999b8 100644
--- a/bundle.json
+++ b/bundle.json
@@ -69,4 +69,4 @@
]
}
}
-}
+}
\ 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
index 6a57d7386b47062529e5ab39b1ec32c27e62d51c..024615c3806a6534e933fafd9fa5b8585e2064fb 100644
--- a/common/include/dialog_ui/js/pages/index/index.css
+++ b/common/include/dialog_ui/js/pages/index/index.css
@@ -2,6 +2,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
+ opacity: 0.8;
background-color: azure;
}
@@ -22,8 +23,6 @@
width: 70%;
height: 80px;
font-size: 40px;
- border: 1px solid #e7e7e7;
- border-radius: 50px;
}
.but2 {
@@ -31,8 +30,6 @@
height: 80px;
font-size: 40px;
margin-left: 10%;
- border: 1px solid #e7e7e7;
- border-radius: 50px;
}
diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h
index 1206f3909740ac8325d19fdcb5f1a940afb2e817..913e73f82a279d4159d2a6aa4ad9da8d98248ed8 100644
--- a/common/include/dm_constants.h
+++ b/common/include/dm_constants.h
@@ -140,6 +140,7 @@ const std::string AUTH_TYPE = "authType";
const std::string TOKEN = "token";
const std::string PIN_TOKEN = "pinToken";
const std::string PIN_CODE_KEY = "pinCode";
+const std::string TAG_CERTIFIED_PARAM = "certifiedParam";
const int32_t AUTH_TYPE_PIN = 1;
const int32_t AUTH_TYPE_SCAN = 2;
const int32_t AUTH_TYPE_TOUCH = 3;
diff --git a/ext/BUILD.gn b/ext/BUILD.gn
index df1b58535c2d55fa019bf3c12c6dafefad964edb..9a10471d6a5fd8a89a6a30eb66f64c61444ad435 100644
--- a/ext/BUILD.gn
+++ b/ext/BUILD.gn
@@ -19,6 +19,8 @@ group("ext_modules") {
deps += [
"./pin_auth:devicemanagerext_pin_auth",
"./profile:devicemanagerext_profile",
+ "./nfc_auth:devicemanager_nfcauth",
+ "./qr_code_auth:devicemanager_qrcodeauth"
]
}
}
diff --git a/ext/input_pin_dialog/dialog_ui/js/BUILD.gn b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/BUILD.gn
similarity index 94%
rename from ext/input_pin_dialog/dialog_ui/js/BUILD.gn
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/BUILD.gn
index 8abf88695e272f47842c8c6549920376cff6b74b..00603189b07801ea95f7c2f55bb3437c612e0a8e 100644
--- a/ext/input_pin_dialog/dialog_ui/js/BUILD.gn
+++ b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/BUILD.gn
@@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
gen_sa_dialog_js("dialog_js_files_etc") {
- project_path = "//foundation/distributedhardware/devicemanager/ext/input_pin_dialog/dialog_ui/js"
+ project_path = "//foundation/distributedhardware/devicemanager/ext/child_auth_ui//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/child_auth_ui/input_pin_dialog/dialog_ui/js/common/KeyBoard.js
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/common/KeyBoard.js
diff --git a/ext/input_pin_dialog/dialog_ui/js/common/index.hml b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/common/index.hml
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/common/index.hml
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/common/index.hml
diff --git a/ext/input_pin_dialog/dialog_ui/js/common/pincode.png b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/common/pincode.png
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/common/pincode.png
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/common/pincode.png
diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/i18n/en-US.json
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/i18n/en-US.json
diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.css
similarity index 76%
rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.css
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.css
index 7a13cd6ce3967228bf41825c336b2cc3a6e16e14..fc2207c2f9f7e3d00aa2e2d32073cbfbf2ea34ec 100644
--- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css
+++ b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.css
@@ -2,6 +2,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
+ opacity: 0.8;
background-color: azure;
}
@@ -14,13 +15,13 @@
.title-list {
font-size: 60px;
line-height: 60px;
- font-weight: 600;
+ font-weight: 800;
}
.title-error {
font-size: 30px;
line-height: 40px;
- font-weight: 500;
+ font-weight: 800;
color: #ff0000;
}
@@ -40,17 +41,13 @@
.but1 {
width: 30%;
height: 80px;
- font-size: 40px;
+ font-size: 50px;
margin-left: 10%;
- border: 1px solid #e7e7e7;
- border-radius: 50px;
}
.but2 {
width: 30%;
height: 80px;
- font-size: 40px;
+ font-size: 50px;
margin-left: 55%;
- border: 1px solid #e7e7e7;
- border-radius: 50px;
}
\ No newline at end of file
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.hml
similarity index 58%
rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.hml
index 84f217637922f7f11220581ad95ca82c435abbf6..c8edca3fb50de19ccbca16b9436c9f148c42cafb 100644
--- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml
+++ b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.hml
@@ -6,14 +6,11 @@
请输入另一个设备显示的PIN码进行验证
-
- PIN码输入错误,请重新输入(3次:还有{{isTimes}}次机会)
-
-
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.js
similarity index 62%
rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.js
rename to ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.js
index 514b6ec77625f87c10ea936fcd20191c9f544f72..c68e1a3dd639e7f449fd306401e046a139abdc45 100644
--- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js
+++ b/ext/child_auth_ui/input_pin_dialog/dialog_ui/js/pages/index/index.js
@@ -6,32 +6,24 @@ var inputVal = 0;
export default {
data: {
pincode: router.getParams().pinCode,
- isShow:false,
- isTimes:3,
},
onInit() {
code = router.getParams().pinCode;
- callNativeHandler("EVENT_CONFIRM", "2");
},
onChange(e){
inputVal = e.value;
},
onConfirm() {
numbs = numbs + 1;
- if(numbs <= 3){
+ if(numbs < 3){
console.info('click cancel numbs < 3 ');
console.info('code: ' + code);
console.info('inputVal: ' + inputVal);
if(code == inputVal){
- console.info('click cancel code == inputVal');
- callNativeHandler("EVENT_INPUT", "0");
+ console.info('click cancel code == inputVal');
+ callNativeHandler("EVENT_INPUT", "0");
}else{
- if(numbs == 3){
- callNativeHandler("EVENT_CONFIRM", "1");
- }
- console.info('click cancel code != inputVal');
- this.isShow = true;
- this.isTimes = 3 - numbs;
+ console.info('click cancel code != inputVal');
}
}else{
console.info('click cancel numbs > 3 ');
diff --git a/ext/child_auth_ui/scan_dialog/dialog_ui/js/BUILD.gn b/ext/child_auth_ui/scan_dialog/dialog_ui/js/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..4a1c51d0d918a4d80138d7151fb3ace4ccd53f8e
--- /dev/null
+++ b/ext/child_auth_ui/scan_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/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
+import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
+
+gen_sa_dialog_js("dialog_js_files_etc") {
+ project_path = "//foundation/distributedhardware/devicemanager/ext/child_auth_ui/scan_dialog/dialog_ui/js"
+ dialog_name = "scan_service"
+ part_name = "device_manager_base"
+ subsystem_name = "distributedhardware"
+}
diff --git a/ext/show_pin_dialog/dialog_ui/js/common/pincode.png b/ext/child_auth_ui/scan_dialog/dialog_ui/js/common/pincode.png
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/common/pincode.png
rename to ext/child_auth_ui/scan_dialog/dialog_ui/js/common/pincode.png
diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/child_auth_ui/scan_dialog/dialog_ui/js/i18n/en-US.json
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json
rename to ext/child_auth_ui/scan_dialog/dialog_ui/js/i18n/en-US.json
diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/child_auth_ui/scan_dialog/dialog_ui/js/i18n/zh-CN.json
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json
rename to ext/child_auth_ui/scan_dialog/dialog_ui/js/i18n/zh-CN.json
diff --git a/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.css b/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..d6b65b0781fc28b3933b4ca103878e1b1b27e073
--- /dev/null
+++ b/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.css
@@ -0,0 +1,53 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ opacity: 0.8;
+ background-color: azure;
+}
+
+.title {
+ font-size: 80px;
+ line-height: 100px;
+ font-weight: 800;
+}
+
+.title-list {
+ font-size: 60px;
+ line-height: 60px;
+ font-weight: 800;
+}
+
+.title-error {
+ font-size: 30px;
+ line-height: 40px;
+ font-weight: 800;
+ color: #ff0000;
+}
+
+.title-pin {
+ font-size: 60px;
+ line-height: 80px;
+ font-weight: 800;
+}
+
+.but {
+ width: 85%;
+ margin-top: 10%;
+ text-align: center;
+ height: 100px;
+}
+
+.but1 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 10%;
+}
+
+.but2 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 55%;
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.hml b/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..45c8429e09673275d3f00e54e0dccd7c52a1c678
--- /dev/null
+++ b/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.hml
@@ -0,0 +1,16 @@
+
+
+ 二维码扫描
+
+
+ 二维码扫描框
+
+
+
+ 取消
+
+
+ 确定
+
+
+
\ No newline at end of file
diff --git a/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.js b/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..f5fce5c1b79678425dd74d201ad07ecf49466686
--- /dev/null
+++ b/ext/child_auth_ui/scan_dialog/dialog_ui/js/pages/index/index.js
@@ -0,0 +1,19 @@
+import router from '@ohos.router'
+
+export default {
+ data: {
+ qr_code: router.getParams().certifiedParam,
+ },
+ onInit() {
+ console.info('getParams: ' + router.getParams());
+ callNativeHandler("EVENT_INIT", "0");
+ },
+ onConfirm() {
+ console.info('click confirm');
+ callNativeHandler("EVENT_CONFIRM", qr_code);
+ },
+ onCancel() {
+ console.info('click cancel');
+ callNativeHandler("EVENT_CANCEL", "2");
+ }
+}
\ No newline at end of file
diff --git a/ext/show_pin_dialog/dialog_ui/js/BUILD.gn b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/BUILD.gn
similarity index 95%
rename from ext/show_pin_dialog/dialog_ui/js/BUILD.gn
rename to ext/child_auth_ui/show_pin_dialog/dialog_ui/js/BUILD.gn
index 8c623e7f87ffeec940e5f3a0730114001f79f6e0..82e4ec76e469bcaeb778ac54ca26fb5a08f02e7a 100644
--- a/ext/show_pin_dialog/dialog_ui/js/BUILD.gn
+++ b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/BUILD.gn
@@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
gen_sa_dialog_js("dialog_js_files_etc") {
- project_path = "//foundation/distributedhardware/devicemanager/ext/show_pin_dialog/dialog_ui/js"
+ project_path = "//foundation/distributedhardware/devicemanager/ext/child_auth_ui/show_pin_dialog/dialog_ui/js"
dialog_name = "show_pin_service"
part_name = "device_manager_base"
subsystem_name = "distributedhardware"
diff --git a/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/common/pincode.png b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/common/pincode.png
new file mode 100644
index 0000000000000000000000000000000000000000..6616f7659fcf1d5da5ab6796863e32efbe086cdc
Binary files /dev/null and b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/common/pincode.png differ
diff --git a/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..0714fc75f8420ac089a6ee1c24c8f2d8472ff511
--- /dev/null
+++ b/ext/child_auth_ui/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/child_auth_ui/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..53afe2047da6ff0423e5eae8d9f9af9f73d85d0b
--- /dev/null
+++ b/ext/child_auth_ui/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/child_auth_ui/show_pin_dialog/dialog_ui/js/pages/index/index.css
similarity index 45%
rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.css
rename to ext/child_auth_ui/show_pin_dialog/dialog_ui/js/pages/index/index.css
index ad2c2c4163304477cc340203355f1f1ea6b60d30..fc2207c2f9f7e3d00aa2e2d32073cbfbf2ea34ec 100644
--- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css
+++ b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/pages/index/index.css
@@ -2,31 +2,52 @@
flex-direction: column;
justify-content: center;
align-items: center;
+ opacity: 0.8;
background-color: azure;
}
.title {
font-size: 80px;
- line-height: 120px;
+ line-height: 100px;
font-weight: 800;
}
.title-list {
font-size: 60px;
- line-height: 100px;
- font-weight: 600;
+ line-height: 60px;
+ font-weight: 800;
+}
+
+.title-error {
+ font-size: 30px;
+ line-height: 40px;
+ font-weight: 800;
+ color: #ff0000;
}
.title-pin {
font-size: 60px;
- line-height: 100px;
+ line-height: 80px;
font-weight: 800;
}
.but {
+ width: 85%;
+ margin-top: 10%;
+ text-align: center;
+ height: 100px;
+}
+
+.but1 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 10%;
+}
+
+.but2 {
width: 30%;
- font-size: 40px;
height: 80px;
- border: 1px solid #e7e7e7;
- border-radius: 50px;
+ font-size: 50px;
+ margin-left: 55%;
}
\ No newline at end of file
diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/pages/index/index.hml
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml
rename to ext/child_auth_ui/show_pin_dialog/dialog_ui/js/pages/index/index.hml
diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/child_auth_ui/show_pin_dialog/dialog_ui/js/pages/index/index.js
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.js
rename to ext/child_auth_ui/show_pin_dialog/dialog_ui/js/pages/index/index.js
diff --git a/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/BUILD.gn b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..4a850d2444cf3023704a12c2092d1bc6960700e8
--- /dev/null
+++ b/ext/child_auth_ui/show_qr_code_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/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
+import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
+
+gen_sa_dialog_js("dialog_js_files_etc") {
+ project_path = "//foundation/distributedhardware/devicemanager/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js"
+ dialog_name = "show_qr_code_dialog"
+ part_name = "device_manager_base"
+ subsystem_name = "distributedhardware"
+}
diff --git a/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/common/pincode.png b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/common/pincode.png
new file mode 100644
index 0000000000000000000000000000000000000000..6616f7659fcf1d5da5ab6796863e32efbe086cdc
Binary files /dev/null and b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/common/pincode.png differ
diff --git a/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/i18n/en-US.json b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..0714fc75f8420ac089a6ee1c24c8f2d8472ff511
--- /dev/null
+++ b/ext/child_auth_ui/show_qr_code_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/child_auth_ui/show_qr_code_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..53afe2047da6ff0423e5eae8d9f9af9f73d85d0b
--- /dev/null
+++ b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/i18n/zh-CN.json
@@ -0,0 +1,5 @@
+{
+ "message": {
+ "hello": "你好世界"
+ }
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.css b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..d6b65b0781fc28b3933b4ca103878e1b1b27e073
--- /dev/null
+++ b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.css
@@ -0,0 +1,53 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ opacity: 0.8;
+ background-color: azure;
+}
+
+.title {
+ font-size: 80px;
+ line-height: 100px;
+ font-weight: 800;
+}
+
+.title-list {
+ font-size: 60px;
+ line-height: 60px;
+ font-weight: 800;
+}
+
+.title-error {
+ font-size: 30px;
+ line-height: 40px;
+ font-weight: 800;
+ color: #ff0000;
+}
+
+.title-pin {
+ font-size: 60px;
+ line-height: 80px;
+ font-weight: 800;
+}
+
+.but {
+ width: 85%;
+ margin-top: 10%;
+ text-align: center;
+ height: 100px;
+}
+
+.but1 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 10%;
+}
+
+.but2 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 55%;
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.hml b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..cb1a8e094316b44eafa6a28bd44a7056406fbae4
--- /dev/null
+++ b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.hml
@@ -0,0 +1,14 @@
+
+
+ 通过二维码验证
+
+
+ 请在对端设备扫描二维码进行验证
+
+
+ {{ "pincode" }}
+
+
+ 取消
+
+
\ No newline at end of file
diff --git a/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.js b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..bcfb49daae960e4dae850a59f257ff789d2237ae
--- /dev/null
+++ b/ext/child_auth_ui/show_qr_code_dialog/dialog_ui/js/pages/index/index.js
@@ -0,0 +1,15 @@
+import router from '@ohos.router'
+
+export default {
+ data: {
+ qr_code: router.getParams().certifiedParam,
+ },
+ onInit() {
+ console.info('getParams: ' + router.getParams());
+ callNativeHandler("EVENT_INIT", "0");
+ },
+ onConfirm() {
+ console.info('click confirm');
+ callNativeHandler("EVENT_CANCEL", "1");
+ }
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/BUILD.gn b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..f74c54c6fdc139eb53a0efeb086ba6d89e29f628
--- /dev/null
+++ b/ext/child_auth_ui/show_touch_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/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
+import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
+
+gen_sa_dialog_js("dialog_js_files_etc") {
+ project_path = "//foundation/distributedhardware/devicemanager/ext/child_auth_ui/touch_dialog/dialog_ui/js"
+ dialog_name = "show_touch_service"
+ part_name = "device_manager_base"
+ subsystem_name = "distributedhardware"
+}
diff --git a/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/common/pincode.png b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/common/pincode.png
new file mode 100644
index 0000000000000000000000000000000000000000..6616f7659fcf1d5da5ab6796863e32efbe086cdc
Binary files /dev/null and b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/common/pincode.png differ
diff --git a/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/i18n/en-US.json b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..0714fc75f8420ac089a6ee1c24c8f2d8472ff511
--- /dev/null
+++ b/ext/child_auth_ui/show_touch_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/child_auth_ui/show_touch_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..53afe2047da6ff0423e5eae8d9f9af9f73d85d0b
--- /dev/null
+++ b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/i18n/zh-CN.json
@@ -0,0 +1,5 @@
+{
+ "message": {
+ "hello": "你好世界"
+ }
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.css b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..d6b65b0781fc28b3933b4ca103878e1b1b27e073
--- /dev/null
+++ b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.css
@@ -0,0 +1,53 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ opacity: 0.8;
+ background-color: azure;
+}
+
+.title {
+ font-size: 80px;
+ line-height: 100px;
+ font-weight: 800;
+}
+
+.title-list {
+ font-size: 60px;
+ line-height: 60px;
+ font-weight: 800;
+}
+
+.title-error {
+ font-size: 30px;
+ line-height: 40px;
+ font-weight: 800;
+ color: #ff0000;
+}
+
+.title-pin {
+ font-size: 60px;
+ line-height: 80px;
+ font-weight: 800;
+}
+
+.but {
+ width: 85%;
+ margin-top: 10%;
+ text-align: center;
+ height: 100px;
+}
+
+.but1 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 10%;
+}
+
+.but2 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 55%;
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.hml b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..ff2ed4496254e67f105edbac4a10d26ccf7255c1
--- /dev/null
+++ b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.hml
@@ -0,0 +1,14 @@
+
+
+ 碰一碰
+
+
+ 若终止,请取消
+
+
+ {{ "pincode" }}
+
+
+ 取消
+
+
\ No newline at end of file
diff --git a/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.js b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..77dcbd5509d517eafdf60ecc4e7cc1e3538bf802
--- /dev/null
+++ b/ext/child_auth_ui/show_touch_dialog/dialog_ui/js/pages/index/index.js
@@ -0,0 +1,16 @@
+import router from '@ohos.router'
+
+export default {
+ data: {
+ nfcCode: router.getParams().certifiedParam,
+ },
+ onInit() {
+ console.info('getParams: ' + router.getParams());
+ console.info('getParams: =========123456qr========');
+ callNativeHandler("EVENT_INIT", "0");
+ },
+ onConfirm() {
+ console.info('click confirm');
+ callNativeHandler("EVENT_CANCEL", "1");
+ }
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/touch_dialog/dialog_ui/js/BUILD.gn b/ext/child_auth_ui/touch_dialog/dialog_ui/js/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..0b3710cc8a7d725e55df53013fd585514d48629a
--- /dev/null
+++ b/ext/child_auth_ui/touch_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/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
+import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
+
+gen_sa_dialog_js("dialog_js_files_etc") {
+ project_path = "//foundation/distributedhardware/devicemanager/ext/child_auth_ui/show_touch_dialog/dialog_ui/js"
+ dialog_name = "touch_service"
+ part_name = "device_manager_base"
+ subsystem_name = "distributedhardware"
+}
diff --git a/ext/child_auth_ui/touch_dialog/dialog_ui/js/common/pincode.png b/ext/child_auth_ui/touch_dialog/dialog_ui/js/common/pincode.png
new file mode 100644
index 0000000000000000000000000000000000000000..6616f7659fcf1d5da5ab6796863e32efbe086cdc
Binary files /dev/null and b/ext/child_auth_ui/touch_dialog/dialog_ui/js/common/pincode.png differ
diff --git a/ext/child_auth_ui/touch_dialog/dialog_ui/js/i18n/en-US.json b/ext/child_auth_ui/touch_dialog/dialog_ui/js/i18n/en-US.json
new file mode 100644
index 0000000000000000000000000000000000000000..0714fc75f8420ac089a6ee1c24c8f2d8472ff511
--- /dev/null
+++ b/ext/child_auth_ui/touch_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/child_auth_ui/touch_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/child_auth_ui/touch_dialog/dialog_ui/js/i18n/zh-CN.json
new file mode 100644
index 0000000000000000000000000000000000000000..53afe2047da6ff0423e5eae8d9f9af9f73d85d0b
--- /dev/null
+++ b/ext/child_auth_ui/touch_dialog/dialog_ui/js/i18n/zh-CN.json
@@ -0,0 +1,5 @@
+{
+ "message": {
+ "hello": "你好世界"
+ }
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.css b/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.css
new file mode 100644
index 0000000000000000000000000000000000000000..d6b65b0781fc28b3933b4ca103878e1b1b27e073
--- /dev/null
+++ b/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.css
@@ -0,0 +1,53 @@
+.container {
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ opacity: 0.8;
+ background-color: azure;
+}
+
+.title {
+ font-size: 80px;
+ line-height: 100px;
+ font-weight: 800;
+}
+
+.title-list {
+ font-size: 60px;
+ line-height: 60px;
+ font-weight: 800;
+}
+
+.title-error {
+ font-size: 30px;
+ line-height: 40px;
+ font-weight: 800;
+ color: #ff0000;
+}
+
+.title-pin {
+ font-size: 60px;
+ line-height: 80px;
+ font-weight: 800;
+}
+
+.but {
+ width: 85%;
+ margin-top: 10%;
+ text-align: center;
+ height: 100px;
+}
+
+.but1 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 10%;
+}
+
+.but2 {
+ width: 30%;
+ height: 80px;
+ font-size: 50px;
+ margin-left: 55%;
+}
\ No newline at end of file
diff --git a/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.hml b/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.hml
new file mode 100644
index 0000000000000000000000000000000000000000..8b2066f1cacd1e8f1271b2a4f5888353bbfd4157
--- /dev/null
+++ b/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.hml
@@ -0,0 +1,19 @@
+
+
+ 碰一碰
+
+
+ 请点击确认
+
+
+ 图片
+
+
+
+ 取消
+
+
+ 确定
+
+
+
\ No newline at end of file
diff --git a/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.js b/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..5bf41cef2873512a37fe971b007d992b75158157
--- /dev/null
+++ b/ext/child_auth_ui/touch_dialog/dialog_ui/js/pages/index/index.js
@@ -0,0 +1,21 @@
+import router from '@ohos.router'
+
+export default {
+ data: {
+ nfcCode: router.getParams().certifiedParam,
+ },
+ onInit() {
+ console.info('getParams: =========123456qr========');
+ console.info('getParams: ' + router.getParams());
+ callNativeHandler("EVENT_INIT", "0");
+ },
+ onConfirm() {
+ console.info('click confirm');
+ callNativeHandler("EVENT_CONFIRM", nfcCode);
+ },
+ onCancel() {
+ console.info('click cancel');
+ callNativeHandler("EVENT_CANCEL", "2");
+ }
+ }
+}
\ No newline at end of file
diff --git a/ext/nfc_auth/BUILD.gn b/ext/nfc_auth/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..3d6b3b5ab3b37b48dbf1e29bbc1e515429edbfdb
--- /dev/null
+++ b/ext/nfc_auth/BUILD.gn
@@ -0,0 +1,105 @@
+# 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.
+
+if (defined(ohos_lite)) {
+ import("//build/lite/config/component/lite_component.gni")
+} else {
+ import("//build/ohos.gni")
+}
+
+import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
+
+if (defined(ohos_lite)) {
+} else {
+ ohos_shared_library("devicemanager_nfcauth") {
+ include_dirs = [
+ "include",
+ "${common_path}/include",
+ "${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 = [
+ "src/nfc_auth.cpp"
+ ]
+
+ deps = [
+ "${ext_path}/child_auth_ui/show_touch_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${ext_path}/child_auth_ui/touch_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${innerkits_path}/native_cpp:devicemanagersdk",
+ "${services_path}:devicemanagerservice",
+ "${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/ace/ace_engine/interfaces/innerkits/ui_service_manager:ui_service_mgr",
+ "//foundation/windowmanager/wm:libwm",
+ "//utils/native/base:utils",
+ ]
+
+ external_deps = [
+ "bundle_framework:appexecfwk_base",
+ "bundle_framework:appexecfwk_core",
+ "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 = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"devicemanagerext\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ subsystem_name = "distributedhardware"
+
+ part_name = "device_manager_base"
+ }
+}
diff --git a/ext/nfc_auth/include/nfc_auth.h b/ext/nfc_auth/include/nfc_auth.h
new file mode 100644
index 0000000000000000000000000000000000000000..84dde2a8be3ad25b4ae24e4ab215c815c81002f3
--- /dev/null
+++ b/ext/nfc_auth/include/nfc_auth.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#ifndef OHOS_DM_TOUCH_AUTH_H
+#define OHOS_DM_TOUCH_AUTH_H
+
+#include
+#include
+
+#include "authentication.h"
+#include "dm_auth_manager.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+class NFCAuth : public IAuthentication {
+public:
+ NFCAuth();
+ ~NFCAuth();
+ int32_t ShowAuthInfo(std::string &certifiedParam, std::shared_ptr authManager) override;
+ int32_t StartAuth(std::string &certifiedParam, std::shared_ptr authManager) override;
+ int32_t VerifyAuthentication(std::string &certifiedParam, const std::string &authParam) override;
+ int32_t ClosePage(int32_t pageId) override;
+};
+} // namespace DistributedHardware
+} // namespace OHOS
+#endif // OHOS_DM_TOUCH_AUTH_H
\ No newline at end of file
diff --git a/ext/nfc_auth/src/nfc_auth.cpp b/ext/nfc_auth/src/nfc_auth.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eaa625246a8871f3fda46624091bec6a6163715f
--- /dev/null
+++ b/ext/nfc_auth/src/nfc_auth.cpp
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+#include "nfc_auth.h"
+
+#include
+
+#include "dm_constants.h"
+#include "dm_log.h"
+#include "nlohmann/json.hpp"
+#include "ui_service_mgr_client.h"
+namespace OHOS {
+namespace DistributedHardware {
+NFCAuth::NFCAuth()
+{
+ LOGI("NFCAuth constructor");
+}
+
+NFCAuth::~NFCAuth()
+{
+}
+
+int32_t NFCAuth::ShowAuthInfo(std::string &certifiedParam, std::shared_ptr authManager)
+{
+ LOGI("ShowPinDialog start");
+ //定义字符串
+ nlohmann::json jsonObj;
+ jsonObj[TAG_CERTIFIED_PARAM] = certifiedParam;
+ jsonObj.dump();
+ const std::string params = jsonObj.dump();
+
+ Ace::UIServiceMgrClient::GetInstance()->ShowDialog(
+ "show_touch_service",
+ params,
+ OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
+ ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
+ [authManager](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());
+ if (event == "EVENT_INIT"){
+ authManager->SetPageId(id);
+ } else {
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
+ authManager->AuthenticateFinish();
+ }
+ });
+ LOGI("ShowConfigDialog end");
+ return DM_OK;
+}
+
+int32_t NFCAuth::StartAuth(std::string &certifiedParam, std::shared_ptr authManager)
+{
+ LOGI("InputPinDialog start");
+ //定义字符串
+ nlohmann::json jsonObj;
+ jsonObj[TAG_CERTIFIED_PARAM] = certifiedParam;
+ jsonObj.dump();
+ const std::string params = jsonObj.dump();
+ // std::shared_ptr authMgr_ = authManager;
+
+ Ace::UIServiceMgrClient::GetInstance()->ShowDialog(
+ "touch_service",
+ params,
+ OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
+ ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
+ [authManager](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());
+ if (event == "EVENT_INIT"){
+ authManager->SetPageId(id);
+ } else if(event == "EVENT_CONFIRM"){
+ authManager->VerifyAuthentication(params);
+ } else {
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
+ authManager->AuthenticateFinish();
+ }
+ });
+ LOGI("ShowConfigDialog end");
+ return DM_OK;
+}
+
+int32_t NFCAuth::VerifyAuthentication(std::string &certifiedParam, const std::string &authParam)
+{
+ if (certifiedParam == authParam){
+ return DM_OK;
+ }
+ return DM_FAILED;
+}
+
+int32_t NFCAuth::ClosePage(int32_t pageId)
+{
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(pageId);
+ return DM_OK;
+}
+
+extern "C" IAuthentication *CreateNfcAuthObject(void)
+{
+ return new NFCAuth;
+}
+} // namespace DistributedHardware
+} // namespace OHOS
diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn
index 41bfe45895d84043dd289304b4e37359cf414055..ba5e64b1fd3ef1689a46c8fece07d8c3ee33261b 100644
--- a/ext/pin_auth/BUILD.gn
+++ b/ext/pin_auth/BUILD.gn
@@ -66,16 +66,16 @@ if (defined(ohos_lite)) {
]
deps = [
- "${ext_path}/input_pin_dialog/dialog_ui/js:dialog_js_files_etc",
- "${ext_path}/show_pin_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${ext_path}/child_auth_ui/input_pin_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${ext_path}/child_auth_ui/show_pin_dialog/dialog_ui/js:dialog_js_files_etc",
"${innerkits_path}/native_cpp:devicemanagersdk",
+ "${services_path}:devicemanagerservice",
"${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/ace/ace_engine/interfaces/innerkits/ui_service_manager:ui_service_mgr",
- "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice",
"//foundation/windowmanager/wm:libwm",
"//utils/native/base:utils",
]
@@ -104,4 +104,4 @@ if (defined(ohos_lite)) {
part_name = "device_manager_base"
}
-}
+}
\ No newline at end of file
diff --git a/ext/pin_auth/include/pin_auth.h b/ext/pin_auth/include/pin_auth.h
index dca2e7e7f9e12b4679d778c7d4a9b893f46c129d..ca0d2b998b7ccd41048a3611f4d7fa99e55cf1e2 100644
--- a/ext/pin_auth/include/pin_auth.h
+++ b/ext/pin_auth/include/pin_auth.h
@@ -30,12 +30,11 @@ class PinAuth : public IAuthentication {
public:
PinAuth();
~PinAuth();
- int32_t ShowAuthInfo(int32_t code, std::shared_ptr authManager) 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;
-
+ int32_t ShowAuthInfo(std::string &certifiedParam, std::shared_ptr authManager) override;
+ int32_t StartAuth(std::string &certifiedParam, std::shared_ptr authManager) override;
+ int32_t VerifyAuthentication(std::string &certifiedParam, const std::string &authParam) override;
+ int32_t ClosePage(int32_t pageId) override;
private:
- int32_t times_ = 0;
std::shared_ptr pinAuthUi_;
};
} // namespace DistributedHardware
diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp
index 0bbadd15f7aa503e771432a132e9512f1834eec8..3dabd383927253b53fdae50fbe94de413e2d52dd 100644
--- a/ext/pin_auth/src/pin_auth.cpp
+++ b/ext/pin_auth/src/pin_auth.cpp
@@ -23,7 +23,6 @@
namespace OHOS {
namespace DistributedHardware {
-const int32_t MAX_VERIFY_TIMES = 3;
PinAuth::PinAuth()
{
LOGI("PinAuth constructor");
@@ -33,37 +32,46 @@ PinAuth::~PinAuth()
{
}
-int32_t PinAuth::ShowAuthInfo(int32_t code, std::shared_ptr authManager)
+int32_t PinAuth::ShowAuthInfo(std::string &certifiedParam, std::shared_ptr authManager)
{
- return pinAuthUi_->ShowPinDialog(code, authManager);
+ return pinAuthUi_->ShowPinDialog(atoi(certifiedParam.c_str()), authManager);
}
-int32_t PinAuth::StartAuth(int32_t code, std::shared_ptr authManager)
+int32_t PinAuth::StartAuth(std::string &certifiedParam, std::shared_ptr authManager)
{
- return pinAuthUi_->InputPinDialog(code, authManager);
+ return pinAuthUi_->InputPinDialog(atoi(certifiedParam.c_str()), authManager);
}
-int32_t PinAuth::VerifyAuthentication(std::string pinToken, int32_t code, const std::string &authParam)
+int32_t PinAuth::VerifyAuthentication(std::string &certifiedParam, const std::string &authParam)
{
- times_ += 1;
- nlohmann::json jsonObject = nlohmann::json::parse(authParam, nullptr, false);
- if (jsonObject.is_discarded()) {
- LOGE("DecodeRequestAuth jsonStr error");
- return DM_FAILED;
- }
- if (!jsonObject.contains(PIN_CODE_KEY) && !jsonObject.contains(PIN_TOKEN)) {
- LOGE("err json string, first time");
- return DM_FAILED;
- }
- int32_t inputPinCode = jsonObject[PIN_CODE_KEY];
- int32_t inputPinToken = jsonObject[PIN_TOKEN];
- if (code == inputPinCode && stoi(pinToken) == inputPinToken) {
+ // times_ += 1;
+ // nlohmann::json jsonObject = nlohmann::json::parse(authParam, nullptr, false);
+ // if (jsonObject.is_discarded()) {
+ // LOGE("DecodeRequestAuth jsonStr error");
+ // return DM_FAILED;
+ // }
+ // if (!jsonObject.contains(PIN_CODE_KEY) && !jsonObject.contains(PIN_TOKEN)) {
+ // LOGE("err json string, first time");
+ // return DM_FAILED;
+ // }
+ // int32_t inputPinCode = jsonObject[PIN_CODE_KEY];
+ // int32_t inputPinToken = jsonObject[PIN_TOKEN];
+ // if (code == inputPinCode && stoi(pinToken) == inputPinToken) {
+ // return DM_OK;
+ // } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) {
+ // return DM_AUTH_INPUT_FAILED;
+ // } else {
+ // return DM_FAILED;
+ // }
+ if (authParam == "0"){
return DM_OK;
- } else if (code != inputPinCode && times_ < MAX_VERIFY_TIMES) {
- return DM_AUTH_INPUT_FAILED;
- } else {
- return DM_FAILED;
}
+ return DM_FAILED;
+}
+
+int32_t PinAuth::ClosePage(int32_t pageId)
+{
+ return DM_OK;
}
extern "C" IAuthentication *CreatePinAuthObject(void)
diff --git a/ext/pin_auth/src/pin_auth_ui.cpp b/ext/pin_auth/src/pin_auth_ui.cpp
index 9fc3459cda10a015720e9c8184833825b398c14f..f570e14fc9427a4917ca8d4818cb1efc3b89957c 100644
--- a/ext/pin_auth/src/pin_auth_ui.cpp
+++ b/ext/pin_auth/src/pin_auth_ui.cpp
@@ -43,7 +43,7 @@ int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr au
ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
[authManager](int32_t id, const std::string& event, const std::string& params) {
if (strcmp(params.c_str(), "0") == 0) {
- authManager->ClosePage(id);
+ authManager->SetPageId(id);
}
if (strcmp(params.c_str(), "1") == 0) {
LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str());
@@ -68,14 +68,9 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a
OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
[authManager](int32_t id, const std::string& event, const std::string& params) {
- if (strcmp(params.c_str(), "2") == 0) {
- authManager->ClosePage(id);
- }
- if (strcmp(params.c_str(), "0") == 0 || strcmp(params.c_str(), "1") == 0) {
- 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());
- }
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
+ LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str());
+ authManager->VerifyAuthentication(params.c_str());
});
LOGI("ShowConfigDialog end");
return DM_OK;
diff --git a/ext/profile/BUILD.gn b/ext/profile/BUILD.gn
index 552653a03c2077c3eea4b5b85534e18fc34c5e57..9dfe54e45e01efe71194329923d12f68c5167a08 100644
--- a/ext/profile/BUILD.gn
+++ b/ext/profile/BUILD.gn
@@ -30,7 +30,15 @@ if (defined(ohos_lite)) {
"${ext_path}/profile/include",
"${services_path}/include",
"${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/standard",
"${services_path}/include/devicestate",
"${utils_path}/include",
@@ -38,11 +46,12 @@ if (defined(ohos_lite)) {
"${innerkits_path}/native_cpp/include",
"${innerkits_path}/native_cpp/include/ipc",
"${innerkits_path}/native_cpp/include/ipc/standard",
- "//foundation/communication/dsoftbus/interfaces/kits/bus_center",
- "//foundation/communication/dsoftbus/interfaces/kits/common",
- "//foundation/communication/dsoftbus/interfaces/kits/discovery",
- "//foundation/communication/dsoftbus/interfaces/kits/transport",
- "//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
+
+ "//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 = [
@@ -60,6 +69,7 @@ if (defined(ohos_lite)) {
"device_profile_core:distributed_device_profile_client",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
+ "dsoftbus_standard:softbus_client"
]
defines = [
diff --git a/ext/qr_code_auth/BUILD.gn b/ext/qr_code_auth/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..18337c5a7394759fb4149f12c02b95cebaa254fc
--- /dev/null
+++ b/ext/qr_code_auth/BUILD.gn
@@ -0,0 +1,105 @@
+# 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.
+
+if (defined(ohos_lite)) {
+ import("//build/lite/config/component/lite_component.gni")
+} else {
+ import("//build/ohos.gni")
+}
+
+import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
+
+if (defined(ohos_lite)) {
+} else {
+ ohos_shared_library("devicemanager_qrcodeauth") {
+ include_dirs = [
+ "include",
+ "${common_path}/include",
+ "${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 = [
+ "src/qr_code_auth.cpp",
+ ]
+
+ deps = [
+ "${utils_path}:devicemanagerutils",
+ "${services_path}:devicemanagerservice",
+ "${innerkits_path}/native_cpp:devicemanagersdk",
+ "${ext_path}/child_auth_ui/scan_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${ext_path}/child_auth_ui/show_qr_code_dialog/dialog_ui/js:dialog_js_files_etc",
+ "//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/ace/ace_engine/interfaces/innerkits/ui_service_manager:ui_service_mgr",
+ "//foundation/windowmanager/wm:libwm",
+ "//utils/native/base:utils",
+ ]
+
+ external_deps = [
+ "bundle_framework:appexecfwk_base",
+ "bundle_framework:appexecfwk_core",
+ "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 = [
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"devicemanagerext\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ subsystem_name = "distributedhardware"
+
+ part_name = "device_manager_base"
+ }
+}
diff --git a/ext/qr_code_auth/include/qr_code_auth.h b/ext/qr_code_auth/include/qr_code_auth.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf0ceecaadb86c0bebfc59cddef534d92b5c786e
--- /dev/null
+++ b/ext/qr_code_auth/include/qr_code_auth.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#ifndef OHOS_DM_QR_CODE_AUTH_H
+#define OHOS_DM_QR_CODE_AUTH_H
+
+#include
+#include
+
+#include "authentication.h"
+#include "dm_auth_manager.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+class QRCodeAuth : public IAuthentication, public std::enable_shared_from_this{
+public:
+ QRCodeAuth();
+ ~QRCodeAuth();
+ int32_t ShowAuthInfo(std::string &certifiedParam, std::shared_ptr authManager) override;
+ int32_t StartAuth(std::string &certifiedParam, std::shared_ptr authManager) override;
+ int32_t VerifyAuthentication(std::string &certifiedParam, const std::string &authParam) override;
+ int32_t ClosePage(int32_t pageId) override;
+};
+} // namespace DistributedHardware
+} // namespace OHOS
+#endif // OHOS_DM_QR_CODE_AUTH_H
\ No newline at end of file
diff --git a/ext/qr_code_auth/src/qr_code_auth.cpp b/ext/qr_code_auth/src/qr_code_auth.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f0fb71a7e936defd0c430c7b2822047be6afc9ae
--- /dev/null
+++ b/ext/qr_code_auth/src/qr_code_auth.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+#include "qr_code_auth.h"
+
+#include
+
+#include "dm_constants.h"
+#include "dm_log.h"
+#include "nlohmann/json.hpp"
+#include "ui_service_mgr_client.h"
+namespace OHOS {
+namespace DistributedHardware {
+QRCodeAuth::QRCodeAuth()
+{
+ LOGI("QRCodeAuth constructor");
+}
+
+QRCodeAuth::~QRCodeAuth()
+{
+}
+
+int32_t QRCodeAuth::ShowAuthInfo(std::string &certifiedParam, std::shared_ptr authManager)
+{
+ LOGI("ShowPinDialog start");
+ //定义字符串
+ nlohmann::json jsonObj;
+ jsonObj[TAG_CERTIFIED_PARAM] = certifiedParam;
+ jsonObj.dump();
+ const std::string params = jsonObj.dump();
+
+ Ace::UIServiceMgrClient::GetInstance()->ShowDialog(
+ "show_qr_code_dialog",
+ params,
+ OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
+ ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
+ [authManager](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());
+ if (event == "EVENT_INIT"){
+ authManager->SetPageId(id);
+ } else {
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
+ authManager->AuthenticateFinish();
+ }
+ });
+ LOGI("ShowConfigDialog end");
+ return DM_OK;
+}
+
+int32_t QRCodeAuth::StartAuth(std::string &certifiedParam, std::shared_ptr authManager)
+{
+ LOGI("InputPinDialog start");
+ //定义字符串
+ nlohmann::json jsonObj;
+ jsonObj[TAG_CERTIFIED_PARAM] = certifiedParam;
+ jsonObj.dump();
+ const std::string params = jsonObj.dump();
+
+ Ace::UIServiceMgrClient::GetInstance()->ShowDialog(
+ "scan_service",
+ params,
+ OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
+ ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
+ [authManager](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());
+ if (event == "EVENT_INIT"){
+ authManager->SetPageId(id);
+ } else if(event == "EVENT_CONFIRM"){
+ authManager->VerifyAuthentication(params);
+ } else {
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
+ authManager->AuthenticateFinish();
+ }
+ });
+ LOGI("ShowConfigDialog end");
+ return DM_OK;
+}
+
+int32_t QRCodeAuth::VerifyAuthentication(std::string &certifiedParam, const std::string &authParam)
+{
+ if (certifiedParam == authParam){
+ return DM_OK;
+ }
+ return DM_FAILED;
+}
+
+int32_t QRCodeAuth::ClosePage(int32_t pageId)
+{
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(pageId);
+ return DM_OK;
+}
+
+extern "C" IAuthentication *CreateQRcodeAuthObject(void)
+{
+ return new QRCodeAuth;
+}
+} // namespace DistributedHardware
+} // namespace OHOS
diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp
index bb96c37a7044c5a55a282bc3077f4f9ed3ee30f6..5823b97d6a1792280afc11dfe5a2b3825e1a6f65 100644
--- a/interfaces/kits/js/src/native_devicemanager_js.cpp
+++ b/interfaces/kits/js/src/native_devicemanager_js.cpp
@@ -1491,8 +1491,8 @@ napi_value DeviceManagerNapi::AuthenticateDevice(napi_env env, napi_callback_inf
JsToDmDeviceInfo(env, argv[0], deviceInfo);
std::string extraString;
JsToDmExtra(env, argv[PARAM_INDEX_ONE], extraString, authAsyncCallbackInfo_.authType);
- int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(deviceManagerWrapper->bundleName_, 1, deviceInfo,
- extraString, authCallback);
+ int32_t ret = DeviceManager::GetInstance().AuthenticateDevice(deviceManagerWrapper->bundleName_,
+ authAsyncCallbackInfo_.authType, deviceInfo, extraString, authCallback);
if (ret != 0) {
LOGE("AuthenticateDevice for bundleName %s failed, ret %d", deviceManagerWrapper->bundleName_.c_str(), ret);
}
diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn
index cde4b3193c839c7d977c0188478d1d6adbfb58ef..4e798afa5d234e01b2d92a5039832fc5f8e136ab 100644
--- a/services/devicemanagerservice/BUILD.gn
+++ b/services/devicemanagerservice/BUILD.gn
@@ -23,10 +23,6 @@ if (defined(ohos_lite)) {
executable("devicemanagerservice") {
sources = [ "src/ipc/lite/ipc_server_main.cpp" ]
}
-} else if (!support_jsapi) {
- group("devicemanagerservice") {
- deps = []
- }
} else {
config("devicemanagerservice_config") {
include_dirs = [
diff --git a/services/devicemanagerservice/include/authentication/authentication.h b/services/devicemanagerservice/include/authentication/authentication.h
index 67ca0c3ee86b1e0fccae4eb20927cda40dc3a829..c7f48b1f685ac2ee81565bfa04dfb6604243c481 100644
--- a/services/devicemanagerservice/include/authentication/authentication.h
+++ b/services/devicemanagerservice/include/authentication/authentication.h
@@ -16,17 +16,16 @@
#ifndef OHOS_DM_AUTHENTICATION_H
#define OHOS_DM_AUTHENTICATION_H
-#include "dm_ability_manager.h"
-
namespace OHOS {
namespace DistributedHardware {
class DmAuthManager;
class IAuthentication {
public:
virtual ~IAuthentication() = default;
- virtual int32_t ShowAuthInfo(int32_t code, std::shared_ptr authManager) = 0;
- virtual int32_t StartAuth(int32_t code, std::shared_ptr authManager) = 0;
- virtual int32_t VerifyAuthentication(std::string pinToken, int32_t code, const std::string &authParam) = 0;
+ virtual int32_t ShowAuthInfo(std::string &certifiedParam, std::shared_ptr authManager) = 0;
+ virtual int32_t StartAuth(std::string &certifiedParam, std::shared_ptr authManager) = 0;
+ virtual int32_t VerifyAuthentication(std::string &certifiedParam, const std::string &authParam) = 0;
+ virtual int32_t ClosePage(int32_t pageId) = 0;
};
using CreateIAuthAdapterFuncPtr = IAuthentication *(*)(void);
diff --git a/services/devicemanagerservice/include/authentication/dm_auth_manager.h b/services/devicemanagerservice/include/authentication/dm_auth_manager.h
index 6a7ae6b85aeb7a5a7f90f58e97bf559765801835..ce30b3f3c4f8897b5e3542bd85dc2ee8856c912c 100644
--- a/services/devicemanagerservice/include/authentication/dm_auth_manager.h
+++ b/services/devicemanagerservice/include/authentication/dm_auth_manager.h
@@ -86,7 +86,6 @@ typedef struct DmAuthRequestContext {
std::string appThumbnail;
std::string token;
int32_t reason;
- int32_t aceId;
std::vector syncGroupList;
} DmAuthRequestContext;
@@ -110,10 +109,11 @@ typedef struct DmAuthResponseContext {
std::string appIcon;
std::string appThumbnail;
std::string token;
+ std::string certifiedParam;
+ int32_t pageId;
int64_t requestId;
int32_t code;
int32_t state;
- int32_t aceId;
std::vector syncGroupList;
} DmAuthResponseContext;
@@ -131,7 +131,6 @@ 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);
@@ -161,10 +160,10 @@ public:
void ShowConfigDialog();
void ShowAuthInfoDialog();
void ShowStartAuthDialog();
+ int32_t SetPageId(int32_t pageId);
int32_t GetAuthenticationParam(DmAuthParam &authParam);
int32_t OnUserOperation(int32_t action);
- void UserSwitchEventCallback(int32_t userId);
- void ClosePage(const int32_t &id);
+ void UserSwitchEventCallback (int32_t userId);
private:
std::shared_ptr softbusConnector_;
diff --git a/services/devicemanagerservice/include/dependency/hichain/hichain_connector.h b/services/devicemanagerservice/include/dependency/hichain/hichain_connector.h
index 99d534f6ef6ee9d3749494be63c4dde0d2d5c170..9742a347fc8c663930ad401243e33352dc887d5f 100644
--- a/services/devicemanagerservice/include/dependency/hichain/hichain_connector.h
+++ b/services/devicemanagerservice/include/dependency/hichain/hichain_connector.h
@@ -59,11 +59,12 @@ public:
int32_t AddMember(std::string deviceId, std::string &connectInfo);
int32_t DelMemberFromGroup(std::string groupId, std::string deviceId);
int32_t DeleteGroup(std::string &groupId);
- int32_t DeleteGroup(const int32_t userId, std::string &groupId);
bool IsDevicesInGroup(std::string hostDevice, std::string peerDevice);
int32_t GetRelatedGroups(std::string DeviceId, std::vector &groupList);
int32_t GetGroupInfo(std::string queryParams, std::vector &groupList);
int32_t GetGroupInfo(const int32_t userId, std::string queryParams, std::vector &groupList);
+ int32_t DeleteGroup(const int32_t userId, std::string &groupId);
+ int32_t DeleteTimeOutGroup(const char* deviceId);
private:
int64_t GenRequestId();
int32_t SyncGroups(std::string deviceId, std::vector &remoteGroupIdList);
diff --git a/services/devicemanagerservice/include/dependency/timer/dm_timer.h b/services/devicemanagerservice/include/dependency/timer/dm_timer.h
index 4bf8896edcd10ac5bf90e61e9a438316210289f1..84c3f6c290af9a99ca9195c44be46720c4ed0aa3 100644
--- a/services/devicemanagerservice/include/dependency/timer/dm_timer.h
+++ b/services/devicemanagerservice/include/dependency/timer/dm_timer.h
@@ -29,9 +29,11 @@
namespace OHOS {
namespace DistributedHardware {
+class DmTimer;
typedef void (*TimeoutHandle)(void *data);
+typedef void (*TimerHandle)(const DmTimer &timer);
-#define MAX_EVENTS 255
+#define MAXEVENTS 255
enum DmTimerStatus : int32_t {
DM_STATUS_INIT = 0,
@@ -46,8 +48,38 @@ public:
DmTimer(const std::string &name);
~DmTimer();
DmTimerStatus Start(uint32_t timeOut, TimeoutHandle handle, void *data);
+ template
+ DmTimerStatus Start(uint32_t timeOut, TimerHandle handle, T *data)
+ {
+ if (mTimerName_.empty() || handle == nullptr || data == nullptr) {
+ LOGI("DmTimer is not init or param empty");
+ return DmTimerStatus::DM_STATUS_FINISH;
+ }
+ LOGI("DmTimer %s start timeout(%d)", mTimerName_.c_str(), timeOut);
+ if (mStatus_ != DmTimerStatus::DM_STATUS_INIT) {
+ return DmTimerStatus::DM_STATUS_BUSY;
+ }
+
+ mTimeOutSec_ = timeOut;
+ mTimerHandle_ = handle;
+ owner = data;
+
+ if (CreateTimeFd()) {
+ return DmTimerStatus::DM_STATUS_CREATE_ERROR;
+ }
+
+ mStatus_ = DmTimerStatus::DM_STATUS_RUNNING;
+ mThread_ = std::thread(&DmTimer::WiteforTimeout, this);
+ mThread_.detach();
+
+ return mStatus_;
+ };
+
void Stop(int32_t code);
- void WaitForTimeout();
+ void WiteforTimeout();
+
+public:
+ void *owner;
private:
int32_t CreateTimeFd();
@@ -57,10 +89,12 @@ private:
DmTimerStatus mStatus_;
uint32_t mTimeOutSec_;
TimeoutHandle mHandle_;
+ TimerHandle mTimerHandle_;
+ void *mHandleOutData_;
void *mHandleData_;
int32_t mTimeFd_[2];
struct epoll_event mEv_;
- struct epoll_event mEvents_[MAX_EVENTS];
+ struct epoll_event mEvents_[MAXEVENTS];
int32_t mEpFd_;
std::thread mThread_;
std::string mTimerName_;
diff --git a/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h b/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h
index a54ef47ef12102bd5a5d4838bd135757e0b7e488..cdd78c9159b73871659135732805ccf114a79dff 100644
--- a/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h
+++ b/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h
@@ -19,14 +19,29 @@
#include "device_manager_service_listener.h"
#include "dm_adapter_manager.h"
#include "softbus_connector.h"
-
+#include "dm_timer.h"
+#include "hichain_connector.h"
namespace OHOS {
namespace DistributedHardware {
+class HmDevice {
+public:
+ HmDevice(std::string deviceId, std::shared_ptr stateMgr);
+ ~HmDevice();
+
+public:
+ std::string mDeviceId;
+ std::map mGroupMap;
+ std::shared_ptr mOfflineTimerPtr;
+ std::shared_ptr deviceStateMgr;
+};
+
+#define OFFLINE_TIMEOUT 300
class DmDeviceStateManager final : public ISoftbusStateCallback,
public std::enable_shared_from_this {
public:
DmDeviceStateManager(std::shared_ptr softbusConnector,
- std::shared_ptr listener);
+ std::shared_ptr listener,
+ std::shared_ptr hiChainConnector);
~DmDeviceStateManager();
void OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &info);
void OnDeviceOffline(const std::string &pkgName, const DmDeviceInfo &info);
@@ -34,6 +49,9 @@ public:
void OnDeviceReady(const std::string &pkgName, const DmDeviceInfo &info);
void OnProfileReady(const std::string &pkgName, const std::string deviceId);
int32_t RegisterSoftbusStateCallback();
+ void OnDeviceOnline(const DmDeviceInfo &deviceInfo);
+ void OnDeviceOffline(const DmDeviceInfo &deviceInfo);
+ void RmHichainGroup(HmDevice *hmDevice);
private:
std::shared_ptr softbusConnector_;
@@ -41,7 +59,10 @@ private:
std::shared_ptr listener_;
std::map deviceStateMap_;
std::map remoteDeviceInfos_;
+ std::map> timerMap_;
+ std::shared_ptr hiChainConnector_;
std::string profileSoName_;
+ std::map mHmDeviceMap_ = {};
};
} // namespace DistributedHardware
} // namespace OHOS
diff --git a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp
index 9ba556f4a188c3e4bf57fd6ff8f48da531b2ad7a..8f5228f3702dfaf50e49140302ae421fb93f9f20 100644
--- a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp
+++ b/services/devicemanagerservice/src/authentication/auth_message_processor.cpp
@@ -146,6 +146,7 @@ void AuthMessageProcessor::CreateResponseAuthMessage(nlohmann::json &json)
json[TAG_REQUEST_ID] = authResponseContext_->requestId;
json[TAG_GROUP_ID] = groupId;
json[TAG_GROUP_NAME] = authResponseContext_->groupName;
+ json[TAG_CERTIFIED_PARAM] = authResponseContext_->certifiedParam;
LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s,%s", groupId.c_str(),
authResponseContext_->groupName.c_str());
}
@@ -225,6 +226,7 @@ void AuthMessageProcessor::ParseAuthResponseMessage(nlohmann::json &json)
authResponseContext_->requestId = json[TAG_REQUEST_ID];
authResponseContext_->groupId = json[TAG_GROUP_ID];
authResponseContext_->groupName = json[TAG_GROUP_NAME];
+ authResponseContext_->certifiedParam = json[TAG_CERTIFIED_PARAM];
LOGI("AuthMessageProcessor::ParseAuthResponseMessage %s,%s", authResponseContext_->groupId.c_str(),
authResponseContext_->groupName.c_str());
}
diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp
index dfe504b5c30c43ce160c5ee2c1543e8abcbbef50..5c450188922c6d25e1a5c9fd704c7f7af17acdeb 100644
--- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp
+++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp
@@ -80,7 +80,8 @@ DmAuthManager::~DmAuthManager()
int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId,
const std::string &extra)
{
- LOGE("DmAuthManager::AuthenticateDevice start");
+ LOGE("DmAuthManager::AuthenticateDevice start auth type %d", authType);
+ LOGE("DmAuthManager::AuthenticateDevice start auth type %d", authenticationMap_.size());
std::shared_ptr authentication = authenticationMap_[authType];
if (authentication == nullptr) {
LOGE("DmAuthManager::AuthenticateDevice authType %d not support.", authType);
@@ -178,22 +179,18 @@ int32_t DmAuthManager::VerifyAuthentication(const std::string &authParam)
timerMap_[INPUT_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT);
std::shared_ptr ptr;
- if (authenticationMap_.find(1) == authenticationMap_.end()) {
+ if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) {
LOGE("DmAuthManager::authenticationMap_ is null");
return DM_FAILED;
}
- ptr = authenticationMap_[1];
- int32_t ret = ptr->VerifyAuthentication(authRequestContext_->token, authResponseContext_->code, authParam);
+
+ ptr = authenticationMap_[authResponseContext_->authType];
+ int32_t ret = ptr->VerifyAuthentication(authResponseContext_->certifiedParam, authParam);
switch (ret) {
case DM_OK:
authRequestState_->TransitionTo(std::make_shared());
break;
- case DM_AUTH_INPUT_FAILED:
- listener_->OnVerifyAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId,
- DM_AUTH_INPUT_FAILED, "");
- break;
default:
- CancelDisplay();
authRequestContext_->reason = DM_AUTH_INPUT_FAILED;
authResponseContext_->state = authRequestState_->GetStateType();
authRequestState_->TransitionTo(std::make_shared());
@@ -336,6 +333,8 @@ void DmAuthManager::OnGroupCreated(int64_t requestId, const std::string &groupId
void DmAuthManager::OnMemberJoin(int64_t requestId, int32_t status)
{
+ LOGI("DmAuthManager OnMemberJoin start");
+ CancelDisplay();
LOGE("DmAuthManager OnMemberJoin start");
if (authRequestState_ != nullptr) {
timerMap_[ADD_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT);
@@ -520,7 +519,7 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId)
return DM_FAILED;
}
LOGI("DmAuthManager::authRequestContext CancelDisplay start");
- Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->aceId);
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId);
return DM_OK;
}
@@ -547,7 +546,7 @@ void DmAuthManager::AuthenticateFinish()
LOGI("DmAuthManager::AuthenticateFinish start");
if (authResponseState_ != nullptr) {
if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH) {
- Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->aceId);
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId);
}
if (!timerMap_.empty()) {
for (auto &iter : timerMap_) {
@@ -569,7 +568,7 @@ void DmAuthManager::AuthenticateFinish()
}
if (authResponseContext_->state == AuthState::AUTH_REQUEST_INPUT) {
- Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->aceId);
+ CancelDisplay();
}
listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId,
@@ -680,26 +679,38 @@ void DmAuthManager::ShowConfigDialog()
void DmAuthManager::ShowAuthInfoDialog()
{
LOGI("DmAuthManager::ShowAuthInfoDialog start");
+ if (authResponseContext_->authType == 1) {
+ authResponseContext_->certifiedParam = std::to_string(authResponseContext_->code);
+ } else {
+ authResponseContext_->certifiedParam = GenerateGroupName();
+ }
+
std::shared_ptr ptr;
- if (authenticationMap_.find(1) == authenticationMap_.end()) {
+ if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) {
LOGE("DmAuthManager::authenticationMap_ is null");
return;
}
- ptr = authenticationMap_[1];
+ ptr = authenticationMap_[authResponseContext_->authType];
LOGI("ShowAuthInfoDialog code:%d", authResponseContext_->code);
- ptr->ShowAuthInfo(authResponseContext_->code, shared_from_this());
+ ptr->ShowAuthInfo(authResponseContext_->certifiedParam, shared_from_this());
}
void DmAuthManager::ShowStartAuthDialog()
{
LOGI("DmAuthManager::ShowStartAuthDialog start");
std::shared_ptr ptr;
- if (authenticationMap_.find(1) == authenticationMap_.end()) {
+ if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) {
LOGE("DmAuthManager::authenticationMap_ is null");
return;
}
- ptr = authenticationMap_[1];
- ptr->StartAuth(authResponseContext_->code, shared_from_this());
+ ptr = authenticationMap_[authResponseContext_->authType];
+ ptr->StartAuth(authResponseContext_->certifiedParam, shared_from_this());
+}
+
+int32_t DmAuthManager::SetPageId(int32_t pageId)
+{
+ authResponseContext_->pageId = pageId;
+ return DM_OK;
}
int32_t DmAuthManager::GetAuthenticationParam(DmAuthParam &authParam)
@@ -783,25 +794,5 @@ void DmAuthManager::UserSwitchEventCallback (int32_t userId)
}
}
}
-
-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");
-}
-
-void DmAuthManager::ClosePage(const int32_t &id)
-{
- authResponseContext_->aceId = id;
-}
} // namespace DistributedHardware
} // namespace OHOS
diff --git a/services/devicemanagerservice/src/config/dm_config_manager.cpp b/services/devicemanagerservice/src/config/dm_config_manager.cpp
index b91a09276adbacb0105ada63d00fb711f43f172c..3b382f5967cd8a653269cb3f57864a6c71b4d024 100644
--- a/services/devicemanagerservice/src/config/dm_config_manager.cpp
+++ b/services/devicemanagerservice/src/config/dm_config_manager.cpp
@@ -284,7 +284,14 @@ void DmConfigManager::GetAuthAdapter(std::mapsecond).funcName.c_str());
auto func = (CreateIAuthAdapterFuncPtr)dlsym(so_handle, (iter->second).funcName.c_str());
+ if (dlerror() != nullptr) {
+ LOGE("Create object function is not exist 1");
+ }
+ if (func == nullptr) {
+ LOGE("Create object function is not exist 2");
+ }
if (dlerror() != nullptr || func == nullptr) {
LOGE("Create object function is not exist");
continue;
diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp
index 22a50c39d2031d6ae48e308e4d656ebe56fbfa3d..990509de1a2c4f029ae36556e502cdd8e3141426 100644
--- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp
+++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp
@@ -490,5 +490,26 @@ int32_t HiChainConnector::DeleteGroup(const int32_t userId, std::string &groupId
}
return DM_OK;
}
+
+int32_t HiChainConnector::DeleteTimeOutGroup(const char* deviceId)
+{
+ LOGE("HiChainConnector::DeleteTimeOutGroup start");
+ int32_t userId = MultipleUserConnector::GetCurrentAccountUserID();
+ if (userId < 0) {
+ LOGE("get current process account user id failed");
+ return DM_FAILED;
+ }
+ std::vector peerGroupInfoList;
+ GetRelatedGroups(deviceId, peerGroupInfoList);
+ char localDeviceId[DEVICE_UUID_LENGTH] = {0};
+ GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH);
+ for (auto &group : peerGroupInfoList){
+ if (deviceGroupManager_->isDeviceInGroup(userId, DM_PKG_NAME.c_str(), group.groupId.c_str(), localDeviceId)){
+ DeleteGroup(group.groupId);
+ return DM_OK;
+ }
+ }
+ return DM_FAILED;
+}
} // namespace DistributedHardware
} // namespace OHOS
diff --git a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp
index a33034f48a1ba692dd046fe310998c54a148f65d..72cdc15f57761715e29c9130ee4c7eed6979f9e6 100644
--- a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp
+++ b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp
@@ -33,6 +33,7 @@ DmTimer::DmTimer(const std::string &name)
mStatus_ = DmTimerStatus::DM_STATUS_INIT;
mTimeOutSec_ = 0;
mHandle_ = nullptr;
+ mTimerHandle_ = nullptr;
mHandleData_ = nullptr;
(void)memset_s(mTimeFd_, sizeof(mTimeFd_), 0, sizeof(mTimeFd_));
(void)memset_s(&mEv_, sizeof(mEv_), 0, sizeof(mEv_));
@@ -64,14 +65,14 @@ DmTimerStatus DmTimer::Start(uint32_t timeOut, TimeoutHandle handle, void *data)
mTimeOutSec_ = timeOut;
mHandle_ = handle;
- mHandleData_ = data;
+ mHandleOutData_ = data;
if (CreateTimeFd()) {
return DmTimerStatus::DM_STATUS_CREATE_ERROR;
}
mStatus_ = DmTimerStatus::DM_STATUS_RUNNING;
- mThread_ = std::thread(&DmTimer::WaitForTimeout, this);
+ mThread_ = std::thread(&DmTimer::WiteforTimeout, this);
mThread_.detach();
return mStatus_;
@@ -96,17 +97,20 @@ void DmTimer::Stop(int32_t code)
return;
}
-void DmTimer::WaitForTimeout()
+void DmTimer::WiteforTimeout()
{
if (mTimerName_.empty()) {
LOGI("DmTimer is not init");
return;
}
LOGI("DmTimer %s start timer at (%d)s", mTimerName_.c_str(), mTimeOutSec_);
-
- int32_t nfds = epoll_wait(mEpFd_, mEvents_, MAX_EVENTS, mTimeOutSec_ * MILL_SECONDS_PER_SECOND);
+ int32_t nfds = epoll_wait(mEpFd_, mEvents_, MAXEVENTS, mTimeOutSec_ * MILL_SECONDS_PER_SECOND);
if (nfds < 0) {
LOGE("DmTimer %s epoll_wait returned n=%d, error: %d", mTimerName_.c_str(), nfds, errno);
+ if (errno == 4) {
+ LOGI("DmTimer is stop");
+ return;
+ }
}
char event = 0;
@@ -123,7 +127,10 @@ void DmTimer::WaitForTimeout()
return;
}
- mHandle_(mHandleData_);
+ if (mHandle_)
+ mHandle_(mHandleOutData_);
+ if (mTimerHandle_)
+ mTimerHandle_(*this);
Release();
LOGE("DmTimer %s end timer at (%d)s", mTimerName_.c_str(), mTimeOutSec_);
@@ -147,7 +154,7 @@ int32_t DmTimer::CreateTimeFd()
mEv_.data.fd = mTimeFd_[0];
mEv_.events = EPOLLIN | EPOLLET;
- mEpFd_ = epoll_create(MAX_EVENTS);
+ mEpFd_ = epoll_create(MAXEVENTS);
ret = epoll_ctl(mEpFd_, EPOLL_CTL_ADD, mTimeFd_[0], &mEv_);
if (ret != 0) {
Release();
diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp
index 8a02d72652ff492a4d90a471db1de89b8175c9a4..88541338f4102005d69adf7b9ed465ce023482a4 100644
--- a/services/devicemanagerservice/src/device_manager_service.cpp
+++ b/services/devicemanagerservice/src/device_manager_service.cpp
@@ -77,7 +77,7 @@ int32_t DeviceManagerService::Init()
}
}
if (deviceStateMgr_ == nullptr) {
- deviceStateMgr_ = std::make_shared(softbusConnector_, listener_);
+ deviceStateMgr_ = std::make_shared(softbusConnector_, listener_, hiChainConnector_);
if (deviceStateMgr_ == nullptr) {
LOGE("Init failed, deviceStateMgr_ apply for failure");
return DM_MAKE_SHARED_FAIL;
diff --git a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp b/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp
index 8fc7214ac674ccef47a525787d456057e7b471c0..1cf0753f7b848ab75f28c14cc534edc2cca2925f 100644
--- a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp
+++ b/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp
@@ -20,9 +20,21 @@
#include "dm_log.h"
namespace OHOS {
namespace DistributedHardware {
+static void TimeOut(const DmTimer &timer)
+{
+ LOGE("time out ");
+ if (timer.owner == nullptr) {
+ LOGE("OnDeviceOfflineTimeOut hmDevice owner = nullptr");
+ return;
+ }
+ std::shared_ptr deviceStateMgr = ((HmDevice *)timer.owner)->deviceStateMgr;
+ deviceStateMgr->RmHichainGroup((HmDevice *)timer.owner);
+}
+
DmDeviceStateManager::DmDeviceStateManager(std::shared_ptr softbusConnector,
- std::shared_ptr listener)
- : softbusConnector_(softbusConnector), listener_(listener)
+ std::shared_ptr listener,
+ std::shared_ptr hiChainConnector)
+ : softbusConnector_(softbusConnector), listener_(listener), hiChainConnector_(hiChainConnector)
{
LOGI("DmDeviceStateManager constructor");
profileSoName_ = "libdevicemanagerext_profile.z.so";
@@ -37,6 +49,7 @@ DmDeviceStateManager::~DmDeviceStateManager()
void DmDeviceStateManager::OnDeviceOnline(const std::string &pkgName, const DmDeviceInfo &info)
{
LOGI("DmDeviceStateManager::OnDeviceOnline in");
+ OnDeviceOnline(info);
DmAdapterManager &adapterMgrPtr = DmAdapterManager::GetInstance();
std::shared_ptr profileAdapter = adapterMgrPtr.GetProfileAdapter(profileSoName_);
if (profileAdapter == nullptr) {
@@ -66,6 +79,7 @@ void DmDeviceStateManager::OnDeviceOnline(const std::string &pkgName, const DmDe
void DmDeviceStateManager::OnDeviceOffline(const std::string &pkgName, const DmDeviceInfo &info)
{
+ OnDeviceOffline(info);
DmAdapterManager &adapterMgrPtr = DmAdapterManager::GetInstance();
std::shared_ptr profileAdapter = adapterMgrPtr.GetProfileAdapter(profileSoName_);
if (profileAdapter == nullptr) {
@@ -113,5 +127,51 @@ int32_t DmDeviceStateManager::RegisterSoftbusStateCallback()
std::shared_ptr(shared_from_this()));
return DM_OK;
}
+
+void DmDeviceStateManager::OnDeviceOnline(const DmDeviceInfo &deviceInfo)
+{
+ std::string deviceId;
+ softbusConnector_->GetUdidByNetworkId(deviceInfo.deviceId, deviceId);
+ LOGI("Device<%s>Online", deviceId.c_str());
+ auto iter = mHmDeviceMap_.find(deviceId);
+ if (iter != mHmDeviceMap_.end()) {
+ iter->second->mOfflineTimerPtr->Stop(0);
+ return;
+ }
+
+ HmDevice *hmDevice = new HmDevice(deviceId, shared_from_this());
+ mHmDeviceMap_[hmDevice->mDeviceId] = hmDevice;
+}
+
+void DmDeviceStateManager::OnDeviceOffline(const DmDeviceInfo &deviceInfo)
+{
+ std::string deviceId;
+ softbusConnector_->GetUdidByNetworkId(deviceInfo.deviceId, deviceId);
+ LOGI("Device<%s>Offline", deviceId.c_str());
+ for (auto &iter : mHmDeviceMap_) {
+ if (iter.second->mDeviceId.compare(deviceId) == 0) {
+ iter.second->mOfflineTimerPtr->Start(OFFLINE_TIMEOUT, TimeOut, iter.second);
+ }
+ }
+}
+
+void DmDeviceStateManager::RmHichainGroup(HmDevice *hmDevice)
+{
+ LOGI("Remove DmDevice<%s> Hichain Group", hmDevice->mDeviceId.c_str());
+ hiChainConnector_->DeleteTimeOutGroup(hmDevice->mDeviceId.c_str());
+}
+
+HmDevice::HmDevice(std::string deviceId, std::shared_ptr stateMgr)
+{
+ mDeviceId = deviceId;
+ std::string timerName = "HmDeviceTimer";
+ mOfflineTimerPtr = std::make_shared(timerName);
+ deviceStateMgr = stateMgr;
+}
+
+HmDevice::~HmDevice()
+{
+ mOfflineTimerPtr = nullptr;
+}
} // namespace DistributedHardware
} // namespace OHOS