diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000000000000000000000000000000000000..0e1c7b4f24c262655fbd42678820e923cdcced55
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,83 @@
+{
+ "files.associations": {
+ "xstring": "cpp",
+ "algorithm": "cpp",
+ "atomic": "cpp",
+ "bit": "cpp",
+ "cctype": "cpp",
+ "charconv": "cpp",
+ "chrono": "cpp",
+ "cinttypes": "cpp",
+ "clocale": "cpp",
+ "cmath": "cpp",
+ "compare": "cpp",
+ "concepts": "cpp",
+ "condition_variable": "cpp",
+ "cstddef": "cpp",
+ "cstdint": "cpp",
+ "cstdio": "cpp",
+ "cstdlib": "cpp",
+ "cstring": "cpp",
+ "ctime": "cpp",
+ "cwchar": "cpp",
+ "deque": "cpp",
+ "exception": "cpp",
+ "coroutine": "cpp",
+ "resumable": "cpp",
+ "format": "cpp",
+ "forward_list": "cpp",
+ "fstream": "cpp",
+ "functional": "cpp",
+ "future": "cpp",
+ "initializer_list": "cpp",
+ "iomanip": "cpp",
+ "ios": "cpp",
+ "iosfwd": "cpp",
+ "iostream": "cpp",
+ "istream": "cpp",
+ "iterator": "cpp",
+ "limits": "cpp",
+ "list": "cpp",
+ "locale": "cpp",
+ "map": "cpp",
+ "memory": "cpp",
+ "mutex": "cpp",
+ "new": "cpp",
+ "optional": "cpp",
+ "ostream": "cpp",
+ "queue": "cpp",
+ "random": "cpp",
+ "ratio": "cpp",
+ "set": "cpp",
+ "shared_mutex": "cpp",
+ "sstream": "cpp",
+ "stdexcept": "cpp",
+ "stop_token": "cpp",
+ "streambuf": "cpp",
+ "string": "cpp",
+ "system_error": "cpp",
+ "thread": "cpp",
+ "tuple": "cpp",
+ "type_traits": "cpp",
+ "typeinfo": "cpp",
+ "unordered_map": "cpp",
+ "unordered_set": "cpp",
+ "utility": "cpp",
+ "vector": "cpp",
+ "xfacet": "cpp",
+ "xhash": "cpp",
+ "xiosbase": "cpp",
+ "xlocale": "cpp",
+ "xlocbuf": "cpp",
+ "xlocinfo": "cpp",
+ "xlocmes": "cpp",
+ "xlocmon": "cpp",
+ "xlocnum": "cpp",
+ "xloctime": "cpp",
+ "xmemory": "cpp",
+ "xstddef": "cpp",
+ "xtr1common": "cpp",
+ "xtree": "cpp",
+ "xutility": "cpp"
+ }
+}
\ No newline at end of file
diff --git a/OAT.xml b/OAT.xml
index 175029b2d063f85b64dd36ae379f0ca8095b44d3..0bb9efb68d08c857565b76b2d1f6f8d6a0a8c7a8 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -59,6 +59,7 @@ Note:If the text contains special characters, please escape them according to th
+
diff --git a/application/AppScope/app.json b/application/AppScope/app.json
index 9b8224c9b242aea7472f8b72a746efc243e4da67..b90f13024e23830dcfa22f9a1e81270d709dfff6 100644
--- a/application/AppScope/app.json
+++ b/application/AppScope/app.json
@@ -2,8 +2,8 @@
"app": {
"bundleName": "com.ohos.dhardwareui",
"vendor": "example",
- "versionCode": 1000001,
- "versionName": "1.0.1",
+ "versionCode": 1000002,
+ "versionName": "1.0.2",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 11,
diff --git a/application/AppScope/app.json5 b/application/AppScope/app.json5
index 1b0c42e73a6c72efa65a8e52183f9593d6dbe1ed..69262b14fbbf94a6202aaea50b1b66358f7ed5d5 100644
--- a/application/AppScope/app.json5
+++ b/application/AppScope/app.json5
@@ -16,8 +16,8 @@
"app": {
"bundleName": "com.ohos.dhardwareui",
"vendor": "example",
- "versionCode": 1000001,
- "versionName": "1.0.1",
+ "versionCode": 1000002,
+ "versionName": "1.0.2",
"icon": "$media:app_icon",
"label": "$string:app_name",
"minAPIVersion": 11,
diff --git a/application/entry/hvigorfile.ts b/application/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..1c4ceb9ee290c3fb187f02280a303b0892c91438
--- /dev/null
+++ b/application/entry/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2024 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 { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+};
diff --git a/application/entry/src/main/resources/bo_CN/element/string.json b/application/entry/src/main/resources/bo_CN/element/string.json
index cb47ab55496585d1b718c060914c40cd4dcef4e0..6bd9656c75e6169a8297b9a8d8014ed7bd806c5c 100644
--- a/application/entry/src/main/resources/bo_CN/element/string.json
+++ b/application/entry/src/main/resources/bo_CN/element/string.json
@@ -27,6 +27,14 @@
{
"name":"continue",
"value":"མུ་མཐུད།"
+ },
+ {
+ "name":"continue_desc",
+ "value":"སྒྲིག་ཆས་གཅིག་གི་ཐོག་ཏུ་བཤར་ལྟ་དང་རྩོམ་སྒྲིག་བྱས་རྗེས། ཉེ་འགྲམ་གྱི་ཧྭ་ཝེ་ཐོ་ཨང་གཅིག་པ་ཐོ་འཇུག་བྱས་ཡོད་པའི་སྒྲིག་ཆས་ཐོག་ཏུ་མུ་མཐུད་ཆོག རྩོལ་ནུས་འདི་བཀོལ་སྤྱོད་བྱ་བར་ཕྱོགས་གཉིས་པོས་༼འཕྲོ་མཐུད་༽ Wi-Fi དང་ སོ་སྔོན་ཁ་ཕྱེ་ནས་གནས་དགོས།"
+ },
+ {
+ "name":"continue_title",
+ "value":"འཕྲོ་མཐུད།"
}
]
}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/mcc460-bo_CN/element/string.json b/application/entry/src/main/resources/mcc460-bo_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..284cee98ad0c7e49c637d6816615054beb5b87c9
--- /dev/null
+++ b/application/entry/src/main/resources/mcc460-bo_CN/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string":[
+ {
+ "name":"continue_desc",
+ "value":"སྒྲིག་ཆས་གཅིག་གི་ཐོག་ཏུ་བཤར་ལྟ་དང་རྩོམ་སྒྲིག་བྱས་རྗེས། ཉེ་འགྲམ་གྱི་ཧྭ་ཝེ་ཐོ་ཨང་གཅིག་པ་ཐོ་འཇུག་བྱས་ཡོད་པའི་སྒྲིག་ཆས་ཐོག་ཏུ་མུ་མཐུད་ཆོག རྩོལ་ནུས་འདི་བཀོལ་སྤྱོད་བྱ་བར་ཕྱོགས་གཉིས་པོས་༼འཕྲོ་མཐུད་༽ WLAN དང་ སོ་སྔོན་ཁ་ཕྱེ་ནས་གནས་དགོས།"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/mcc460-en/element/string.json b/application/entry/src/main/resources/mcc460-en/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b55ac3207847bac5c87083111210bd6ec4d79f38
--- /dev/null
+++ b/application/entry/src/main/resources/mcc460-en/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string":[
+ {
+ "name":"continue_desc",
+ "value":"Browse or edit on one device, then continue on another nearby device logged in with the same Huawei ID. This function requires that both devices have enabled \"Application connection,\" WLAN, and Bluetooth."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/mcc460-ug/element/string.json b/application/entry/src/main/resources/mcc460-ug/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..985e2152ff6e4c5c78f1d6b2c19fb32586fdcce9
--- /dev/null
+++ b/application/entry/src/main/resources/mcc460-ug/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string":[
+ {
+ "name":"continue_desc",
+ "value":"بىر ئۈسكۈنىدە كۆرۈۋاتقان ياكى تەھرىرلەۋاتقان ئىشنى ئەتراپتىكى ئوخشاش خۇاۋېي ھېسابىغا تىزىملاپ كىرگەن يەنە بىر ئۈسكۈنىدە داۋاملاشتۇرۇشقا بولىدۇ. ھەر ئىككى ئۈسكۈنىدە «ئۆتكۈزۈش»، WLAN ۋە كۆكچىش ئوچۇق بولۇشى كېرەك."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/mcc460-zh_CN/element/string.json b/application/entry/src/main/resources/mcc460-zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..8eeef0499c59d0103703478124f3fd5780ecfe07
--- /dev/null
+++ b/application/entry/src/main/resources/mcc460-zh_CN/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string":[
+ {
+ "name":"continue_desc",
+ "value":"在一台设备上进行浏览或编辑,然后可在附近另一台登录相同华为帐号的设备上继续。此功能需双方设备开启“接续”、WLAN 和蓝牙。"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/mcc460-zh_HK/element/string.json b/application/entry/src/main/resources/mcc460-zh_HK/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..2c7d4ff7cc7720a33afe188fa0889d71f5e06448
--- /dev/null
+++ b/application/entry/src/main/resources/mcc460-zh_HK/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string":[
+ {
+ "name":"continue_desc",
+ "value":"在一部裝置上進行瀏覽或編輯,然後可在附近另一部登入相同華為帳戶的裝置上繼續。此功能需雙方裝置啟用「接續」、WLAN 和藍牙。"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/mcc460-zh_TW/element/string.json b/application/entry/src/main/resources/mcc460-zh_TW/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..5db7559e9f99b71bb399a7fa17f30a52e177b444
--- /dev/null
+++ b/application/entry/src/main/resources/mcc460-zh_TW/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string":[
+ {
+ "name":"continue_desc",
+ "value":"在一台裝置中瀏覽或編輯,然後可以在附近另一台登入相同華為 ID 的裝置中繼續。此功能需要兩台裝置皆已啟用「接續」、WLAN 和藍牙。"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/ug/element/string.json b/application/entry/src/main/resources/ug/element/string.json
index b46b448ce00f0b3ca32832a543adff45d59b9d17..e73f05a9001c26eeffbe160c32bb898f9c7fef0f 100644
--- a/application/entry/src/main/resources/ug/element/string.json
+++ b/application/entry/src/main/resources/ug/element/string.json
@@ -27,6 +27,14 @@
{
"name":"continue",
"value":"داۋاملاشتۇرۇش"
+ },
+ {
+ "name":"continue_desc",
+ "value":"بىر ئۈسكۈنىدە كۆرۈۋاتقان ياكى تەھرىرلەۋاتقان ئىشنى ئەتراپتىكى ئوخشاش خۇاۋېي ھېسابىغا تىزىملاپ كىرگەن يەنە بىر ئۈسكۈنىدە داۋاملاشتۇرۇشقا بولىدۇ. ھەر ئىككى ئۈسكۈنىدە «ئۆتكۈزۈش»، Wi-Fi ۋە كۆكچىش ئوچۇق بولۇشى كېرەك."
+ },
+ {
+ "name":"continue_title",
+ "value":"ئۆتكۈزۈش"
}
]
}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/zh_CN/element/string.json b/application/entry/src/main/resources/zh_CN/element/string.json
index 289fc27be1a5916798d73f63f6e0623aa304bf6b..3f5c8ca49f41a7c9e8aa11edb6c70e450a890a2d 100644
--- a/application/entry/src/main/resources/zh_CN/element/string.json
+++ b/application/entry/src/main/resources/zh_CN/element/string.json
@@ -1,60 +1,60 @@
{
- "string": [
- {
- "name": "module_desc",
- "value": "模块描述"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "分布式硬件控制UI"
- },
- {
- "name": "connected_to",
- "value": "已连接至%1$s"
- },
- {
- "name": "stop_device",
- "value": "您可以断开连接以停止使用此设备的%1$s"
- },
- {
- "name": "pause",
- "value": "暂停"
- },
- {
- "name": "continue",
- "value": "继续"
- },
- {
- "name": "DHTypeName_Camera",
- "value": "相机"
- },
- {
- "name": "DHTypeName_Mic",
- "value": "麦克风"
- },
- {
- "name": "disconnect",
- "value": "断开连接"
- },
- {
- "name": "ContinueSwitchAbility_desc",
- "value": "description"
- },
- {
- "name": "ContinueSwitchAbility_label",
- "value": "label"
- },
- {
- "name": "continue_title",
- "value": "接续"
- },
- {
- "name": "continue_desc",
- "value": "在一台设备上进行浏览或编辑,然后可在附近另一台登录相同华为账号的设备上继续。此功能需双方设备开启“接续”,WLAN和蓝牙。"
- }
- ]
+ "string":[
+ {
+ "name":"module_desc",
+ "value":"模块描述"
+ },
+ {
+ "name":"EntryAbility_desc",
+ "value":"description"
+ },
+ {
+ "name":"EntryAbility_label",
+ "value":"分布式硬件控制UI"
+ },
+ {
+ "name":"connected_to",
+ "value":"已连接至%1$s"
+ },
+ {
+ "name":"stop_device",
+ "value":"您可以断开连接以停止使用此设备的%1$s"
+ },
+ {
+ "name":"pause",
+ "value":"暂停"
+ },
+ {
+ "name":"continue",
+ "value":"继续"
+ },
+ {
+ "name":"DHTypeName_Camera",
+ "value":"相机"
+ },
+ {
+ "name":"DHTypeName_Mic",
+ "value":"麦克风"
+ },
+ {
+ "name":"disconnect",
+ "value":"断开连接"
+ },
+ {
+ "name":"ContinueSwitchAbility_desc",
+ "value":"description"
+ },
+ {
+ "name":"ContinueSwitchAbility_label",
+ "value":"label"
+ },
+ {
+ "name":"continue_title",
+ "value":"接续"
+ },
+ {
+ "name":"continue_desc",
+ "value":"在一台设备上进行浏览或编辑,然后可在附近另一台登录相同华为帐号的设备上继续。此功能需双方设备开启“接续”、Wi-Fi 和蓝牙。"
+ }
+ ]
}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/zh_HK/element/string.json b/application/entry/src/main/resources/zh_HK/element/string.json
index 2ce592dcb47ae7cde444ded9bfcb20b24c1dc916..1a7562d8f16cbc04ffdd0369b91d323a5b2861f7 100644
--- a/application/entry/src/main/resources/zh_HK/element/string.json
+++ b/application/entry/src/main/resources/zh_HK/element/string.json
@@ -27,6 +27,14 @@
{
"name":"continue",
"value":"繼續"
+ },
+ {
+ "name":"continue_desc",
+ "value":"在一部裝置上進行瀏覽或編輯,然後可在附近另一部登入相同華為帳戶的裝置上繼續。此功能需雙方裝置啟用「接續」、Wi-Fi 和藍牙。"
+ },
+ {
+ "name":"continue_title",
+ "value":"接續"
}
]
}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/zh_TW/element/string.json b/application/entry/src/main/resources/zh_TW/element/string.json
index b06bc7d1b5b05635d04459921b0c38ba4590eaaa..b7da129bfeae4bc106ac36e05360d5e731095117 100644
--- a/application/entry/src/main/resources/zh_TW/element/string.json
+++ b/application/entry/src/main/resources/zh_TW/element/string.json
@@ -27,6 +27,14 @@
{
"name":"continue",
"value":"繼續"
+ },
+ {
+ "name":"continue_desc",
+ "value":"在一台裝置中瀏覽或編輯,然後可以在附近另一台登入相同華為 ID 的裝置中繼續。此功能需要兩台裝置皆已啟用「接續」、Wi-Fi 和藍牙。"
+ },
+ {
+ "name":"continue_title",
+ "value":"接續"
}
]
}
\ No newline at end of file
diff --git a/application/entry/src/main/resources/zz_ZX/element/string.json b/application/entry/src/main/resources/zz_ZX/element/string.json
index b70e661a9033ba5ebc7b0be9347d7c1472d3bcd3..dbc9dba7d14a50143d10e8b16b936abd4e6ff9c8 100644
--- a/application/entry/src/main/resources/zz_ZX/element/string.json
+++ b/application/entry/src/main/resources/zz_ZX/element/string.json
@@ -39,6 +39,22 @@
{
"name":"continue",
"value":"[TS_867711]_Resume"
+ },
+ {
+ "name":"continue_desc",
+ "value":"[TS_921308]_Browse or edit on one device, then continue on another nearby device logged in with the same Huawei ID. This function requires that both devices have enabled \"Application connection,\" Wifi, and Bluetooth."
+ },
+ {
+ "name":"ContinueSwitchAbility_label",
+ "value":"[TS_921307]_label"
+ },
+ {
+ "name":"continue_title",
+ "value":"[TS_921305]_Continuation"
+ },
+ {
+ "name":"ContinueSwitchAbility_desc",
+ "value":"[TS_921306]_description"
}
]
}
\ No newline at end of file
diff --git a/application/hvigorfile.ts b/application/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..8096108d3686cb1a60685700f0b493f62787376c
--- /dev/null
+++ b/application/hvigorfile.ts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2024 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 { appTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+};
diff --git a/bundle.json b/bundle.json
index 4f8e8db1419dd81bfa4eb49bd10cb34bc3a721e5..86b33cd74266ebef9a30cef04b5896081d5012ab 100644
--- a/bundle.json
+++ b/bundle.json
@@ -55,7 +55,6 @@
"bounds_checking_function",
"power_manager",
"openssl",
- "json",
"ffmpeg",
"zlib"
]
diff --git a/common/utils/include/distributed_hardware_errno.h b/common/utils/include/distributed_hardware_errno.h
index 998aba9ee3e20eac4ec5dfaceb0e2f061008dffe..febf17d663d592af48eecad4e7a09530614cd1c7 100644
--- a/common/utils/include/distributed_hardware_errno.h
+++ b/common/utils/include/distributed_hardware_errno.h
@@ -73,6 +73,7 @@ namespace DistributedHardware {
constexpr int32_t ERR_DH_FWK_HARDWARE_MANAGER_DEVICE_REPEAT_ONLINE = -10500;
constexpr int32_t ERR_DH_FWK_HARDWARE_MANAGER_DEVICE_REPEAT_OFFLINE = -10501;
constexpr int32_t ERR_DH_FWK_HARDWARE_MANAGER_INIT_FAILED = -10502;
+ constexpr int32_t ERR_DH_FWK_HARDWARE_MANAGER_DEVICE_NOT_ONLINE = -10503;
/* ComponentLoader errno, range: [-10600, -10699] */
constexpr int32_t ERR_DH_FWK_LOADER_HANDLER_IS_NULL = -10600;
diff --git a/common/utils/include/idistributed_hardware_manager.h b/common/utils/include/idistributed_hardware_manager.h
index dc2cf8948f1c1d6b342370cbfd1cfb9bb1e670d5..9355374562ac4049a5649a65159644ea57c6e9d9 100644
--- a/common/utils/include/idistributed_hardware_manager.h
+++ b/common/utils/include/idistributed_hardware_manager.h
@@ -32,6 +32,8 @@ public:
uint16_t deviceType) = 0;
virtual int32_t SendOffLineEvent(const std::string &networkId, const std::string &uuid,
uint16_t deviceType) = 0;
+ virtual int32_t SendDeviceChangedEvent(const std::string &networkId, const std::string &uuid,
+ uint16_t deviceType) = 0;
virtual size_t GetOnLineCount() = 0;
virtual int32_t GetComponentVersion(std::unordered_map &versionMap) = 0;
virtual int32_t Dump(const std::vector &argsStr, std::string &result) = 0;
diff --git a/services/distributedhardwarefwkservice/BUILD.gn b/services/distributedhardwarefwkservice/BUILD.gn
index 92597676966cfa2a079209fe773c3f791fb6279d..08e875e72983a3f5e191b1f4cdd3c57a8254ef0f 100644
--- a/services/distributedhardwarefwkservice/BUILD.gn
+++ b/services/distributedhardwarefwkservice/BUILD.gn
@@ -95,9 +95,9 @@ ohos_shared_library("distributedhardwarefwksvr") {
"src/resourcemanager/version_info_manager.cpp",
"src/task/disable_task.cpp",
"src/task/enable_task.cpp",
- "src/task/monitor_task_timer.cpp",
"src/task/offline_task.cpp",
"src/task/online_task.cpp",
+ "src/task/device_changed_task.cpp",
"src/task/task.cpp",
"src/task/task_board.cpp",
"src/task/task_executor.cpp",
@@ -138,7 +138,6 @@ ohos_shared_library("distributedhardwarefwksvr") {
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
- "json:nlohmann_json_static",
"kv_store:distributeddata_inner",
"power_manager:powermgr_client",
"resource_schedule_service:ressched_client",
diff --git a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h
index d071f397729a9e5469bb3251b6df8a7146ae3e2d..c58ec056afac970fe55f4ff30d7a257afb779f25 100644
--- a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h
+++ b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h
@@ -34,7 +34,6 @@
#include "idistributed_hardware_source.h"
#include "impl_utils.h"
#include "low_latency_listener.h"
-#include "monitor_task_timer.h"
#include "meta_capability_info.h"
#include "task_board.h"
#include "task_factory.h"
@@ -77,7 +76,7 @@ public:
* @return false if the task param not exist, return false.
*/
bool FetchNeedRefreshTask(const std::pair &taskKey, TaskParam &taskParam);
-
+ bool IsIdenticalAccount(const std::string &networkId);
class ComponentManagerEventHandler : public AppExecFwk::EventHandler {
public:
ComponentManagerEventHandler(const std::shared_ptr &runner);
@@ -120,7 +119,6 @@ private:
int32_t InitComponentHandler();
int32_t InitSAMonitor();
void StartComponent();
- void StartTaskMonitor();
void RegisterDHStateListener();
void RegisterDataSyncTriggerListener();
void InitDHCommTool();
@@ -129,7 +127,6 @@ private:
void UnregisterDHStateListener();
void UnregisterDataSyncTriggerListener();
void UnInitDHCommTool();
- void StopTaskMonitor();
void StopComponent();
void StopPrivacy();
int32_t GetEnableCapParam(const std::string &networkId, const std::string &uuid, DHType dhType, EnableParam ¶m,
@@ -148,7 +145,6 @@ private:
std::shared_ptr cameraCompPrivacy_ = nullptr;
std::shared_ptr compMonitorPtr_ = nullptr;
sptr lowLatencyListener_ = nullptr;
- std::shared_ptr monitorTaskTimer_ = nullptr;
std::atomic isUnInitTimeOut_;
// record the remote device business state, {{deviceUUID, dhId}, BusinessState}.
diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h b/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h
index 97ce0f0ad255ea2ba1b7ff9a5e101234afa919a9..601e8078dbf725d9e9200f53d79bca19908de6e9 100644
--- a/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h
+++ b/services/distributedhardwarefwkservice/include/distributed_hardware_manager.h
@@ -32,6 +32,7 @@ public:
int32_t Release() override;
int32_t SendOnLineEvent(const std::string &networkId, const std::string &uuid, uint16_t deviceType) override;
int32_t SendOffLineEvent(const std::string &networkId, const std::string &uuid, uint16_t deviceType) override;
+ int32_t SendDeviceChangedEvent(const std::string &networkId, const std::string &uuid, uint16_t deviceType) override;
size_t GetOnLineCount() override;
int32_t GetComponentVersion(std::unordered_map &versionMap) override;
diff --git a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h
index d249dbc8310f029cc5f1f8fdfcd852c6b5ed87bc..9cc616a11bd90079bffc70d8d8349c45eb789b95 100644
--- a/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h
+++ b/services/distributedhardwarefwkservice/include/distributed_hardware_manager_factory.h
@@ -33,6 +33,7 @@ public:
bool IsInit();
int32_t SendOnLineEvent(const std::string &networkId, const std::string &uuid, uint16_t deviceType);
int32_t SendOffLineEvent(const std::string &networkId, const std::string &uuid, uint16_t deviceType);
+ int32_t SendDeviceChangedEvent(const std::string &networkId, const std::string &uuid, uint16_t deviceType);
int32_t GetComponentVersion(std::unordered_map &versionMap);
int Dump(const std::vector &argsStr, std::string &result);
diff --git a/services/distributedhardwarefwkservice/include/task/monitor_task_timer.h b/services/distributedhardwarefwkservice/include/task/device_changed_task.h
similarity index 59%
rename from services/distributedhardwarefwkservice/include/task/monitor_task_timer.h
rename to services/distributedhardwarefwkservice/include/task/device_changed_task.h
index 703da1b916fd7bc7d85ab201cddaf9bab068a051..bd86723c058ea4155c080239678847f2ab414134 100644
--- a/services/distributedhardwarefwkservice/include/task/monitor_task_timer.h
+++ b/services/distributedhardwarefwkservice/include/task/device_changed_task.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * 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
@@ -13,22 +13,23 @@
* limitations under the License.
*/
-#ifndef OHOS_DISTRIBUTED_HARDWARE_MONITOR_TASK_TIMER_H
-#define OHOS_DISTRIBUTED_HARDWARE_MONITOR_TASK_TIMER_H
+#ifndef OHOS_DISTRIBUTED_HARDWARE_DEVICE_CHANGED_TASK_H
+#define OHOS_DISTRIBUTED_HARDWARE_DEVICE_CHANGED_TASK_H
-#include "dh_timer.h"
+#include "task.h"
namespace OHOS {
namespace DistributedHardware {
-class MonitorTaskTimer : public DHTimer {
+class DeviceChangedTask : public Task {
public:
- MonitorTaskTimer(std::string timerId, int32_t delayTimerMs);
- ~MonitorTaskTimer() override;
+ DeviceChangedTask() = delete;
+ DeviceChangedTask(const std::string &networkId, const std::string &uuid, const std::string &dhId, const DHType dhType);
+ virtual ~DeviceChangedTask();
+ virtual void DoTask();
private:
- void ExecuteInner() override;
- void HandleStopTimer() override;
+ void HandleDeviceChanged();
};
} // namespace DistributedHardware
} // namespace OHOS
-#endif
+#endif
\ No newline at end of file
diff --git a/services/distributedhardwarefwkservice/include/utils/impl_utils.h b/services/distributedhardwarefwkservice/include/utils/impl_utils.h
index f47aff567a311de774ac2a37c17f524b5c302454..6b79211984b063132749eb3a51e3a0f448c07479 100644
--- a/services/distributedhardwarefwkservice/include/utils/impl_utils.h
+++ b/services/distributedhardwarefwkservice/include/utils/impl_utils.h
@@ -28,7 +28,8 @@ enum class TaskType : int32_t {
ENABLE = 1,
DISABLE = 2,
ON_LINE = 3,
- OFF_LINE = 4
+ OFF_LINE = 4,
+ DEVICE_CHANGED = 5
};
enum class TaskStep : int32_t {
@@ -38,7 +39,8 @@ enum class TaskStep : int32_t {
REGISTER_ONLINE_DISTRIBUTED_HARDWARE = 4,
UNREGISTER_OFFLINE_DISTRIBUTED_HARDWARE = 5,
CLEAR_OFFLINE_INFO = 6,
- WAIT_UNREGISTGER_COMPLETE = 7
+ WAIT_UNREGISTGER_COMPLETE = 7,
+ DO_DEVICE_CHANGED = 8
};
enum class TaskState : int32_t {
diff --git a/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp b/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp
index 94c2041730306cf255d49a2659c0ac0de2efc31b..f10b8fa3c550625d5e0b026edfb1b36836ce0811 100644
--- a/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp
+++ b/services/distributedhardwarefwkservice/src/accessmanager/access_manager.cpp
@@ -175,8 +175,25 @@ void AccessManager::OnDeviceReady(const DmDeviceInfo &deviceInfo)
void AccessManager::OnDeviceChanged(const DmDeviceInfo &deviceInfo)
{
- (void)deviceInfo;
- return;
+ std::lock_guard lock(accessMutex_);
+ DHLOGI("start, networkId = %{public}s, deviceName = %{public}s",
+ GetAnonyString(deviceInfo.networkId).c_str(), GetAnonyString(deviceInfo.deviceName).c_str());
+
+ auto networkId = std::string(deviceInfo.networkId);
+ if (networkId.size() == 0 || networkId.size() > MAX_ID_LEN) {
+ DHLOGE("NetworkId is invalid!");
+ return;
+ }
+ auto uuid = GetUUIDBySoftBus(networkId);
+ if (uuid.size() == 0 || uuid.size() > MAX_ID_LEN) {
+ DHLOGE("Uuid is invalid!");
+ return;
+ }
+
+ auto ret =
+ DistributedHardwareManagerFactory::GetInstance().SendDeviceChangedEvent(networkId, uuid, deviceInfo.deviceTypeId);
+ DHLOGI("device changed result = %{public}d, networkId = %{public}s, uuid = %{public}s", ret,
+ GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str());
}
void AccessManager::CheckTrustedDeviceOnline()
diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp
index 811cf22969d91641e9293f89382b075be496ef63..c5b372f17c0ffd9b48418bad48d2bf10d199c775 100644
--- a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp
+++ b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp
@@ -62,14 +62,12 @@ namespace {
constexpr int32_t DISABLE_RETRY_MAX_TIMES = 3;
constexpr int32_t ENABLE_PARAM_RETRY_TIME = 500 * 1000;
constexpr int32_t INVALID_SA_ID = -1;
- constexpr int32_t MONITOR_TASK_DELAY_MS = 5 * 1000;
constexpr int32_t UNINIT_COMPONENT_TIMEOUT_SECONDS = 2;
const std::string MONITOR_TASK_TIMER_ID = "monitor_task_timer_id";
}
ComponentManager::ComponentManager() : compSource_({}), compSink_({}), compSrcSaId_({}),
compMonitorPtr_(std::make_shared()), lowLatencyListener_(new(std::nothrow) LowLatencyListener),
- monitorTaskTimer_(std::make_shared(MONITOR_TASK_TIMER_ID, MONITOR_TASK_DELAY_MS)),
isUnInitTimeOut_(false), dhBizStates_({}), dhStateListener_(std::make_shared()),
dataSyncTriggerListener_(std::make_shared()),
dhCommToolPtr_(std::make_shared()), needRefreshTaskParams_({})
@@ -102,7 +100,6 @@ int32_t ComponentManager::Init()
}
StartComponent();
- StartTaskMonitor();
RegisterDHStateListener();
RegisterDataSyncTriggerListener();
InitDHCommTool();
@@ -163,13 +160,6 @@ void ComponentManager::StartComponent()
}
}
-void ComponentManager::StartTaskMonitor()
-{
- if (monitorTaskTimer_ != nullptr) {
- monitorTaskTimer_->StartTimer();
- }
-}
-
void ComponentManager::RegisterDHStateListener()
{
for (const auto &item : compSource_) {
@@ -213,7 +203,6 @@ int32_t ComponentManager::UnInit()
UnregisterDHStateListener();
UnregisterDataSyncTriggerListener();
UnInitDHCommTool();
- StopTaskMonitor();
StopPrivacy();
UnInitSAMonitor();
StopComponent();
@@ -281,14 +270,6 @@ void ComponentManager::UnInitDHCommTool()
dhCommToolPtr_->UnInit();
}
-void ComponentManager::StopTaskMonitor()
-{
- // stop monitor task timer
- if (monitorTaskTimer_ != nullptr) {
- monitorTaskTimer_->StopTimer();
- }
-}
-
void ComponentManager::StopComponent()
{
// stop source and sink sa
@@ -719,14 +700,14 @@ int32_t ComponentManager::GetCapParam(const std::string &uuid, const std::string
std::string deviceId = GetDeviceIdByUUID(uuid);
auto ret = CapabilityInfoManager::GetInstance()->GetCapability(deviceId, dhId, capability);
if ((ret == DH_FWK_SUCCESS) && (capability != nullptr)) {
- DHLOGE("GetCapability success, deviceId: %{public}s, uuid: %{public}s, dhId: %{public}s, ret: %{public}d",
+ DHLOGI("GetCapability success, deviceId: %{public}s, uuid: %{public}s, dhId: %{public}s, ret: %{public}d",
GetAnonyString(deviceId).c_str(), GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), ret);
return ret;
}
ret = LocalCapabilityInfoManager::GetInstance()->GetCapability(deviceId, dhId, capability);
if ((ret == DH_FWK_SUCCESS) && (capability != nullptr)) {
- DHLOGE("Local GetCaps success, deviceId: %{public}s, uuid: %{public}s, dhId: %{public}s, ret: %{public}d",
+ DHLOGI("Local GetCaps success, deviceId: %{public}s, uuid: %{public}s, dhId: %{public}s, ret: %{public}d",
GetAnonyString(deviceId).c_str(), GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), ret);
return ret;
}
@@ -739,7 +720,7 @@ int32_t ComponentManager::GetMetaParam(const std::string &uuid, const std::strin
{
auto ret = MetaInfoManager::GetInstance()->GetMetaCapInfo(GetDeviceIdByUUID(uuid), dhId, metaCapPtr);
if ((ret == DH_FWK_SUCCESS) && (metaCapPtr != nullptr)) {
- DHLOGE("GetCapability success, uuid =%{public}s, dhId = %{public}s, errCode = %{public}d",
+ DHLOGI("GetCapability success, uuid =%{public}s, dhId = %{public}s, errCode = %{public}d",
GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(), ret);
return ret;
}
diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp
index ee3f702b3c4b4016db6f05d56a5b8e1bbdb75345..13c4e1902064477dbbc53dda6282dd5a7b69168b 100644
--- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp
+++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager.cpp
@@ -146,6 +146,30 @@ int32_t DistributedHardwareManager::SendOffLineEvent(const std::string &networkI
return DH_FWK_SUCCESS;
}
+int32_t DistributedHardwareManager::SendDeviceChangedEvent(const std::string &networkId, const std::string &uuid,
+ uint16_t deviceType)
+{
+ (void)deviceType;
+
+ if (networkId.size() == 0 || networkId.size() > MAX_ID_LEN || uuid.size() == 0 || uuid.size() > MAX_ID_LEN) {
+ DHLOGE("NetworkId or uuid is invalid");
+ return ERR_DH_FWK_PARA_INVALID;
+ }
+
+ DHLOGI("networkId = %{public}s, uuid = %{public}s", GetAnonyString(networkId).c_str(),
+ GetAnonyString(uuid).c_str());
+
+ TaskParam taskParam = {
+ .networkId = networkId,
+ .uuid = uuid,
+ .dhId = "",
+ .dhType = DHType::UNKNOWN
+ };
+ auto task = TaskFactory::GetInstance().CreateTask(TaskType::DEVICE_CHANGED, taskParam, nullptr);
+ TaskExecutor::GetInstance().PushTask(task);
+ return DH_FWK_SUCCESS;
+}
+
size_t DistributedHardwareManager::GetOnLineCount()
{
return DHContext::GetInstance().GetOnlineCount();
diff --git a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp
index 6da58efcb92010c6e2b2f42ecc5f003e07e42afb..17e658514f19175848d752422fb88bc1b32b5920 100644
--- a/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp
+++ b/services/distributedhardwarefwkservice/src/distributed_hardware_manager_factory.cpp
@@ -205,6 +205,34 @@ int32_t DistributedHardwareManagerFactory::SendOffLineEvent(const std::string &n
return DH_FWK_SUCCESS;
}
+int32_t DistributedHardwareManagerFactory::SendDeviceChangedEvent(const std::string &networkId, const std::string &uuid,
+ uint16_t deviceType)
+{
+ if (networkId.empty() || networkId.size() > MAX_ID_LEN || uuid.empty() || uuid.size() > MAX_ID_LEN) {
+ DHLOGE("NetworkId or uuid is invalid");
+ return ERR_DH_FWK_PARA_INVALID;
+ }
+
+ if (!isInit) {
+ DHLOGI("distributedHardwareMgr is null");
+ return ERR_DH_FWK_HARDWARE_MANAGER_DEVICE_NOT_ONLINE;
+ }
+ //if device not online, no need to handle device change event
+ if (!DHContext::GetInstance().IsDeviceOnline(uuid)) {
+ DHLOGI("Device not online, networkId: %{public}s, uuid: %{public}s",
+ GetAnonyString(networkId).c_str(), GetAnonyString(uuid).c_str());
+ return ERR_DH_FWK_HARDWARE_MANAGER_DEVICE_NOT_ONLINE;
+ }
+
+ auto result = DistributedHardwareManager::GetInstance().SendDeviceChangedEvent(networkId, uuid, deviceType);
+ if (result != DH_FWK_SUCCESS) {
+ DHLOGE("offline failed, errCode = %{public}d", result);
+ return result;
+ }
+
+ return DH_FWK_SUCCESS;
+}
+
int32_t DistributedHardwareManagerFactory::GetComponentVersion(std::unordered_map &versionMap)
{
DHLOGI("start");
diff --git a/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp b/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp
index 5812b213c409ca7c532ebff97b999e01c9c769e5..8a52d1b4bfce4fc4b1d08213a85ab899ac8c6e9f 100644
--- a/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp
+++ b/services/distributedhardwarefwkservice/src/localhardwaremanager/local_hardware_manager.cpp
@@ -116,8 +116,7 @@ void LocalHardwareManager::QueryLocalHardware(const DHType dhType, IHardwareHand
DHLOGE("Query hardwareHandler and obtain empty, dhType: %{public}#X", dhType);
usleep(QUERY_INTERVAL_TIME);
} else {
- DHLOGI("Query hardwareHandler success, dhType: %{public}#X!, size: %{public}d",
- dhType, static_cast(dhItems.size()));
+ DHLOGI("Query hardwareHandler success, dhType: %{public}#X!, size: %{public}zu", dhType, dhItems.size());
/*
* Failed to delete data when the device restarts or other exception situation.
* So check and remove the non-exist local capabilityInfo.
@@ -141,8 +140,8 @@ void LocalHardwareManager::QueryMetaHardware(const DHType dhType, IHardwareHandl
DHLOGE("Query metahardwareHandler and obtain empty, dhType: %{public}#X", dhType);
usleep(QUERY_INTERVAL_TIME);
} else {
- DHLOGI("Query metahardwareHandler success, dhType: %{public}#X!, size: %{public}d",
- dhType, static_cast(metaDhItems.size()));
+ DHLOGI("Query metahardwareHandler success, dhType: %{public}#X!, size: %{public}zu",
+ dhType, metaDhItems.size());
metaDHItemsMap_[dhType] = metaDhItems;
break;
}
diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp
index 75548046a328fa07ebc9ae0ac9e9da06d2b72a5e..e34aee75ba937e4fb3d6b6c767933435156a257e 100644
--- a/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp
+++ b/services/distributedhardwarefwkservice/src/resourcemanager/db_adapter.cpp
@@ -98,7 +98,10 @@ DistributedKv::Status DBAdapter::GetLocalKvStorePtr()
int32_t DBAdapter::Init(bool isAutoSync, DistributedKv::DataType dataType)
{
- DHLOGI("Init DB, storeId: %{public}s", storeId_.storeId.c_str());
+ this->isAutoSync = isAutoSync;
+ this->dataType = dataType;
+ DHLOGI("Init DB, storeId: %{public}s, dataType: %{public}d",
+ storeId_.storeId.c_str(), static_cast(dataType));
std::lock_guard lock(dbAdapterMutex_);
int32_t tryTimes = MAX_INIT_RETRY_TIMES;
while (tryTimes > 0) {
@@ -123,14 +126,15 @@ int32_t DBAdapter::Init(bool isAutoSync, DistributedKv::DataType dataType)
DHLOGE("Init KvStorePtr failed");
return ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL;
}
- this->isAutoSync = isAutoSync;
- this->dataType = dataType;
return DH_FWK_SUCCESS;
}
int32_t DBAdapter::InitLocal()
{
- DHLOGI("Init local DB, storeId: %{public}s", storeId_.storeId.c_str());
+ this->isAutoSync = false;
+ this->dataType = DistributedKv::DataType::TYPE_STATICS;
+ DHLOGI("Init local DB, storeId: %{public}s, dataType: %{public}d",
+ storeId_.storeId.c_str(), static_cast(this->dataType));
std::lock_guard lock(dbAdapterMutex_);
int32_t tryTimes = MAX_INIT_RETRY_TIMES;
while (tryTimes > 0) {
@@ -148,7 +152,6 @@ int32_t DBAdapter::InitLocal()
DHLOGE("Init KvStorePtr failed");
return ERR_DH_FWK_RESOURCE_KV_STORAGE_POINTER_NULL;
}
- this->isAutoSync = false;
return DH_FWK_SUCCESS;
}
@@ -229,7 +232,8 @@ void DBAdapter::TriggerDynamicQuery(const std::string &key)
int32_t DBAdapter::GetDataByKey(const std::string &key, std::string &data)
{
- DHLOGI("Get data by key: %{public}s", GetAnonyString(key).c_str());
+ DHLOGI("Get data by key: %{public}s, storeId: %{public}s, dataType: %{public}d",
+ GetAnonyString(key).c_str(), storeId_.storeId.c_str(), static_cast(this->dataType));
std::lock_guard lock(dbAdapterMutex_);
if (kvStoragePtr_ == nullptr) {
DHLOGE("kvStoragePtr_ is null");
@@ -251,7 +255,8 @@ int32_t DBAdapter::GetDataByKey(const std::string &key, std::string &data)
int32_t DBAdapter::GetDataByKeyPrefix(const std::string &keyPrefix, std::vector &values)
{
- DHLOGI("Get data by key prefix: %{public}s", GetAnonyString(keyPrefix).c_str());
+ DHLOGI("Get data by key prefix: %{public}s, storeId: %{public}s, dataType: %{public}d",
+ GetAnonyString(keyPrefix).c_str(), storeId_.storeId.c_str(), static_cast(this->dataType));
std::lock_guard lock(dbAdapterMutex_);
if (kvStoragePtr_ == nullptr) {
DHLOGE("kvStoragePtr_ is null");
diff --git a/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp b/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp
index 6e2f56eaca05111fa0192d04034ec80220d856a9..574e98429fc468404cf0868235df5347109906d9 100644
--- a/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp
+++ b/services/distributedhardwarefwkservice/src/resourcemanager/local_capability_info_manager.cpp
@@ -123,7 +123,6 @@ int32_t LocalCapabilityInfoManager::AddCapability(const std::vector keys;
std::vector values;
std::string key;
- std::string data;
for (auto &resInfo : resInfos) {
if (resInfo == nullptr) {
continue;
diff --git a/services/distributedhardwarefwkservice/src/task/device_changed_task.cpp b/services/distributedhardwarefwkservice/src/task/device_changed_task.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a90995b5f880109f2394c5f31a1cd5523bf9196a
--- /dev/null
+++ b/services/distributedhardwarefwkservice/src/task/device_changed_task.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2021-2024 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 "device_changed_task.h"
+
+#include "anonymous_string.h"
+#include "capability_info_manager.h"
+#include "component_manager.h"
+#include "dh_utils_tool.h"
+#include "capability_utils.h"
+#include "distributed_hardware_errno.h"
+#include "distributed_hardware_log.h"
+#include "local_capability_info_manager.h"
+#include "meta_info_manager.h"
+#include "task_board.h"
+#include "task_executor.h"
+#include "task_factory.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+#undef DH_LOG_TAG
+#define DH_LOG_TAG "DeviceChangedTask"
+
+DeviceChangedTask::DeviceChangedTask(const std::string &networkId, const std::string &uuid, const std::string &dhId,
+ const DHType dhType) : Task(networkId, uuid, dhId, dhType)
+{
+ SetTaskType(TaskType::DEVICE_CHANGED);
+ SetTaskSteps(std::vector { TaskStep::DO_DEVICE_CHANGED });
+ DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(uuid).c_str());
+}
+
+DeviceChangedTask::~DeviceChangedTask()
+{
+ DHLOGD("id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str());
+}
+
+void DeviceChangedTask::DoTask()
+{
+ DHLOGD("start device changed task, id = %{public}s, uuid = %{public}s", GetId().c_str(), GetAnonyString(GetUUID()).c_str());
+ this->SetTaskState(TaskState::RUNNING);
+ for (const auto& step : this->GetTaskSteps()) {
+ switch (step) {
+ case TaskStep::DO_DEVICE_CHANGED: {
+ HandleDeviceChanged();
+ break;
+ }
+ default: {
+ break;
+ }
+ }
+ }
+ SetTaskState(TaskState::SUCCESS);
+ DHLOGD("finish device changed task, remove it, id = %{public}s.", GetId().c_str());
+ TaskBoard::GetInstance().RemoveTask(this->GetId());
+}
+
+
+void DeviceChangedTask::HandleDeviceChanged()
+{
+ DHLOGI("networkId = %{public}s, uuid = %{public}s", GetAnonyString(GetNetworkId()).c_str(),
+ GetAnonyString(GetUUID()).c_str());
+ if (!ComponentManager::GetInstance().IsIdenticalAccount(GetNetworkId())) {
+ DHLOGI("not identical account");
+ return;
+ }
+ std::string deviceId = GetDeviceIdByUUID(GetUUID());
+ std::vector> devDhInfos;
+ std::vector> capabilityInfos;
+ CapabilityInfoManager::GetInstance()->GetCapabilitiesByDeviceId(deviceId, capabilityInfos);
+ std::for_each(capabilityInfos.begin(), capabilityInfos.end(), [&](std::shared_ptr cap) {
+ devDhInfos.push_back({cap->GetDHId(), cap->GetDHType()});
+ });
+
+ if (devDhInfos.empty()) {
+ DHLOGW("Can not get cap info from CapabilityInfo, try use local Capability info");
+ LocalCapabilityInfoManager::GetInstance()->GetCapabilitiesByDeviceId(deviceId, capabilityInfos);
+ std::for_each(capabilityInfos.begin(), capabilityInfos.end(), [&](std::shared_ptr cap) {
+ devDhInfos.push_back({cap->GetDHId(), cap->GetDHType()});
+ });
+ }
+
+ if (devDhInfos.empty()) {
+ DHLOGW("Can not get cap info from local Capbility, try use meta info");
+ std::vector> metaCapInfos;
+ MetaInfoManager::GetInstance()->GetMetaCapInfosByDeviceId(deviceId, metaCapInfos);
+ std::for_each(metaCapInfos.begin(), metaCapInfos.end(), [&](std::shared_ptr cap) {
+ devDhInfos.push_back({cap->GetDHId(), cap->GetDHType()});
+ });
+ }
+
+ if (devDhInfos.empty()) {
+ DHLOGE("Can not get cap info, uuid = %{public}s, deviceId = %{public}s", GetAnonyString(GetUUID()).c_str(),
+ GetAnonyString(deviceId).c_str());
+ return;
+ }
+
+ auto enabledDevices = TaskBoard::GetInstance().GetEnabledDevice();
+ for (const auto &info : devDhInfos) {
+
+ //skip enabled component
+ std::string deviceKey = GetCapabilityKey(GetDeviceIdByUUID(GetUUID()), info.first);
+ if (enabledDevices.find(deviceKey) != enabledDevices.end()) {
+ continue;
+ }
+ TaskParam taskParam = {
+ .networkId = GetNetworkId(),
+ .uuid = GetUUID(),
+ .dhId = info.first,
+ .dhType = info.second
+ };
+ auto task = TaskFactory::GetInstance().CreateTask(TaskType::ENABLE, taskParam, shared_from_this());
+ TaskExecutor::GetInstance().PushTask(task);
+ }
+}
+} // namespace DistributedHardware
+} // namespace OHOS
diff --git a/services/distributedhardwarefwkservice/src/task/monitor_task_timer.cpp b/services/distributedhardwarefwkservice/src/task/monitor_task_timer.cpp
deleted file mode 100644
index d02e8a97e266b86d546f45ce6332eefca8891e54..0000000000000000000000000000000000000000
--- a/services/distributedhardwarefwkservice/src/task/monitor_task_timer.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2022-2024 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 "monitor_task_timer.h"
-
-#include "anonymous_string.h"
-#include "capability_info.h"
-#include "capability_info_manager.h"
-#include "distributed_hardware_errno.h"
-#include "distributed_hardware_log.h"
-#include "dh_timer.h"
-#include "task_board.h"
-#include "task_executor.h"
-#include "task_factory.h"
-
-namespace OHOS {
-namespace DistributedHardware {
-#undef DH_LOG_TAG
-#define DH_LOG_TAG "MonitorTaskTimer"
-MonitorTaskTimer::MonitorTaskTimer(std::string timerId, int32_t delayTimeMs) : DHTimer(timerId, delayTimeMs)
-{
- DHLOGI("MonitorTaskTimer ctor!");
-}
-
-MonitorTaskTimer::~MonitorTaskTimer()
-{
- DHLOGI("MonitorTaskTimer dtor!");
-}
-
-void MonitorTaskTimer::ExecuteInner()
-{
- DHLOGD("ExecuteInner!");
- auto enabledDevices = TaskBoard::GetInstance().GetEnabledDevice();
- std::shared_ptr capInfoPtr = nullptr;
- TaskParam taskParam;
- std::string capabilityKey;
- for (auto item : enabledDevices) {
- capabilityKey = item.first;
- taskParam = item.second;
- if (taskParam.dhType != DHType::INPUT) {
- continue;
- }
- if (CapabilityInfoManager::GetInstance()->GetDataByKey(capabilityKey, capInfoPtr) != DH_FWK_SUCCESS) {
- DHLOGI("CapabilityInfoManager can not find this key in DB, key: %{public}s, networkId: %{public}s, "
- "uuid: %{public}s, dhId: %{public}s", GetAnonyString(capabilityKey).c_str(),
- GetAnonyString(taskParam.networkId).c_str(), GetAnonyString(taskParam.uuid).c_str(),
- GetAnonyString(taskParam.dhId).c_str());
- auto task = TaskFactory::GetInstance().CreateTask(TaskType::DISABLE, taskParam, nullptr);
- TaskExecutor::GetInstance().PushTask(task);
- }
- }
-
- if (capInfoPtr != nullptr) {
- capInfoPtr = nullptr;
- }
-}
-
-void MonitorTaskTimer::HandleStopTimer()
-{
- DHLOGI("HandleStopTimer!");
-}
-} // namespace DistributedHardware
-} // namespace OHOS
diff --git a/services/distributedhardwarefwkservice/src/task/task_factory.cpp b/services/distributedhardwarefwkservice/src/task/task_factory.cpp
index d20aecb3af5b2638bca63969977ce8e00d36bc22..d3e782e929996ca49236141b177d4e158378a0dd 100644
--- a/services/distributedhardwarefwkservice/src/task/task_factory.cpp
+++ b/services/distributedhardwarefwkservice/src/task/task_factory.cpp
@@ -22,6 +22,7 @@
#include "offline_task.h"
#include "online_task.h"
#include "task_board.h"
+#include "device_changed_task.h"
namespace OHOS {
namespace DistributedHardware {
@@ -52,6 +53,10 @@ std::shared_ptr TaskFactory::CreateTask(TaskType taskType, TaskParam taskP
task = std::make_shared(taskParam.networkId, taskParam.uuid, taskParam.dhId, taskParam.dhType);
break;
}
+ case TaskType::DEVICE_CHANGED: {
+ task = std::make_shared(taskParam.networkId, taskParam.uuid, taskParam.dhId, taskParam.dhType);
+ break;
+ }
default: {
DHLOGE("CreateTask type invalid, type: %{public}d", taskType);
return nullptr;
diff --git a/utils/BUILD.gn b/utils/BUILD.gn
index a8988f475e6243af13006fe552a4ea4943d28837..8f822fad2b183d4b63af77a045840bbf4ba610bc 100644
--- a/utils/BUILD.gn
+++ b/utils/BUILD.gn
@@ -65,7 +65,6 @@ ohos_shared_library("distributedhardwareutils") {
"hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
- "json:nlohmann_json_static",
"openssl:libcrypto_shared",
"safwk:system_ability_fwk",
"zlib:shared_libz",