diff --git a/BUILD.gn b/BUILD.gn index 13f478c6ab43c6feda85a7e597e6c226f6d830d2..7c3738e0fcece4a8694296e6358a1e593c1c6bc5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,7 +16,7 @@ if (defined(ohos_lite)) { lite_component("devicemanager_mini") { features = [ "utils:devicemanagerutils_mini", - "services/devicemanagerservice:devicemanagerservice_mini", + "services/service:devicemanagerservice_mini", "interfaces/inner_kits/native_cpp:devicemanagersdk_mini", "interfaces/kits/js_mini:devicemanager_native_js", ] @@ -29,9 +29,7 @@ if (defined(ohos_lite)) { lite_component("device_manager") { features = [ "utils:devicemanagerutils", - "services/devicemanagerservice:devicemanagerservice", "interfaces/inner_kits/native_cpp:devicemanagersdk", - "ext/pin_auth:devicemanagerext_pin_auth", ] } group("device_manager_test") { @@ -46,7 +44,8 @@ if (defined(ohos_lite)) { "interfaces/inner_kits/native_cpp:devicemanagersdk", "interfaces/kits:devicemanager_native_js", "sa_profile:dm_sa_profile", - "services/devicemanagerservice:devicemanagerservice", + "services/implementation:devicemanagerserviceimpl", + "services/service:devicemanagerservice", "utils:devicemanagerutils", ] } diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 3fe442c18aed763daeef01bdccb878c726f8f459..fb711dd5b55ebd2efaab72643e54888359e80c44 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -18,6 +18,12 @@ #include +#ifdef __LP64__ +const std::string LIB_LOAD_PATH = "/system/lib64/"; +#else +const std::string LIB_LOAD_PATH = "/system/lib/"; +#endif + namespace OHOS { namespace DistributedHardware { const std::string DM_PKG_NAME = "ohos.distributedhardware.devicemanager"; diff --git a/device_manager.gni b/device_manager.gni index 450accdf59b1559507aca19d137cf8439d4fcd60..89701e68ac2655aedd7aa7f68b069f1e2227f410 100644 --- a/device_manager.gni +++ b/device_manager.gni @@ -16,7 +16,8 @@ devicemanager_path = "//foundation/distributedhardware/device_manager" common_path = "${devicemanager_path}/common" utils_path = "${devicemanager_path}/utils" -services_path = "${devicemanager_path}/services/devicemanagerservice" +services_path = "${devicemanager_path}/services/service" +servicesimpl_path = "${devicemanager_path}/services/implementation" innerkits_path = "${devicemanager_path}/interfaces/inner_kits" ext_path = "${devicemanager_path}/ext" aainnerkits_path = "//foundation/ability/ability_runtime/interfaces/inner_api" diff --git a/ext/no_interaction_auth/BUILD.gn b/ext/no_interaction_auth/BUILD.gn index cb0f192a01e52f378dc40b38b0fd7d667a60551a..45706a7ddf6269205598ea9b65df58039eb5a6f7 100644 --- a/ext/no_interaction_auth/BUILD.gn +++ b/ext/no_interaction_auth/BUILD.gn @@ -26,23 +26,22 @@ if (defined(ohos_lite)) { "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", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/config", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/commonevent", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/timer", "${services_path}/include/ipc", "${services_path}/include/ipc/standard", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include", + "${servicesimpl_path}/include", "${innerkits_path}/native_cpp/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -70,7 +69,8 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/security/device_auth/services:deviceauth_sdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", "//utils/native/base:utils", ] diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 68e45a966218368c340a0e67f9a6ad003357ce74..fc0da72ef2cbc42e0d3f5ea7bc0a967b32e214e2 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -25,24 +25,23 @@ if (defined(ohos_lite)) { "include/lite", "${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/authentication/showconfirm/lite", - "${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", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/config", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/authentication/showconfirm/lite", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/commonevent", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/timer", "${services_path}/include/ipc", "${services_path}/include/ipc/lite", "${utils_path}/include", "${utils_path}/include/ipc/lite", - "${services_path}/include", + "${servicesimpl_path}/include", "${innerkits_path}/native_cpp/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -70,7 +69,6 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//base/security/device_auth/services:deviceauth_sdk", "//foundation/communication/dsoftbus/sdk:softbus_client", "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", "//foundation/distributedschedule/samgr_lite/samgr:samgr", @@ -93,24 +91,23 @@ if (defined(ohos_lite)) { "include/standard", "${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/authentication/showconfirm/standard", - "${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", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/config", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/authentication/showconfirm/standard", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/commonevent", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/timer", "${services_path}/include/ipc", "${services_path}/include/ipc/standard", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include", + "${servicesimpl_path}/include", "${innerkits_path}/native_cpp/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -140,9 +137,8 @@ if (defined(ohos_lite)) { "${ext_path}/pin_auth/show_pin_dialog/dialog_ui/js:dialog_js_files_etc", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", - "//base/security/device_auth/services:deviceauth_sdk", "//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", "//utils/native/base:utils", ] diff --git a/ext/profile/BUILD.gn b/ext/profile/BUILD.gn index f33fa1ffba03f86ebfeaf21f809c64927c5e2dab..cde0584affc294e7fa236742080204dffbb5cc17 100644 --- a/ext/profile/BUILD.gn +++ b/ext/profile/BUILD.gn @@ -28,11 +28,11 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "${ext_path}/profile/include", - "${services_path}/include", - "${services_path}/include/adapter", - "${services_path}/include/dependency/softbus", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/dependency/softbus", "${services_path}/include/ipc/standard", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include/devicestate", "${utils_path}/include", "${utils_path}/include/ipc/standard", "${innerkits_path}/native_cpp/include", @@ -51,7 +51,7 @@ if (defined(ohos_lite)) { ] deps = [ - "${services_path}:devicemanagerservice", + "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutils", "//utils/native/base:utils", ] diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index b9b1286609bdb085bbc6ef06278aeecba68c5e4d..4034822f6d2f5fee17c4a42aa20dcde18cb6e68d 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -30,7 +30,7 @@ if (defined(ohos_lite)) { "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", - "${services_path}/include/dispatch", + "${servicesimpl_path}/include/dispatch", ] include_dirs += [ "//utils/native/lite/include", diff --git a/services/devicemanagerservice/include/deviceinfo/dm_device_info_manager.h b/services/devicemanagerservice/include/deviceinfo/dm_device_info_manager.h deleted file mode 100644 index 9504f32f8c01d69b409850ebdf901be16756f619..0000000000000000000000000000000000000000 --- a/services/devicemanagerservice/include/deviceinfo/dm_device_info_manager.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 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_DEVICEINFO_MANAGER_H -#define OHOS_DM_DEVICEINFO_MANAGER_H - -#include -#include - -#include "dm_adapter_manager.h" -#include "dm_device_info.h" -#include "softbus_connector.h" - -namespace OHOS { -namespace DistributedHardware { -class DmDeviceInfoManager { -public: - explicit DmDeviceInfoManager(std::shared_ptr &softbusConnectorPtr); - - /** - * @tc.name: DmDeviceInfoManager::GetTrustedDeviceList - * @tc.desc: Get TrustedDevice List of the DeviceManager DeviceInfo Manager - * @tc.type: FUNC - */ - int32_t GetTrustedDeviceList(const std::string &pkgName, const std::string &extra, - std::vector &deviceList); - - /** - * @tc.name: DmDeviceInfoManager::GetLocalDeviceInfo - * @tc.desc: Get Local DeviceInfo of the DeviceManager DeviceInfo Manager - * @tc.type: FUNC - */ - int32_t GetLocalDeviceInfo(DmDeviceInfo &info); - -private: - std::shared_ptr softbusConnector_; - std::string decisionSoName_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DM_DEVICEINFO_MANAGER_H diff --git a/services/devicemanagerservice/src/deviceinfo/dm_device_info_manager.cpp b/services/devicemanagerservice/src/deviceinfo/dm_device_info_manager.cpp deleted file mode 100644 index 37e9da3274c6632f3e37ecf8f105969349d9e825..0000000000000000000000000000000000000000 --- a/services/devicemanagerservice/src/deviceinfo/dm_device_info_manager.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2022 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 "dm_device_info_manager.h" - -#include "dm_constants.h" -#include "dm_log.h" - -namespace OHOS { -namespace DistributedHardware { -DmDeviceInfoManager::DmDeviceInfoManager(std::shared_ptr &softbusConnectorPtr) - : softbusConnector_(softbusConnectorPtr) -{ - LOGI("DmDeviceInfoManager constructor"); - decisionSoName_ = "libdevicemanagerext_decision.z.so"; -} - -int32_t DmDeviceInfoManager::GetTrustedDeviceList(const std::string &pkgName, const std::string &extra, - std::vector &deviceList) -{ - int32_t ret = softbusConnector_->GetTrustedDeviceList(deviceList); - if (ret != DM_OK) { - LOGE("GetTrustedDeviceList failed"); - return ret; - } - - if (!extra.empty() && !deviceList.empty()) { - DmAdapterManager &adapterMgrPtr = DmAdapterManager::GetInstance(); - std::shared_ptr decisionAdapter = adapterMgrPtr.GetDecisionAdapter(decisionSoName_); - if (decisionAdapter != nullptr) { - decisionAdapter->FilterDeviceList(deviceList, extra); - } else { - LOGE("GetTrustedDeviceList decisionAdapter is nullptr"); - } - } - - return DM_OK; -} - -int32_t DmDeviceInfoManager::GetLocalDeviceInfo(DmDeviceInfo &info) -{ - int32_t ret = softbusConnector_->GetLocalDeviceInfo(info); - if (ret != DM_OK) { - LOGE("GetLocalDeviceInfo failed"); - return ret; - } - return DM_OK; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/implementation/BUILD.gn b/services/implementation/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9497bdb52fa45e4fc5f818d92811bf1546f37338 --- /dev/null +++ b/services/implementation/BUILD.gn @@ -0,0 +1,248 @@ +# Copyright (c) 2022 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/device_manager/device_manager.gni") + +if (defined(ohos_lite)) { + if (ohos_kernel_type == "liteos_m") { + static_library("devicemanagerservice_mini") { + include_dirs = [ + "${devicemanager_path}/interfaces/inner_kits/native_cpp/include", + "${devicemanager_path}/interfaces/inner_kits/native_cpp/include/notify", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/config", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/authentication/showconfirm/lite", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/commonevent", + "${servicesimpl_path}/include/dependency/multipleuser", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/mini", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/eventbus", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "//base/security/device_auth/interfaces/innerkits", + "//third_party/json/include", + "${utils_path}/include", + "${utils_path}/include/dfx", + "${utils_path}/include/dfx/lite", + "${utils_path}/include/permission/lite", + "foundation/multimedia/image_standard/mock/native/include", + "${servicesimpl_path}/include/dispatch", + "${ext_path}/pin_auth/include", + "${ext_path}/pin_auth/include/lite", + ] + + include_dirs += [ + "//base/security/device_auth/interfaces/innerkits", + "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", + "//utils/native/lite/include", + "//utils/system/safwk/native/include", + "//third_party/json/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", + "//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", + "//foundation/distributedhardware/device_manager/services/implementation/include/dependency/multipleuser", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", + ] + + sources = [ + "${services_path}/src/ability/lite/dm_ability_manager.cpp", + "${services_path}/src/adapter/standard/dm_adapter_manager.cpp", + "${services_path}/src/authentication/auth_message_processor.cpp", + "${services_path}/src/authentication/auth_request_state.cpp", + "${services_path}/src/authentication/auth_response_state.cpp", + "${services_path}/src/authentication/dm_auth_manager.cpp", + "${services_path}/src/authentication/showconfirm/lite/show_confirm.cpp", + "${services_path}/src/config/mini/dm_config_manager.cpp", + "${services_path}/src/config/mini/pin_auth.cpp", + "${services_path}/src/dependency/hichain/hichain_connector.cpp", + "${services_path}/src/dependency/mini/dm_mutex.cpp", + "${services_path}/src/dependency/mini/dm_thread.cpp", + "${services_path}/src/dependency/multipleuser/multiple_user_connector.cpp", + "${services_path}/src/dependency/softbus/softbus_connector.cpp", + "${services_path}/src/dependency/softbus/softbus_session.cpp", + "${services_path}/src/dependency/timer/mini/dm_timer.cpp", + "${services_path}/src/device_manager_service.cpp", + "${services_path}/src/deviceinfo/dm_device_info_manager.cpp", + "${services_path}/src/devicestate/dm_device_state_manager.cpp", + "${services_path}/src/discovery/dm_discovery_manager.cpp", + "${services_path}/src/dispatch/command_dispatch.cpp", + "${services_path}/src/dispatch/device_manager_service_listener_mini.cpp", + "${services_path}/src/dispatch/server_stub.cpp", + ] + + defines = [ + "__LITEOS_M__", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerserviceimpl\"", + "LOG_DOMAIN=0xD004100", + ] + + if (os_account_part_exists) { + defines += [ "OS_ACCOUNT_PART_EXISTS" ] + include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include" ] + } + + ldflags = dm_ldflags + + deps = [ + "${devicemanager_path}/interfaces/inner_kits/native_cpp:devicemanagersdk_mini", + "${utils_path}:devicemanagerutils_mini", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_static", + "//base/security/device_auth/services:deviceauth", + "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", + "//foundation/communication/dsoftbus/sdk:softbus_client", + "//foundation/distributedschedule/samgr_lite/samgr", + "//third_party/bounds_checking_function:libsec_static", + "//third_party/mbedtls", + "//utils/native/lite:utils", + ] + + external_deps = [ + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + ] + } + } +} else if (!support_jsapi) { + group("devicemanagerserviceimpl") { + deps = [] + } +} else { + config("devicemanagerserviceimpl_config") { + include_dirs = [ + "include", + "include/config", + "include/adapter", + "include/authentication", + "include/authentication/showconfirm/standard", + "include/ability", + "include/devicestate", + "include/discovery", + "include/dependency/commonevent", + "include/dependency/multipleuser", + "include/dependency/hichain", + "include/dependency/softbus", + "include/dependency/timer", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/fwkload/standard", + "${utils_path}/include/dfx", + "${utils_path}/include/dfx/standard", + "${utils_path}/include/permission/standard", + "//base/security/device_auth/interfaces/innerkits", + "//third_party/json/include", + "${services_path}/include", + "${services_path}/include/ipc/standard", + ] + + if (os_account_part_exists) { + include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include" ] + } + } + + ohos_shared_library("devicemanagerserviceimpl") { + sources = [ + "src/ability/standard/dm_ability_manager.cpp", + "src/adapter/standard/dm_adapter_manager.cpp", + "src/authentication/auth_message_processor.cpp", + "src/authentication/auth_request_state.cpp", + "src/authentication/auth_response_state.cpp", + "src/authentication/dm_auth_manager.cpp", + "src/authentication/showconfirm/standard/show_confirm.cpp", + "src/config/dm_config_manager.cpp", + "src/dependency/commonevent/dm_common_event_manager.cpp", + "src/dependency/hichain/hichain_connector.cpp", + "src/dependency/multipleuser/multiple_user_connector.cpp", + "src/dependency/softbus/softbus_connector.cpp", + "src/dependency/softbus/softbus_session.cpp", + "src/dependency/timer/dm_timer.cpp", + "src/device_manager_service_impl.cpp", + "src/devicestate/dm_device_state_manager.cpp", + "src/discovery/dm_discovery_manager.cpp", + ] + + public_configs = [ ":devicemanagerserviceimpl_config" ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerserviceimpl\"", + "LOG_DOMAIN=0xD004100", + ] + + deps = [ + "${aainnerkits_path}/ability_manager:ability_manager", + "${aaservices_path}/abilitymgr:abilityms", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/security/device_auth/services:deviceauth_sdk", + ] + + if (os_account_part_exists) { + defines += [ "OS_ACCOUNT_PART_EXISTS" ] + deps += [ "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits" ] + } + + if (!device_manager_no_interaction_auth) { + deps += [ + "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc", + "//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr", + ] + defines += [ "SUPPORT_GRAPHICS" ] + } + external_deps = [ + "ability_base:want", + "ability_runtime:app_manager", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "common_event_service:cesfwk_core", + "common_event_service:cesfwk_innerkits", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "hisysevent_native:libhisysevent", + "hitrace_native:hitrace_meter", + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + "startup_l2:syspara", + "startup_l2:syspara_watchagent", + "utils_base:utils", + ] + + subsystem_name = "distributedhardware" + + part_name = "device_manager" + } +} diff --git a/services/devicemanagerservice/include/ability/dm_ability_manager.h b/services/implementation/include/ability/dm_ability_manager.h similarity index 100% rename from services/devicemanagerservice/include/ability/dm_ability_manager.h rename to services/implementation/include/ability/dm_ability_manager.h diff --git a/services/devicemanagerservice/include/adapter/crypto_adapter.h b/services/implementation/include/adapter/crypto_adapter.h similarity index 100% rename from services/devicemanagerservice/include/adapter/crypto_adapter.h rename to services/implementation/include/adapter/crypto_adapter.h diff --git a/services/devicemanagerservice/include/adapter/decision_adapter.h b/services/implementation/include/adapter/decision_adapter.h similarity index 100% rename from services/devicemanagerservice/include/adapter/decision_adapter.h rename to services/implementation/include/adapter/decision_adapter.h diff --git a/services/devicemanagerservice/include/adapter/dm_adapter_manager.h b/services/implementation/include/adapter/dm_adapter_manager.h similarity index 100% rename from services/devicemanagerservice/include/adapter/dm_adapter_manager.h rename to services/implementation/include/adapter/dm_adapter_manager.h diff --git a/services/devicemanagerservice/include/adapter/profile_adapter.h b/services/implementation/include/adapter/profile_adapter.h similarity index 100% rename from services/devicemanagerservice/include/adapter/profile_adapter.h rename to services/implementation/include/adapter/profile_adapter.h diff --git a/services/devicemanagerservice/include/authentication/auth_message_processor.h b/services/implementation/include/authentication/auth_message_processor.h similarity index 100% rename from services/devicemanagerservice/include/authentication/auth_message_processor.h rename to services/implementation/include/authentication/auth_message_processor.h diff --git a/services/devicemanagerservice/include/authentication/auth_request_state.h b/services/implementation/include/authentication/auth_request_state.h similarity index 100% rename from services/devicemanagerservice/include/authentication/auth_request_state.h rename to services/implementation/include/authentication/auth_request_state.h diff --git a/services/devicemanagerservice/include/authentication/auth_response_state.h b/services/implementation/include/authentication/auth_response_state.h similarity index 100% rename from services/devicemanagerservice/include/authentication/auth_response_state.h rename to services/implementation/include/authentication/auth_response_state.h diff --git a/services/devicemanagerservice/include/authentication/authentication.h b/services/implementation/include/authentication/authentication.h similarity index 100% rename from services/devicemanagerservice/include/authentication/authentication.h rename to services/implementation/include/authentication/authentication.h diff --git a/services/devicemanagerservice/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h similarity index 98% rename from services/devicemanagerservice/include/authentication/dm_auth_manager.h rename to services/implementation/include/authentication/dm_auth_manager.h index 83726a5f8f684b6f7c8b270bd7bfa3d45e23ec3a..bada1758160f8d00e6923ded7236733b18fed2ba 100644 --- a/services/devicemanagerservice/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -22,7 +22,7 @@ #include "auth_request_state.h" #include "auth_response_state.h" #include "authentication.h" -#include "device_manager_service_listener.h" +#include "idevice_manager_service_listener.h" #include "dm_ability_manager.h" #include "dm_adapter_manager.h" #include "dm_constants.h" @@ -122,7 +122,7 @@ class DmAuthManager final : public ISoftbusSessionCallback, public std::enable_shared_from_this { public: DmAuthManager(std::shared_ptr softbusConnector, - std::shared_ptr listener, + std::shared_ptr listener, std::shared_ptr hiChainConnector_); ~DmAuthManager(); @@ -375,7 +375,7 @@ public: private: std::shared_ptr softbusConnector_; std::shared_ptr hiChainConnector_; - std::shared_ptr listener_; + std::shared_ptr listener_; std::shared_ptr adapterMgr_; std::map> authenticationMap_; std::shared_ptr authRequestState_ = nullptr; diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/implementation/include/authentication/showconfirm/lite/show_confirm.h similarity index 100% rename from services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h rename to services/implementation/include/authentication/showconfirm/lite/show_confirm.h diff --git a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h b/services/implementation/include/authentication/showconfirm/standard/show_confirm.h similarity index 100% rename from services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h rename to services/implementation/include/authentication/showconfirm/standard/show_confirm.h diff --git a/services/devicemanagerservice/include/config/dm_config_manager.h b/services/implementation/include/config/dm_config_manager.h similarity index 100% rename from services/devicemanagerservice/include/config/dm_config_manager.h rename to services/implementation/include/config/dm_config_manager.h diff --git a/services/devicemanagerservice/include/config/json_config.h b/services/implementation/include/config/json_config.h similarity index 100% rename from services/devicemanagerservice/include/config/json_config.h rename to services/implementation/include/config/json_config.h diff --git a/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h b/services/implementation/include/dependency/commonevent/dm_common_event_manager.h similarity index 100% rename from services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h rename to services/implementation/include/dependency/commonevent/dm_common_event_manager.h diff --git a/services/devicemanagerservice/include/dependency/hichain/hichain_connector.h b/services/implementation/include/dependency/hichain/hichain_connector.h similarity index 100% rename from services/devicemanagerservice/include/dependency/hichain/hichain_connector.h rename to services/implementation/include/dependency/hichain/hichain_connector.h diff --git a/services/devicemanagerservice/include/dependency/hichain/hichain_connector_callback.h b/services/implementation/include/dependency/hichain/hichain_connector_callback.h similarity index 100% rename from services/devicemanagerservice/include/dependency/hichain/hichain_connector_callback.h rename to services/implementation/include/dependency/hichain/hichain_connector_callback.h diff --git a/services/devicemanagerservice/include/dependency/mini/dm_mutex.h b/services/implementation/include/dependency/mini/dm_mutex.h similarity index 100% rename from services/devicemanagerservice/include/dependency/mini/dm_mutex.h rename to services/implementation/include/dependency/mini/dm_mutex.h diff --git a/services/devicemanagerservice/include/dependency/mini/dm_thread.h b/services/implementation/include/dependency/mini/dm_thread.h similarity index 100% rename from services/devicemanagerservice/include/dependency/mini/dm_thread.h rename to services/implementation/include/dependency/mini/dm_thread.h diff --git a/services/devicemanagerservice/include/dependency/multipleuser/multiple_user_connector.h b/services/implementation/include/dependency/multipleuser/multiple_user_connector.h similarity index 100% rename from services/devicemanagerservice/include/dependency/multipleuser/multiple_user_connector.h rename to services/implementation/include/dependency/multipleuser/multiple_user_connector.h diff --git a/services/devicemanagerservice/include/dependency/softbus/softbus_connector.h b/services/implementation/include/dependency/softbus/softbus_connector.h similarity index 80% rename from services/devicemanagerservice/include/dependency/softbus/softbus_connector.h rename to services/implementation/include/dependency/softbus/softbus_connector.h index bc20a47b44dc0e7fdda35ca1e44c210175725d47..c734a68c02fb411bebad62892c42f9b0e7c9ec12 100644 --- a/services/devicemanagerservice/include/dependency/softbus/softbus_connector.h +++ b/services/implementation/include/dependency/softbus/softbus_connector.h @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -32,10 +31,6 @@ namespace OHOS { namespace DistributedHardware { -void DeviceOnLine(std::map> stateCallbackMap, - DmDeviceInfo deviceInfo); -void DeviceOffLine(std::map> stateCallbackMap, - DmDeviceInfo deviceInfo); class SoftbusConnector { public: /** @@ -52,27 +47,6 @@ public: */ static void OnPublishFail(int publishId, PublishFailReason reason); - /** - * @tc.name: SoftbusConnector::OnSoftBusDeviceOnline - * @tc.desc: OnSoftBus DeviceOnline of the SoftbusConnector - * @tc.type: FUNC - */ - static void OnSoftBusDeviceOnline(NodeBasicInfo *info); - - /** - * @tc.name: SoftbusConnector::OnSoftbusDeviceOffline - * @tc.desc: OnSoftbus DeviceOffline of the SoftbusConnector - * @tc.type: FUNC - */ - static void OnSoftbusDeviceOffline(NodeBasicInfo *info); - - /** - * @tc.name: SoftbusConnector::OnSoftbusDeviceInfoChanged - * @tc.desc: OnSoftbus DeviceInfoChanged of the SoftbusConnector - * @tc.type: FUNC - */ - static void OnSoftbusDeviceInfoChanged(NodeBasicInfoType type, NodeBasicInfo *info); - /** * @tc.name: SoftbusConnector::OnSoftbusDeviceFound * @tc.desc: OnSoftbus DeviceFound of the SoftbusConnector @@ -145,16 +119,15 @@ public: int32_t RegisterSoftbusDiscoveryCallback(const std::string &pkgName, const std::shared_ptr callback); int32_t UnRegisterSoftbusDiscoveryCallback(const std::string &pkgName); - int32_t GetTrustedDeviceList(std::vector &deviceInfoList); - int32_t GetLocalDeviceInfo(DmDeviceInfo &deviceInfo); int32_t StartDiscovery(const DmSubscribeInfo &subscribeInfo); int32_t StopDiscovery(uint16_t subscribeId); std::shared_ptr GetSoftbusSession(); bool HaveDeviceInMap(std::string deviceId); + void HandleDeviceOnline(const DmDeviceInfo &info); + void HandleDeviceOffline(const DmDeviceInfo &info); private: int32_t Init(); - static int32_t CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nodeBasicInfo, DmDeviceInfo &dmDeviceInfo); static void CovertDeviceInfoToDmDevice(const DeviceInfo &deviceInfo, DmDeviceInfo &dmDeviceInfo); static ConnectionAddr *GetConnectAddrByType(DeviceInfo *deviceInfo, ConnectionAddrType type); @@ -165,7 +138,6 @@ private: NOT_ALLOW_BE_DISCOVERY = 2, }; static PulishStatus publishStatus; - static INodeStateCb softbusNodeStateCb_; static IDiscoveryCallback softbusDiscoveryCallback_; static IPublishCallback softbusPublishCallback_; std::shared_ptr softbusSession_; diff --git a/services/devicemanagerservice/include/dependency/softbus/softbus_discovery_callback.h b/services/implementation/include/dependency/softbus/softbus_discovery_callback.h similarity index 100% rename from services/devicemanagerservice/include/dependency/softbus/softbus_discovery_callback.h rename to services/implementation/include/dependency/softbus/softbus_discovery_callback.h diff --git a/services/devicemanagerservice/include/dependency/softbus/softbus_session.h b/services/implementation/include/dependency/softbus/softbus_session.h similarity index 100% rename from services/devicemanagerservice/include/dependency/softbus/softbus_session.h rename to services/implementation/include/dependency/softbus/softbus_session.h diff --git a/services/devicemanagerservice/include/dependency/softbus/softbus_session_callback.h b/services/implementation/include/dependency/softbus/softbus_session_callback.h similarity index 100% rename from services/devicemanagerservice/include/dependency/softbus/softbus_session_callback.h rename to services/implementation/include/dependency/softbus/softbus_session_callback.h diff --git a/services/devicemanagerservice/include/dependency/softbus/softbus_state_callback.h b/services/implementation/include/dependency/softbus/softbus_state_callback.h similarity index 100% rename from services/devicemanagerservice/include/dependency/softbus/softbus_state_callback.h rename to services/implementation/include/dependency/softbus/softbus_state_callback.h diff --git a/services/devicemanagerservice/include/dependency/timer/dm_timer.h b/services/implementation/include/dependency/timer/dm_timer.h similarity index 100% rename from services/devicemanagerservice/include/dependency/timer/dm_timer.h rename to services/implementation/include/dependency/timer/dm_timer.h diff --git a/services/implementation/include/device_manager_service_impl.h b/services/implementation/include/device_manager_service_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..9dccd133bde4f3391f90338e874dec18c916e453 --- /dev/null +++ b/services/implementation/include/device_manager_service_impl.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2022 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_SERVICE_IMPL_H +#define OHOS_DM_SERVICE_IMPL_H + +#include +#include + +#include "dm_ability_manager.h" +#include "dm_auth_manager.h" +#include "dm_device_info.h" +#include "dm_device_state_manager.h" +#include "dm_discovery_manager.h" +#include "idevice_manager_service_impl.h" +#include "single_instance.h" +#include "softbus_connector.h" + +namespace OHOS { +namespace DistributedHardware { +class DeviceManagerServiceImpl : public IDeviceManagerServiceImpl { +public: + DeviceManagerServiceImpl(); + virtual ~DeviceManagerServiceImpl(); + + int32_t Initialize(const std::shared_ptr &listener); + + void Release(); + + int32_t StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo, + const std::string &extra); + + int32_t StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId); + + int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, + const std::string &extra); + + int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId); + + int32_t VerifyAuthentication(const std::string &authParam); + + int32_t GetFaParam(std::string &pkgName, DmAuthParam &authParam); + + int32_t SetUserOperation(std::string &pkgName, int32_t action); + + int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra); + + int32_t UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra); + + void HandleDeviceOnline(const DmDeviceInfo &info); + + void HandleDeviceOffline(const DmDeviceInfo &info); + + int OnSessionOpened(int sessionId, int result); + + void OnSessionClosed(int sessionId); + + void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen); + +private: + std::shared_ptr authMgr_; + std::shared_ptr deviceStateMgr_; + std::shared_ptr discoveryMgr_; + std::shared_ptr softbusConnector_; + std::shared_ptr abilityMgr_; + std::shared_ptr hiChainConnector_; +}; + +using CreateDMServiceFuncPtr = IDeviceManagerServiceImpl *(*)(void); +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_SERVICE_IMPL_H diff --git a/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h b/services/implementation/include/devicestate/dm_device_state_manager.h old mode 100755 new mode 100644 similarity index 96% rename from services/devicemanagerservice/include/devicestate/dm_device_state_manager.h rename to services/implementation/include/devicestate/dm_device_state_manager.h index 06d9a1bc4595ea2eba6f7da156537c38b7e2378d..eec4a38c977cd47f9476f7ec54840c9f747f7ec1 --- a/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h +++ b/services/implementation/include/devicestate/dm_device_state_manager.h @@ -23,7 +23,7 @@ #else #include #endif -#include "device_manager_service_listener.h" +#include "idevice_manager_service_listener.h" #include "dm_adapter_manager.h" #include "softbus_connector.h" #include "dm_timer.h" @@ -42,7 +42,7 @@ 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(); @@ -159,7 +159,7 @@ private: std::mutex remoteDeviceInfosMutex_; #endif std::shared_ptr softbusConnector_; - std::shared_ptr listener_; + std::shared_ptr listener_; std::map remoteDeviceInfos_; std::map decisionInfos_; std::map stateTimerInfoMap_; diff --git a/services/devicemanagerservice/include/discovery/dm_discovery_manager.h b/services/implementation/include/discovery/dm_discovery_manager.h similarity index 94% rename from services/devicemanagerservice/include/discovery/dm_discovery_manager.h rename to services/implementation/include/discovery/dm_discovery_manager.h index 7234c97a157c25adb38c927114ed5f4feab8261d..81bfd3f493c643a03cb986b1eff9814834cd1d4b 100644 --- a/services/devicemanagerservice/include/discovery/dm_discovery_manager.h +++ b/services/implementation/include/discovery/dm_discovery_manager.h @@ -18,7 +18,7 @@ #include -#include "device_manager_service_listener.h" +#include "idevice_manager_service_listener.h" #include "dm_timer.h" #include "softbus_connector.h" namespace OHOS { @@ -33,7 +33,7 @@ class DmDiscoveryManager final : public ISoftbusDiscoveryCallback, public std::enable_shared_from_this { public: DmDiscoveryManager(std::shared_ptr softbusConnector, - std::shared_ptr listener); + std::shared_ptr listener); ~DmDiscoveryManager(); /** @@ -81,7 +81,7 @@ public: private: std::shared_ptr softbusConnector_; - std::shared_ptr listener_; + std::shared_ptr listener_; std::queue discoveryQueue_; std::map discoveryContextMap_; std::shared_ptr timer_; diff --git a/services/devicemanagerservice/include/dispatch/command_dispatch.h b/services/implementation/include/dispatch/command_dispatch.h similarity index 100% rename from services/devicemanagerservice/include/dispatch/command_dispatch.h rename to services/implementation/include/dispatch/command_dispatch.h diff --git a/services/devicemanagerservice/include/dispatch/server_stub.h b/services/implementation/include/dispatch/server_stub.h similarity index 100% rename from services/devicemanagerservice/include/dispatch/server_stub.h rename to services/implementation/include/dispatch/server_stub.h diff --git a/services/devicemanagerservice/src/ability/lite/dm_ability_manager.cpp b/services/implementation/src/ability/lite/dm_ability_manager.cpp similarity index 100% rename from services/devicemanagerservice/src/ability/lite/dm_ability_manager.cpp rename to services/implementation/src/ability/lite/dm_ability_manager.cpp diff --git a/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp b/services/implementation/src/ability/standard/dm_ability_manager.cpp similarity index 100% rename from services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp rename to services/implementation/src/ability/standard/dm_ability_manager.cpp diff --git a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp b/services/implementation/src/adapter/lite/dm_adapter_manager.cpp similarity index 100% rename from services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp rename to services/implementation/src/adapter/lite/dm_adapter_manager.cpp diff --git a/services/devicemanagerservice/src/adapter/standard/dm_adapter_manager.cpp b/services/implementation/src/adapter/standard/dm_adapter_manager.cpp similarity index 100% rename from services/devicemanagerservice/src/adapter/standard/dm_adapter_manager.cpp rename to services/implementation/src/adapter/standard/dm_adapter_manager.cpp diff --git a/services/devicemanagerservice/src/authentication/auth_message_processor.cpp b/services/implementation/src/authentication/auth_message_processor.cpp similarity index 100% rename from services/devicemanagerservice/src/authentication/auth_message_processor.cpp rename to services/implementation/src/authentication/auth_message_processor.cpp diff --git a/services/devicemanagerservice/src/authentication/auth_request_state.cpp b/services/implementation/src/authentication/auth_request_state.cpp similarity index 100% rename from services/devicemanagerservice/src/authentication/auth_request_state.cpp rename to services/implementation/src/authentication/auth_request_state.cpp diff --git a/services/devicemanagerservice/src/authentication/auth_response_state.cpp b/services/implementation/src/authentication/auth_response_state.cpp similarity index 100% rename from services/devicemanagerservice/src/authentication/auth_response_state.cpp rename to services/implementation/src/authentication/auth_response_state.cpp diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp similarity index 99% rename from services/devicemanagerservice/src/authentication/dm_auth_manager.cpp rename to services/implementation/src/authentication/dm_auth_manager.cpp index 36f423a8ff1cf6898fa16bbf4bf1e2abaff53628..ce134e4e644f7ce1289e54f4f3e5c232674acf74 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -43,7 +43,7 @@ const int32_t DEVICE_ID_HALF = 2; const int32_t MAX_AUTH_TIMES = 3; DmAuthManager::DmAuthManager(std::shared_ptr softbusConnector, - std::shared_ptr listener, + std::shared_ptr listener, std::shared_ptr hiChainConnector) : softbusConnector_(softbusConnector), hiChainConnector_(hiChainConnector), listener_(listener) { diff --git a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp b/services/implementation/src/authentication/showconfirm/lite/show_confirm.cpp similarity index 100% rename from services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp rename to services/implementation/src/authentication/showconfirm/lite/show_confirm.cpp diff --git a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp b/services/implementation/src/authentication/showconfirm/standard/show_confirm.cpp similarity index 99% rename from services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp rename to services/implementation/src/authentication/showconfirm/standard/show_confirm.cpp index c10272ba49a77acb4a186de3a431d8906ab41663..e7c59fb74edf13fb63ca819adf2fc1cb8a484caa 100644 --- a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp +++ b/services/implementation/src/authentication/showconfirm/standard/show_confirm.cpp @@ -61,4 +61,4 @@ void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr #include -#if defined(__LITEOS_M__) -#include "dm_mutex.h" -#include "dm_thread.h" -#else -#include -#include -#endif #include "dm_anonymous.h" #include "dm_constants.h" @@ -40,56 +33,14 @@ std::map> SoftbusConnector::discoveryDe std::map> SoftbusConnector::stateCallbackMap_ = {}; std::map> SoftbusConnector::discoveryCallbackMap_ = {}; -IPublishCallback SoftbusConnector::softbusPublishCallback_ = {.OnPublishSuccess = SoftbusConnector::OnPublishSuccess, - .OnPublishFail = SoftbusConnector::OnPublishFail}; - IDiscoveryCallback SoftbusConnector::softbusDiscoveryCallback_ = { .OnDeviceFound = SoftbusConnector::OnSoftbusDeviceFound, .OnDiscoverFailed = SoftbusConnector::OnSoftbusDiscoveryFailed, .OnDiscoverySuccess = SoftbusConnector::OnSoftbusDiscoverySuccess}; -INodeStateCb SoftbusConnector::softbusNodeStateCb_ = { - .events = EVENT_NODE_STATE_ONLINE | EVENT_NODE_STATE_OFFLINE | EVENT_NODE_STATE_INFO_CHANGED, - .onNodeOnline = SoftbusConnector::OnSoftBusDeviceOnline, - .onNodeOffline = SoftbusConnector::OnSoftbusDeviceOffline, - .onNodeBasicInfoChanged = SoftbusConnector::OnSoftbusDeviceInfoChanged}; - -void DeviceOnLine(std::map> stateCallbackMap, - DmDeviceInfo deviceInfo) -{ - LOGI("Device on line start"); -#if defined(__LITEOS_M__) - DmMutex lockDeviceOnLine; -#else - std::mutex lockDeviceOnLine; - std::lock_guard lock(lockDeviceOnLine); -#endif - for (auto &iter : stateCallbackMap) { - iter.second->OnDeviceOnline(iter.first, deviceInfo); - } - LOGI("Device on line end"); -} - -void DeviceOffLine(std::map> stateCallbackMap, - DmDeviceInfo deviceInfo) -{ - LOGI("Device off line start"); -#if defined(__LITEOS_M__) - DmMutex lockDeviceOffLine; -#else - std::mutex lockDeviceOffLine; - std::lock_guard lock(lockDeviceOffLine); -#endif - for (auto &iter : stateCallbackMap) { - iter.second->OnDeviceOffline(iter.first, deviceInfo); - } - LOGI("Device off line end"); -} - SoftbusConnector::SoftbusConnector() { softbusSession_ = std::make_shared(); - Init(); } SoftbusConnector::~SoftbusConnector() @@ -97,63 +48,6 @@ SoftbusConnector::~SoftbusConnector() LOGI("SoftbusConnector destructor"); } -int32_t SoftbusConnector::Init() -{ - int32_t ret; - int32_t retryTimes = 0; - do { - ret = RegNodeDeviceStateCb(DM_PKG_NAME.c_str(), &softbusNodeStateCb_); - if (ret != DM_OK) { - ++retryTimes; - LOGE("RegNodeDeviceStateCb failed with ret %d, retryTimes %d", ret, retryTimes); - usleep(SOFTBUS_CHECK_INTERVAL); - } - } while (ret != DM_OK); - - PublishInfo dmPublishInfo; - dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; - dmPublishInfo.mode = DiscoverMode::DISCOVER_MODE_ACTIVE; - dmPublishInfo.medium = ExchangeMedium::AUTO; - dmPublishInfo.freq = ExchangeFreq::HIGH; - dmPublishInfo.capability = DM_CAPABILITY_OSD; - dmPublishInfo.capabilityData = nullptr; - dmPublishInfo.dataLen = 0; -#if (defined(__LITEOS_M__) || defined(LITE_DEVICE)) - ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); - if (ret == DM_OK) { - publishStatus = ALLOW_BE_DISCOVERY; - } -#else - char discoverStatus[DISCOVER_STATUS_LEN + 1] = {0}; - ret = GetParameter(DISCOVER_STATUS_KEY.c_str(), "not exist", discoverStatus, DISCOVER_STATUS_LEN); - if (strcmp(discoverStatus, "not exist") == 0) { - ret = SetParameter(DISCOVER_STATUS_KEY.c_str(), DISCOVER_STATUS_ON.c_str()); - LOGI("service set parameter result is : %d", ret); - - ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); - if (ret == DM_OK) { - publishStatus = ALLOW_BE_DISCOVERY; - } - LOGI("service publish result is : %d", ret); - } else if (ret >= 0 && strcmp(discoverStatus, DISCOVER_STATUS_ON.c_str()) == 0) { - ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); - if (ret == DM_OK) { - publishStatus = ALLOW_BE_DISCOVERY; - } - LOGI("service publish result is : %d", ret); - } else if (ret >= 0 && strcmp(discoverStatus, DISCOVER_STATUS_OFF.c_str()) == 0) { - ret = UnPublishService(DM_PKG_NAME.c_str(), DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID); - if (ret == DM_OK) { - publishStatus = NOT_ALLOW_BE_DISCOVERY; - } - LOGI("service unpublish result is : %d", ret); - } - - ret = WatchParameter(DISCOVER_STATUS_KEY.c_str(), &SoftbusConnector::OnParameterChgCallback, nullptr); -#endif - return ret; -} - int32_t SoftbusConnector::RegisterSoftbusDiscoveryCallback(const std::string &pkgName, const std::shared_ptr callback) { @@ -180,48 +74,6 @@ int32_t SoftbusConnector::UnRegisterSoftbusStateCallback(const std::string &pkgN return DM_OK; } -int32_t SoftbusConnector::GetTrustedDeviceList(std::vector &deviceInfoList) -{ - LOGI("SoftbusConnector::GetTrustDevices start"); - int32_t infoNum = 0; - NodeBasicInfo *nodeInfo = nullptr; - int32_t ret = GetAllNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeInfo, &infoNum); - if (ret != 0) { - LOGE("GetAllNodeDeviceInfo failed with ret %d", ret); - return ERR_DM_FAILED; - } - DmDeviceInfo *info = (DmDeviceInfo *)malloc(sizeof(DmDeviceInfo) * (infoNum)); - if (info == nullptr) { - FreeNodeInfo(nodeInfo); - return ERR_DM_MALLOC_FAILED; - } - DmDeviceInfo **pInfoList = &info; - for (int32_t i = 0; i < infoNum; ++i) { - NodeBasicInfo *nodeBasicInfo = nodeInfo + i; - DmDeviceInfo *deviceInfo = *pInfoList + i; - CovertNodeBasicInfoToDmDevice(*nodeBasicInfo, *deviceInfo); - deviceInfoList.push_back(*deviceInfo); - } - FreeNodeInfo(nodeInfo); - free(info); - LOGI("SoftbusConnector::GetTrustDevices success, deviceCount %d", infoNum); - return DM_OK; -} - -int32_t SoftbusConnector::GetLocalDeviceInfo(DmDeviceInfo &deviceInfo) -{ - LOGI("SoftbusConnector::GetLocalDeviceInfo start"); - NodeBasicInfo nodeBasicInfo; - int32_t ret = GetLocalNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeBasicInfo); - if (ret != 0) { - LOGE("GetLocalNodeDeviceInfo failed with ret %d", ret); - return ERR_DM_FAILED; - } - CovertNodeBasicInfoToDmDevice(nodeBasicInfo, deviceInfo); - LOGI("SoftbusConnector::GetLocalDeviceInfo success"); - return DM_OK; -} - int32_t SoftbusConnector::StartDiscovery(const DmSubscribeInfo &dmSubscribeInfo) { SubscribeInfo subscribeInfo; @@ -424,27 +276,6 @@ ConnectionAddr *SoftbusConnector::GetConnectAddr(const std::string &deviceId, st return nullptr; } -int32_t SoftbusConnector::CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nodeBasicInfo, DmDeviceInfo &dmDeviceInfo) -{ - (void)memset_s(&dmDeviceInfo, sizeof(DmDeviceInfo), 0, sizeof(DmDeviceInfo)); - if (memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), nodeBasicInfo.networkId, - std::min(sizeof(dmDeviceInfo.deviceId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { - LOGE("CovertNodeBasicInfoToDmDevice copy deviceId data failed"); - } - - if (memcpy_s(dmDeviceInfo.networkId, sizeof(dmDeviceInfo.networkId), nodeBasicInfo.networkId, - std::min(sizeof(dmDeviceInfo.networkId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { - LOGE("CovertNodeBasicInfoToDmDevice copy networkId data failed"); - } - - if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), nodeBasicInfo.deviceName, - std::min(sizeof(dmDeviceInfo.deviceName), sizeof(nodeBasicInfo.deviceName))) != DM_OK) { - LOGE("CovertNodeBasicInfoToDmDevice copy deviceName data failed"); - } - dmDeviceInfo.deviceTypeId = nodeBasicInfo.deviceTypeId; - return DM_OK; -} - void SoftbusConnector::CovertDeviceInfoToDmDevice(const DeviceInfo &deviceInfo, DmDeviceInfo &dmDeviceInfo) { (void)memset_s(&dmDeviceInfo, sizeof(DmDeviceInfo), 0, sizeof(DmDeviceInfo)); @@ -465,41 +296,19 @@ void SoftbusConnector::CovertDeviceInfoToDmDevice(const DeviceInfo &deviceInfo, dmDeviceInfo.deviceTypeId = deviceInfo.devType; } -void SoftbusConnector::OnPublishSuccess(int publishId) +void SoftbusConnector::HandleDeviceOnline(const DmDeviceInfo &info) { - LOGI("SoftbusConnector::OnPublishSuccess, publishId: %d", publishId); -} - -void SoftbusConnector::OnPublishFail(int publishId, PublishFailReason reason) -{ - LOGI("SoftbusConnector::OnPublishFail failed, publishId: %d, reason: %d", publishId, reason); -} - -void SoftbusConnector::OnSoftBusDeviceOnline(NodeBasicInfo *info) -{ - LOGI("device online"); - if (info == nullptr) { - LOGE("SoftbusConnector::OnSoftbusDeviceOffline NodeBasicInfo is nullptr"); - return; + LOGI("HandleDeviceOnline: start handle device online event."); + for (auto &iter : stateCallbackMap_) { + iter.second->OnDeviceOnline(iter.first, info); } - DmDeviceInfo dmDeviceInfo; - CovertNodeBasicInfoToDmDevice(*info, dmDeviceInfo); -#if defined(__LITEOS_M__) - DmThread deviceOnLine(DeviceOnLine, stateCallbackMap_, dmDeviceInfo); - deviceOnLine.DmCreatThread(); -#else - std::thread deviceOnLine(DeviceOnLine, stateCallbackMap_, dmDeviceInfo); - deviceOnLine.detach(); -#endif - if (discoveryDeviceInfoMap_.empty()) { return; } - // remove the discovery node map uint8_t udid[UDID_BUF_LEN] = {0}; int32_t ret = - GetNodeKeyInfo(DM_PKG_NAME.c_str(), info->networkId, NodeDeviceInfoKey::NODE_KEY_UDID, udid, sizeof(udid)); + GetNodeKeyInfo(DM_PKG_NAME.c_str(), info.networkId, NodeDeviceInfoKey::NODE_KEY_UDID, udid, sizeof(udid)); if (ret != DM_OK) { LOGE("GetNodeKeyInfo failed"); return; @@ -509,26 +318,12 @@ void SoftbusConnector::OnSoftBusDeviceOnline(NodeBasicInfo *info) discoveryDeviceInfoMap_.erase(deviceId); } -void SoftbusConnector::OnSoftbusDeviceOffline(NodeBasicInfo *info) +void SoftbusConnector::HandleDeviceOffline(const DmDeviceInfo &info) { - if (info == nullptr) { - LOGE("OnSoftbusDeviceOffline NodeBasicInfo is nullptr"); - return; + LOGI("HandleDeviceOffline: start handle device offline event."); + for (auto &iter : stateCallbackMap_) { + iter.second->OnDeviceOffline(iter.first, info); } - DmDeviceInfo dmDeviceInfo; - CovertNodeBasicInfoToDmDevice(*info, dmDeviceInfo); -#if defined(__LITEOS_M__) - DmThread deviceOffLine(DeviceOffLine, stateCallbackMap_, dmDeviceInfo); - deviceOffLine.DmCreatThread(); -#else - std::thread deviceOffLine(DeviceOffLine, stateCallbackMap_, dmDeviceInfo); - deviceOffLine.detach(); -#endif -} - -void SoftbusConnector::OnSoftbusDeviceInfoChanged(NodeBasicInfoType type, NodeBasicInfo *info) -{ - LOGI("SoftbusConnector::OnSoftbusDeviceInfoChanged."); } void SoftbusConnector::OnSoftbusDeviceFound(const DeviceInfo *device) @@ -578,30 +373,5 @@ void SoftbusConnector::OnSoftbusDiscoverySuccess(int subscribeId) iter.second->OnDiscoverySuccess(iter.first, originId); } } - -void SoftbusConnector::OnParameterChgCallback(const char *key, const char *value, void *context) -{ - if (strcmp(value, DISCOVER_STATUS_ON.c_str()) == 0 && publishStatus != ALLOW_BE_DISCOVERY) { - PublishInfo dmPublishInfo; - dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; - dmPublishInfo.mode = DiscoverMode::DISCOVER_MODE_ACTIVE; - dmPublishInfo.medium = ExchangeMedium::AUTO; - dmPublishInfo.freq = ExchangeFreq::HIGH; - dmPublishInfo.capability = DM_CAPABILITY_OSD; - dmPublishInfo.capabilityData = nullptr; - dmPublishInfo.dataLen = 0; - int32_t ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); - if (ret == DM_OK) { - publishStatus = ALLOW_BE_DISCOVERY; - } - LOGI("service publish result is : %d", ret); - } else if (strcmp(value, DISCOVER_STATUS_OFF.c_str()) == 0 && publishStatus != NOT_ALLOW_BE_DISCOVERY) { - int32_t ret = UnPublishService(DM_PKG_NAME.c_str(), DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID); - if (ret == DM_OK) { - publishStatus = NOT_ALLOW_BE_DISCOVERY; - } - LOGI("service unpublish result is : %d", ret); - } -} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp b/services/implementation/src/dependency/softbus/softbus_session.cpp similarity index 86% rename from services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp rename to services/implementation/src/dependency/softbus/softbus_session.cpp index c13dc691a919fea786c100382338d4b29ebe2b14..7a49e6cddb21cc98d6d077ad1f93a32f8a96a6b7 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_session.cpp +++ b/services/implementation/src/dependency/softbus/softbus_session.cpp @@ -28,22 +28,10 @@ std::shared_ptr SoftbusSession::sessionCallback_ = null SoftbusSession::SoftbusSession() { - ISessionListener sessionListener = {.OnSessionOpened = SoftbusSession::OnSessionOpened, - .OnSessionClosed = SoftbusSession::OnSessionClosed, - .OnBytesReceived = SoftbusSession::OnBytesReceived, - .OnMessageReceived = nullptr, - .OnStreamReceived = nullptr}; - int32_t ret = CreateSessionServer(DM_PKG_NAME.c_str(), DM_SESSION_NAME.c_str(), &sessionListener); - if (ret != DM_OK) { - LOGE("CreateSessionServer failed"); - } else { - LOGI("CreateSessionServer ok"); - } } SoftbusSession::~SoftbusSession() { - RemoveSessionServer(DM_PKG_NAME.c_str(), DM_SESSION_NAME.c_str()); } int32_t SoftbusSession::RegisterSessionCallback(std::shared_ptr callback) diff --git a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp b/services/implementation/src/dependency/timer/dm_timer.cpp similarity index 100% rename from services/devicemanagerservice/src/dependency/timer/dm_timer.cpp rename to services/implementation/src/dependency/timer/dm_timer.cpp diff --git a/services/devicemanagerservice/src/dependency/timer/mini/dm_timer.cpp b/services/implementation/src/dependency/timer/mini/dm_timer.cpp similarity index 100% rename from services/devicemanagerservice/src/dependency/timer/mini/dm_timer.cpp rename to services/implementation/src/dependency/timer/mini/dm_timer.cpp diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/implementation/src/device_manager_service_impl.cpp similarity index 56% rename from services/devicemanagerservice/src/device_manager_service.cpp rename to services/implementation/src/device_manager_service_impl.cpp index 0c97d2342277ae3d2c44217948980873cd570f75..ddacec442a9ea631bb6a090af594aaba8ea5a197 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -13,13 +13,11 @@ * limitations under the License. */ -#include "device_manager_service.h" +#include "device_manager_service_impl.h" #include -#include "device_manager_service_listener.h" #include "dm_constants.h" -#include "dm_device_info_manager.h" #include "dm_log.h" #include "multiple_user_connector.h" #include "permission_manager.h" @@ -31,33 +29,19 @@ using namespace OHOS::EventFwk; namespace OHOS { namespace DistributedHardware { -IMPLEMENT_SINGLE_INSTANCE(DeviceManagerService); - -DeviceManagerService::~DeviceManagerService() +DeviceManagerServiceImpl::DeviceManagerServiceImpl() { - LOGI("DeviceManagerService destructor"); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance(); - if (dmCommonEventManager.UnsubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_STOPPED)) { - LOGI("subscribe service event success"); - } -#endif - softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback(); - hiChainConnector_->UnRegisterHiChainCallback(); + LOGI("DeviceManagerServiceImpl constructor"); } -int32_t DeviceManagerService::Init() +DeviceManagerServiceImpl::~DeviceManagerServiceImpl() { - if (intFlag_) { - LOGE("Init failed, singleton cannot be initialized multiple times"); - return ERR_DM_INIT_REPEATED; - } - - if (!PermissionManager::GetInstance().CheckPermission()) { - LOGI("The caller does not have permission to call"); - return ERR_DM_NO_PERMISSION; - } + LOGI("DeviceManagerServiceImpl destructor"); +} +int32_t DeviceManagerServiceImpl::Initialize(const std::shared_ptr &listener) +{ + LOGI("DeviceManagerServiceImpl Initialize"); if (softbusConnector_ == nullptr) { softbusConnector_ = std::make_shared(); if (softbusConnector_ == nullptr) { @@ -65,13 +49,6 @@ int32_t DeviceManagerService::Init() return ERR_DM_INIT_FAILED; } } - if (listener_ == nullptr) { - listener_ = std::make_shared(); - if (softbusConnector_ == nullptr) { - LOGE("Init failed, listener_ apply for failure"); - return ERR_DM_INIT_FAILED; - } - } if (hiChainConnector_ == nullptr) { hiChainConnector_ = std::make_shared(); if (hiChainConnector_ == nullptr) { @@ -79,15 +56,8 @@ int32_t DeviceManagerService::Init() return ERR_DM_INIT_FAILED; } } - if (deviceInfoMgr_ == nullptr) { - deviceInfoMgr_ = std::make_shared(softbusConnector_); - if (deviceInfoMgr_ == nullptr) { - LOGE("Init failed, deviceInfoMgr_ apply for failure"); - return ERR_DM_INIT_FAILED; - } - } if (deviceStateMgr_ == nullptr) { - deviceStateMgr_ = std::make_shared(softbusConnector_, listener_, hiChainConnector_); + deviceStateMgr_ = std::make_shared(softbusConnector_, listener, hiChainConnector_); if (deviceStateMgr_ == nullptr) { LOGE("Init failed, deviceStateMgr_ apply for failure"); return ERR_DM_INIT_FAILED; @@ -95,14 +65,14 @@ int32_t DeviceManagerService::Init() deviceStateMgr_->RegisterSoftbusStateCallback(); } if (discoveryMgr_ == nullptr) { - discoveryMgr_ = std::make_shared(softbusConnector_, listener_); + discoveryMgr_ = std::make_shared(softbusConnector_, listener); if (discoveryMgr_ == nullptr) { LOGE("Init failed, discoveryMgr_ apply for failure"); return ERR_DM_INIT_FAILED; } } if (authMgr_ == nullptr) { - authMgr_ = std::make_shared(softbusConnector_, listener_, hiChainConnector_); + authMgr_ = std::make_shared(softbusConnector_, listener, hiChainConnector_); if (authMgr_ == nullptr) { LOGE("Init failed, authMgr_ apply for failure"); return ERR_DM_INIT_FAILED; @@ -125,84 +95,36 @@ int32_t DeviceManagerService::Init() } #endif LOGI("Init success, singleton initialized"); - intFlag_ = true; return DM_OK; } -int32_t DeviceManagerService::GetTrustedDeviceList(const std::string &pkgName, const std::string &extra, - std::vector &deviceList) -{ - if (!PermissionManager::GetInstance().CheckPermission()) { - LOGI("The caller does not have permission to call"); - return ERR_DM_NO_PERMISSION; - } - if (!intFlag_) { - LOGE("GetTrustedDeviceList failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } - if (pkgName.empty()) { - LOGE("GetTrustedDeviceList failed, pkgName is empty"); - return ERR_DM_INPUT_PARAMETER_EMPTY; - } - return deviceInfoMgr_->GetTrustedDeviceList(pkgName, extra, deviceList); -} - -int32_t DeviceManagerService::GetLocalDeviceInfo(DmDeviceInfo &info) +void DeviceManagerServiceImpl::Release() { - if (!PermissionManager::GetInstance().CheckPermission()) { - LOGI("The caller does not have permission to call"); - return ERR_DM_NO_PERMISSION; - } - if (!intFlag_) { - LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } - return deviceInfoMgr_->GetLocalDeviceInfo(info); -} - -int32_t DeviceManagerService::GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId, - std::string &udid) -{ - if (!intFlag_) { - LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } - - if (pkgName.empty()) { - LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return ERR_DM_INPUT_PARAMETER_EMPTY; - } - SoftbusConnector::GetUdidByNetworkId(netWorkId.c_str(), udid); - return DM_OK; -} - -int32_t DeviceManagerService::GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId, - std::string &uuid) -{ - if (!intFlag_) { - LOGE("GetLocalDeviceInfo failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; + LOGI("DeviceManagerServiceImpl Release"); +#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) + DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance(); + if (dmCommonEventManager.UnsubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_STOPPED)) { + LOGI("subscribe service event success"); } +#endif + softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback(); + hiChainConnector_->UnRegisterHiChainCallback(); - if (pkgName.empty()) { - LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return ERR_DM_INPUT_PARAMETER_EMPTY; - } - SoftbusConnector::GetUuidByNetworkId(netWorkId.c_str(), uuid); - return DM_OK; + authMgr_ = nullptr; + deviceStateMgr_ = nullptr; + discoveryMgr_ = nullptr; + softbusConnector_ = nullptr; + abilityMgr_ = nullptr; + hiChainConnector_ = nullptr; } -int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo, - const std::string &extra) +int32_t DeviceManagerServiceImpl::StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo, + const std::string &extra) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); return ERR_DM_NO_PERMISSION; } - if (!intFlag_) { - LOGE("StartDeviceDiscovery failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } if (pkgName.empty()) { LOGE("StartDeviceDiscovery failed, pkgName is empty"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -210,16 +132,12 @@ int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, c return discoveryMgr_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); } -int32_t DeviceManagerService::StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId) +int32_t DeviceManagerServiceImpl::StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); return ERR_DM_NO_PERMISSION; } - if (!intFlag_) { - LOGE("StopDeviceDiscovery failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } if (pkgName.empty()) { LOGE("StopDeviceDiscovery failed, pkgName is empty"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -227,17 +145,13 @@ int32_t DeviceManagerService::StopDeviceDiscovery(const std::string &pkgName, ui return discoveryMgr_->StopDeviceDiscovery(pkgName, subscribeId); } -int32_t DeviceManagerService::AuthenticateDevice(const std::string &pkgName, int32_t authType, - const std::string &deviceId, const std::string &extra) +int32_t DeviceManagerServiceImpl::AuthenticateDevice(const std::string &pkgName, int32_t authType, + const std::string &deviceId, const std::string &extra) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); return ERR_DM_NO_PERMISSION; } - if (!intFlag_) { - LOGE("AuthenticateDevice failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } if (pkgName.empty()) { LOGE("AuthenticateDevice failed, pkgName is empty"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -249,16 +163,12 @@ int32_t DeviceManagerService::AuthenticateDevice(const std::string &pkgName, int return authMgr_->AuthenticateDevice(pkgName, authType, deviceId, extra); } -int32_t DeviceManagerService::UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId) +int32_t DeviceManagerServiceImpl::UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); return ERR_DM_NO_PERMISSION; } - if (!intFlag_) { - LOGE("UnAuthenticateDevice failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } if (pkgName.empty()) { LOGE("UnAuthenticateDevice failed, pkgName is empty"); return ERR_DM_INPUT_PARAMETER_EMPTY; @@ -270,20 +180,16 @@ int32_t DeviceManagerService::UnAuthenticateDevice(const std::string &pkgName, c return authMgr_->UnAuthenticateDevice(pkgName, deviceId); } -int32_t DeviceManagerService::VerifyAuthentication(const std::string &authParam) +int32_t DeviceManagerServiceImpl::VerifyAuthentication(const std::string &authParam) { if (!PermissionManager::GetInstance().CheckPermission()) { LOGI("The caller does not have permission to call"); return ERR_DM_NO_PERMISSION; } - if (!intFlag_) { - LOGE("VerifyAuthentication failed, singleton not init or init fail"); - return ERR_DM_NOT_INIT; - } return authMgr_->VerifyAuthentication(authParam); } -int32_t DeviceManagerService::GetFaParam(std::string &pkgName, DmAuthParam &authParam) +int32_t DeviceManagerServiceImpl::GetFaParam(std::string &pkgName, DmAuthParam &authParam) { if (pkgName.empty()) { LOGE("GetFaParam failed, pkgName is empty"); @@ -295,7 +201,7 @@ int32_t DeviceManagerService::GetFaParam(std::string &pkgName, DmAuthParam &auth return DM_OK; } -int32_t DeviceManagerService::SetUserOperation(std::string &pkgName, int32_t action) +int32_t DeviceManagerServiceImpl::SetUserOperation(std::string &pkgName, int32_t action) { if (pkgName.empty()) { LOGE("SetUserOperation failed, pkgName is empty"); @@ -307,7 +213,7 @@ int32_t DeviceManagerService::SetUserOperation(std::string &pkgName, int32_t act return DM_OK; } -int32_t DeviceManagerService::RegisterDevStateCallback(const std::string &pkgName, const std::string &extra) +int32_t DeviceManagerServiceImpl::RegisterDevStateCallback(const std::string &pkgName, const std::string &extra) { if (pkgName.empty()) { LOGE("RegisterDevStateCallback failed, pkgName is empty"); @@ -319,7 +225,7 @@ int32_t DeviceManagerService::RegisterDevStateCallback(const std::string &pkgNam return DM_OK; } -int32_t DeviceManagerService::UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra) +int32_t DeviceManagerServiceImpl::UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra) { if (pkgName.empty()) { LOGE("UnRegisterDevStateCallback failed, pkgName is empty"); @@ -331,9 +237,38 @@ int32_t DeviceManagerService::UnRegisterDevStateCallback(const std::string &pkgN return DM_OK; } -bool DeviceManagerService::IsServiceInitialized() +void DeviceManagerServiceImpl::HandleDeviceOnline(const DmDeviceInfo &info) +{ + if (softbusConnector_ != nullptr) { + softbusConnector_->HandleDeviceOnline(info); + } +} + +void DeviceManagerServiceImpl::HandleDeviceOffline(const DmDeviceInfo &info) +{ + if (softbusConnector_ != nullptr) { + softbusConnector_->HandleDeviceOffline(info); + } +} + +int DeviceManagerServiceImpl::OnSessionOpened(int sessionId, int result) +{ + return SoftbusSession::OnSessionOpened(sessionId, result); +} + +void DeviceManagerServiceImpl::OnSessionClosed(int sessionId) +{ + SoftbusSession::OnSessionClosed(sessionId); +} + +void DeviceManagerServiceImpl::OnBytesReceived(int sessionId, const void *data, unsigned int dataLen) +{ + SoftbusSession::OnBytesReceived(sessionId, data, dataLen); +} + +extern "C" IDeviceManagerServiceImpl *CreateDMServiceObject(void) { - return intFlag_; + return new DeviceManagerServiceImpl; } } // namespace DistributedHardware -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp b/services/implementation/src/devicestate/dm_device_state_manager.cpp old mode 100755 new mode 100644 similarity index 99% rename from services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp rename to services/implementation/src/devicestate/dm_device_state_manager.cpp index 0b089ef29e861c31878a08719def9820deaba97c..1032a6a0f137cd57c5adc4ecc7c36fcd58cb1ae6 --- a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp +++ b/services/implementation/src/devicestate/dm_device_state_manager.cpp @@ -24,7 +24,7 @@ namespace OHOS { namespace DistributedHardware { DmDeviceStateManager::DmDeviceStateManager(std::shared_ptr softbusConnector, - std::shared_ptr listener, std::shared_ptr hiChainConnector) + std::shared_ptr listener, std::shared_ptr hiChainConnector) : softbusConnector_(softbusConnector), listener_(listener), hiChainConnector_(hiChainConnector) { profileSoName_ = "libdevicemanagerext_profile.z.so"; diff --git a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp b/services/implementation/src/discovery/dm_discovery_manager.cpp similarity index 98% rename from services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp rename to services/implementation/src/discovery/dm_discovery_manager.cpp index 9ecadecf564bfeae30592d5934a7ed41d2044918..9dd3bdbfb37773b216762618e5ab6e2d0e449817 100644 --- a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp +++ b/services/implementation/src/discovery/dm_discovery_manager.cpp @@ -25,7 +25,7 @@ const std::string DISCOVERY_TIMEOUT_TASK = TIMER_PREFIX + "discovery"; const int32_t DISCOVERY_TIMEOUT = 120; DmDiscoveryManager::DmDiscoveryManager(std::shared_ptr softbusConnector, - std::shared_ptr listener) + std::shared_ptr listener) : softbusConnector_(softbusConnector), listener_(listener) { LOGI("DmDiscoveryManager constructor"); diff --git a/services/devicemanagerservice/src/dispatch/command_dispatch.cpp b/services/implementation/src/dispatch/command_dispatch.cpp similarity index 100% rename from services/devicemanagerservice/src/dispatch/command_dispatch.cpp rename to services/implementation/src/dispatch/command_dispatch.cpp diff --git a/services/devicemanagerservice/src/dispatch/device_manager_service_listener_mini.cpp b/services/implementation/src/dispatch/device_manager_service_listener_mini.cpp similarity index 98% rename from services/devicemanagerservice/src/dispatch/device_manager_service_listener_mini.cpp rename to services/implementation/src/dispatch/device_manager_service_listener_mini.cpp index 067f2ab8549e8386047cd6e272c059dadaa72646..8a346b51b3a1778c24c072355396b56898ccb47d 100644 --- a/services/devicemanagerservice/src/dispatch/device_manager_service_listener_mini.cpp +++ b/services/implementation/src/dispatch/device_manager_service_listener_mini.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "device_manager_service_listener.h" +#include "idevice_manager_service_listener.h" #include "dm_anonymous.h" #include "dm_constants.h" diff --git a/services/devicemanagerservice/src/dispatch/server_stub.cpp b/services/implementation/src/dispatch/server_stub.cpp similarity index 100% rename from services/devicemanagerservice/src/dispatch/server_stub.cpp rename to services/implementation/src/dispatch/server_stub.cpp diff --git a/services/devicemanagerservice/BUILD.gn b/services/service/BUILD.gn old mode 100755 new mode 100644 similarity index 65% rename from services/devicemanagerservice/BUILD.gn rename to services/service/BUILD.gn index 87535c8d22276142bc89c62894c2892ac1e2ea50..ebe2949acb882c958d118c9b10755e5af9a7abb6 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/service/BUILD.gn @@ -25,22 +25,21 @@ if (defined(ohos_lite)) { include_dirs = [ "${devicemanager_path}/interfaces/inner_kits/native_cpp/include", "${devicemanager_path}/interfaces/inner_kits/native_cpp/include/notify", - "${services_path}/include", - "${services_path}/include/config", - "${services_path}/include/adapter", - "${services_path}/include/authentication", - "${services_path}/include/authentication/showconfirm/lite", - "${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/multipleuser", - "${services_path}/include/dependency/hichain", - "${services_path}/include/dependency/softbus", - "${services_path}/include/dependency/mini", - "${services_path}/include/dependency/timer", - "${services_path}/include/eventbus", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/config", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/authentication/showconfirm/lite", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/commonevent", + "${servicesimpl_path}/include/dependency/multipleuser", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/mini", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/eventbus", "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -51,7 +50,7 @@ if (defined(ohos_lite)) { "${utils_path}/include/dfx/lite", "${utils_path}/include/permission/lite", "foundation/multimedia/image_standard/mock/native/include", - "${services_path}/include/dispatch", + "${servicesimpl_path}/include/dispatch", "${ext_path}/pin_auth/include", "${ext_path}/pin_auth/include/lite", ] @@ -70,7 +69,7 @@ if (defined(ohos_lite)) { "//foundation/communication/dsoftbus/interfaces/kits/discovery", "//foundation/communication/dsoftbus/interfaces/kits/transport", "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice/include/dependency/multipleuser", + "//foundation/distributedhardware/device_manager/services/implementation/include/dependency/multipleuser", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", ] @@ -89,7 +88,7 @@ if (defined(ohos_lite)) { "${services_path}/src/dependency/mini/dm_mutex.cpp", "${services_path}/src/dependency/mini/dm_thread.cpp", "${services_path}/src/dependency/multipleuser/multiple_user_connector.cpp", - "${services_path}/src/dependency/softbus/softbus_connector.cpp", + "${services_path}/src/dependency/softbus/softbus_listener.cpp", "${services_path}/src/dependency/softbus/softbus_session.cpp", "${services_path}/src/dependency/timer/mini/dm_timer.cpp", "${services_path}/src/device_manager_service.cpp", @@ -137,21 +136,8 @@ if (defined(ohos_lite)) { executable("devicemanagerservice") { include_dirs = [ "include", - "include/config", - "include/adapter", - "include/authentication", - "include/authentication/showconfirm/lite", - "include/ability", - "include/deviceinfo", - "include/devicestate", - "include/discovery", - "include/dependency/multipleuser/", - "include/dependency/hichain", - "include/dependency/softbus", - "include/dependency/timer", - "include", + "include/softbus", "include/ipc/lite", - "include/eventbus", "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -165,6 +151,7 @@ if (defined(ohos_lite)) { "${innerkits_path}/native_cpp/include/ipc", "${innerkits_path}/native_cpp/include/ipc/lite", ] + include_dirs += [ "//base/security/device_auth/interfaces/innerkits", "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", @@ -184,29 +171,7 @@ if (defined(ohos_lite)) { ] sources = [ - "src/ability/lite/dm_ability_manager.cpp", - "src/adapter/lite/dm_adapter_manager.cpp", - "src/authentication/auth_message_processor.cpp", - "src/authentication/auth_request_state.cpp", - "src/authentication/auth_response_state.cpp", - "src/authentication/dm_auth_manager.cpp", - "src/authentication/showconfirm/lite/show_confirm.cpp", - "src/config/dm_config_manager.cpp", - "src/dependency/hichain/hichain_connector.cpp", - "src/dependency/multipleuser/multiple_user_connector.cpp", - "src/dependency/softbus/softbus_connector.cpp", - "src/dependency/softbus/softbus_session.cpp", - "src/dependency/timer/dm_timer.cpp", - "src/device_manager_service.cpp", - "src/device_manager_service_listener.cpp", - "src/deviceinfo/dm_device_info_manager.cpp", - "src/devicestate/dm_device_state_manager.cpp", - "src/discovery/dm_discovery_manager.cpp", - "src/ipc/lite/ipc_cmd_parser.cpp", - "src/ipc/lite/ipc_server_listener.cpp", - "src/ipc/lite/ipc_server_listenermgr.cpp", "src/ipc/lite/ipc_server_main.cpp", - "src/ipc/lite/ipc_server_stub.cpp", ] ldflags = dm_ldflags @@ -218,7 +183,6 @@ if (defined(ohos_lite)) { ] deps = [ - "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", @@ -241,22 +205,9 @@ if (defined(ohos_lite)) { config("devicemanagerservice_config") { include_dirs = [ "include", - "include/config", - "include/adapter", - "include/authentication", - "include/authentication/showconfirm/standard", - "include/ability", - "include/deviceinfo", - "include/devicestate", - "include/discovery", - "include/dependency/commonevent", - "include/dependency/multipleuser", - "include/dependency/hichain", - "include/dependency/softbus", - "include/dependency/timer", + "include/softbus", "include/ipc", "include/ipc/standard", - "include/eventbus", "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -265,40 +216,18 @@ if (defined(ohos_lite)) { "${utils_path}/include/dfx", "${utils_path}/include/dfx/standard", "${utils_path}/include/permission/standard", - "//base/security/device_auth/interfaces/innerkits", - "//third_party/json/include", ] - - if (os_account_part_exists) { - include_dirs += [ "//base/account/os_account/interfaces/innerkits/osaccount/native/include" ] - } } ohos_shared_library("devicemanagerservice") { sources = [ - "src/ability/standard/dm_ability_manager.cpp", - "src/adapter/standard/dm_adapter_manager.cpp", - "src/authentication/auth_message_processor.cpp", - "src/authentication/auth_request_state.cpp", - "src/authentication/auth_response_state.cpp", - "src/authentication/dm_auth_manager.cpp", - "src/authentication/showconfirm/standard/show_confirm.cpp", - "src/config/dm_config_manager.cpp", - "src/dependency/commonevent/dm_common_event_manager.cpp", - "src/dependency/hichain/hichain_connector.cpp", - "src/dependency/multipleuser/multiple_user_connector.cpp", - "src/dependency/softbus/softbus_connector.cpp", - "src/dependency/softbus/softbus_session.cpp", - "src/dependency/timer/dm_timer.cpp", "src/device_manager_service.cpp", "src/device_manager_service_listener.cpp", - "src/deviceinfo/dm_device_info_manager.cpp", - "src/devicestate/dm_device_state_manager.cpp", - "src/discovery/dm_discovery_manager.cpp", "src/ipc/standard/ipc_cmd_parser.cpp", "src/ipc/standard/ipc_server_client_proxy.cpp", "src/ipc/standard/ipc_server_listener.cpp", "src/ipc/standard/ipc_server_stub.cpp", + "src/softbus/softbus_listener.cpp", ] public_configs = [ ":devicemanagerservice_config" ] @@ -317,30 +246,8 @@ if (defined(ohos_lite)) { "//base/security/device_auth/services:deviceauth_sdk", ] - if (os_account_part_exists) { - defines += [ "OS_ACCOUNT_PART_EXISTS" ] - deps += [ "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits" ] - } - - if (!device_manager_no_interaction_auth) { - deps += [ - "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc", - "//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr", - ] - defines += [ "SUPPORT_GRAPHICS" ] - } external_deps = [ - "ability_base:want", - "ability_runtime:app_manager", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", - "common_event_service:cesfwk_core", - "common_event_service:cesfwk_innerkits", "dsoftbus:softbus_client", - "eventhandler:libeventhandler", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", - "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr_standard:samgr_proxy", @@ -353,4 +260,4 @@ if (defined(ohos_lite)) { part_name = "device_manager" } -} +} \ No newline at end of file diff --git a/services/devicemanagerservice/include/device_manager_service.h b/services/service/include/device_manager_service.h similarity index 43% rename from services/devicemanagerservice/include/device_manager_service.h rename to services/service/include/device_manager_service.h index 31278f7b74b45d614c80938b18fa74a21ea46a11..1531c0ec1f5569efeac168ac8f27da52d130229f 100644 --- a/services/devicemanagerservice/include/device_manager_service.h +++ b/services/service/include/device_manager_service.h @@ -17,138 +17,76 @@ #define OHOS_DM_SERVICE_H #include -#include - -#include "dm_ability_manager.h" -#include "dm_auth_manager.h" -#include "dm_device_info.h" -#include "dm_device_info_manager.h" -#include "dm_device_state_manager.h" -#include "dm_discovery_manager.h" +#include +#if defined(__LITEOS_M__) +#include "dm_mutex.h" +#else +#include +#endif + +#include "device_manager_service_listener.h" +#include "idevice_manager_service_impl.h" #include "single_instance.h" -#include "softbus_connector.h" +#include "softbus_listener.h" namespace OHOS { namespace DistributedHardware { class DeviceManagerService { DECLARE_SINGLE_INSTANCE_BASE(DeviceManagerService); public: - int32_t Init(); + DeviceManagerService() {} + ~DeviceManagerService(); - /** - * @tc.name: DeviceManagerService::GetTrustedDeviceList - * @tc.desc: Get Trusted DeviceList of the Device Manager Service - * @tc.type: FUNC - */ + int32_t Init(); + int32_t GetTrustedDeviceList(const std::string &pkgName, const std::string &extra, std::vector &deviceList); - /** - * @tc.name: DeviceManagerService::GetLocalDeviceInfo - * @tc.desc: Get Local DeviceInfo of the Device Manager Service - * @tc.type: FUNC - */ int32_t GetLocalDeviceInfo(DmDeviceInfo &info); - /** - * @tc.name: DeviceManagerService::GetUdidByNetworkId - * @tc.desc: Get Udid By NetworkId of the Device Manager Service - * @tc.type: FUNC - */ int32_t GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &udid); - /** - * @tc.name: DeviceManagerService::GetUuidByNetworkId - * @tc.desc: Get Uuid By NetworkId of the Device Manager Service - * @tc.type: FUNC - */ int32_t GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &uuid); - /** - * @tc.name: DeviceManagerService::StartDeviceDiscovery - * @tc.desc: Start Device Discovery of the Device Manager Service - * @tc.type: FUNC - */ int32_t StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo, const std::string &extra); - /** - * @tc.name: DeviceManagerService::StopDeviceDiscovery - * @tc.desc: Stop Device Discovery of the Device Manager Service - * @tc.type: FUNC - */ int32_t StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId); - /** - * @tc.name: DeviceManagerService::AuthenticateDevice - * @tc.desc: Authenticate Device of the Device Manager Service - * @tc.type: FUNC - */ int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra); - /** - * @tc.name: DeviceManagerService::UnAuthenticateDevice - * @tc.desc: UnAuthenticate Device of the Device Manager Service - * @tc.type: FUNC - */ int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId); - /** - * @tc.name: DeviceManagerService::VerifyAuthentication - * @tc.desc: Verify Authentication of the Device Manager Service - * @tc.type: FUNC - */ int32_t VerifyAuthentication(const std::string &authParam); - /** - * @tc.name: DeviceManagerService::GetFaParam - * @tc.desc: Get FaParam of the Device Manager Service - * @tc.type: FUNC - */ int32_t GetFaParam(std::string &pkgName, DmAuthParam &authParam); - /** - * @tc.name: DeviceManagerService::SetUserOperation - * @tc.desc: Se tUser Operation of the Device Manager Service - * @tc.type: FUNC - */ int32_t SetUserOperation(std::string &pkgName, int32_t action); - /** - * @tc.name: DeviceManagerService::RegisterDevStateCallback - * @tc.desc: Register DevState Callback of the Device Manager Service - * @tc.type: FUNC - */ int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra); - /** - * @tc.name: DeviceManagerService::UnRegisterDevStateCallback - * @tc.desc: UnRegister DevState Callback of the Device Manager Service - * @tc.type: FUNC - */ int32_t UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra); - /** - * @tc.name: DeviceManagerService::IsServiceInitialized - * @tc.desc: IsServiceInitialized of the Device Manager Service - * @tc.type: FUNC - */ - bool IsServiceInitialized(); + void HandleDeviceOnline(const DmDeviceInfo &info); + + void HandleDeviceOffline(const DmDeviceInfo &info); + + int OnSessionOpened(int sessionId, int result); + + void OnSessionClosed(int sessionId); + + void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen); + + bool IsDMServiceImplReady(); private: - DeviceManagerService() = default; - bool intFlag_ = false; - std::shared_ptr authMgr_; - std::shared_ptr deviceInfoMgr_; - std::shared_ptr deviceStateMgr_; - std::shared_ptr discoveryMgr_; - std::shared_ptr softbusConnector_; + bool isImplsoLoaded_ = false; + std::shared_ptr softbusListener_; std::shared_ptr listener_; - std::shared_ptr abilityMgr_; - std::shared_ptr hiChainConnector_; + std::shared_ptr dmServiceImpl_; }; } // namespace DistributedHardware } // namespace OHOS -#endif // OHOS_DM_SERVICE_H +#endif // OHOS_DM_SERVICE_H \ No newline at end of file diff --git a/services/devicemanagerservice/include/device_manager_service_listener.h b/services/service/include/device_manager_service_listener.h similarity index 58% rename from services/devicemanagerservice/include/device_manager_service_listener.h rename to services/service/include/device_manager_service_listener.h index ce0b3e95e9e34d1e5777f8f8e4fe90c82b2b2861..eae8b1451b294ec71374cc55d12aa2b712c2a586 100644 --- a/services/devicemanagerservice/include/device_manager_service_listener.h +++ b/services/service/include/device_manager_service_listener.h @@ -20,65 +20,33 @@ #include #include "dm_device_info.h" +#include "idevice_manager_service_listener.h" #if !defined(__LITEOS_M__) #include "ipc_notify_dmfa_result_req.h" #include "ipc_server_listener.h" #endif - namespace OHOS { namespace DistributedHardware { -class DeviceManagerServiceListener { +class DeviceManagerServiceListener : public IDeviceManagerServiceListener { public: - /** - * @tc.name: DeviceManagerServiceListener::OnDeviceStateChange - * @tc.desc: Device State Change of the DeviceManager Service Listener - * @tc.type: FUNC - */ + DeviceManagerServiceListener() {}; + virtual ~DeviceManagerServiceListener() {}; + void OnDeviceStateChange(const std::string &pkgName, const DmDeviceState &state, const DmDeviceInfo &info); - /** - * @tc.name: DeviceManagerServiceListener::OnDeviceFound - * @tc.desc: Device Found of the DeviceManager Service Listener - * @tc.type: FUNC - */ void OnDeviceFound(const std::string &pkgName, uint16_t subscribeId, const DmDeviceInfo &info); - /** - * @tc.name: DeviceManagerServiceListener::OnDiscoveryFailed - * @tc.desc: Discovery Failed of the DeviceManager Service Listener - * @tc.type: FUNC - */ void OnDiscoveryFailed(const std::string &pkgName, uint16_t subscribeId, int32_t failedReason); - /** - * @tc.name: DeviceManagerServiceListener::OnDiscoverySuccess - * @tc.desc: Discovery Success of the DeviceManager Service Listener - * @tc.type: FUNC - */ void OnDiscoverySuccess(const std::string &pkgName, int32_t subscribeId); - /** - * @tc.name: DeviceManagerServiceListener::OnAuthResult - * @tc.desc: Auth Result of the DeviceManager Service Listener - * @tc.type: FUNC - */ void OnAuthResult(const std::string &pkgName, const std::string &deviceId, const std::string &token, int32_t status, int32_t reason); - /** - * @tc.name: DeviceManagerServiceListener::OnVerifyAuthResult - * @tc.desc: Verify Auth Result of the DeviceManager Service Listener - * @tc.type: FUNC - */ void OnVerifyAuthResult(const std::string &pkgName, const std::string &deviceId, int32_t resultCode, const std::string &flag); - /** - * @tc.name: DeviceManagerServiceListener::OnFaCall - * @tc.desc: Fa Call of the DeviceManager Service Listener - * @tc.type: FUNC - */ void OnFaCall(std::string &pkgName, std::string ¶mJson); private: @@ -88,4 +56,4 @@ private: }; } // namespace DistributedHardware } // namespace OHOS -#endif // OHOS_DM_SERVICE_LISTENER_H +#endif // OHOS_DM_SERVICE_LISTENER_H \ No newline at end of file diff --git a/services/service/include/idevice_manager_service_impl.h b/services/service/include/idevice_manager_service_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..4c8af0469d6e7837416baf1197eb98bc3f6b0eab --- /dev/null +++ b/services/service/include/idevice_manager_service_impl.h @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2022 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_I_DM_SERVICE_IMPL_H +#define OHOS_I_DM_SERVICE_IMPL_H + +#include +#include + +#include "idevice_manager_service_listener.h" +#include "dm_device_info.h" +#include "dm_subscribe_info.h" + +namespace OHOS { +namespace DistributedHardware { +class IDeviceManagerServiceImpl { +public: + virtual ~IDeviceManagerServiceImpl() {} + + /** + * @tc.name: IDeviceManagerServiceImpl::Initialize + * @tc.desc: Initialize the device manager service impl + * @tc.type: FUNC + */ + virtual int32_t Initialize(const std::shared_ptr &listener); + + /** + * @tc.name: IDeviceManagerServiceImpl::Release + * @tc.desc: Release the device manager service impl + * @tc.type: FUNC + */ + virtual void Release(); + + /** + * @tc.name: IDeviceManagerServiceImpl::StartDeviceDiscovery + * @tc.desc: Start Device Discovery of the device manager service impl + * @tc.type: FUNC + */ + virtual int32_t StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo, + const std::string &extra); + + /** + * @tc.name: IDeviceManagerServiceImpl::StopDeviceDiscovery + * @tc.desc: Stop Device Discovery of the device manager service impl + * @tc.type: FUNC + */ + virtual int32_t StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId); + + /** + * @tc.name: IDeviceManagerServiceImpl::AuthenticateDevice + * @tc.desc: Authenticate Device of the device manager service impl + * @tc.type: FUNC + */ + virtual int32_t AuthenticateDevice(const std::string &pkgName, int32_t authType, const std::string &deviceId, + const std::string &extra); + + /** + * @tc.name: IDeviceManagerServiceImpl::UnAuthenticateDevice + * @tc.desc: UnAuthenticate Device of the device manager service impl + * @tc.type: FUNC + */ + virtual int32_t UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId); + + /** + * @tc.name: IDeviceManagerServiceImpl::VerifyAuthentication + * @tc.desc: Verify Authentication of the device manager service impl + * @tc.type: FUNC + */ + virtual int32_t VerifyAuthentication(const std::string &authParam); + + /** + * @tc.name: IDeviceManagerServiceImpl::GetFaParam + * @tc.desc: Get FaParam of the device manager service impl + * @tc.type: FUNC + */ + virtual int32_t GetFaParam(std::string &pkgName, DmAuthParam &authParam); + + /** + * @tc.name: IDeviceManagerServiceImpl::SetUserOperation + * @tc.desc: Se tUser Operation of device manager service impl + * @tc.type: FUNC + */ + virtual int32_t SetUserOperation(std::string &pkgName, int32_t action); + + /** + * @tc.name: IDeviceManagerServiceImpl::RegisterDevStateCallback + * @tc.desc: Register Device State Callback to device manager service impl + * @tc.type: FUNC + */ + virtual int32_t RegisterDevStateCallback(const std::string &pkgName, const std::string &extra); + + /** + * @tc.name: IDeviceManagerServiceImpl::UnRegisterDevStateCallback + * @tc.desc: UnRegister Device State Callback to device manager service impl + * @tc.type: FUNC + */ + virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra); + + /** + * @tc.name: IDeviceManagerServiceImpl::HandleDeviceOnline + * @tc.desc: Handle Device Online to the device manager service impl + * @tc.type: FUNC + */ + virtual void HandleDeviceOnline(const DmDeviceInfo &info); + + /** + * @tc.name: IDeviceManagerServiceImpl::HandleDeviceOffline + * @tc.desc: Handle Device Offline to the device manager service impl + * @tc.type: FUNC + */ + virtual void HandleDeviceOffline(const DmDeviceInfo &info); + + /** + * @tc.name: IDeviceManagerServiceImpl::OnSessionOpened + * @tc.desc: Send Session Opened event to the device manager service impl + * @tc.type: FUNC + */ + virtual int OnSessionOpened(int sessionId, int result); + + /** + * @tc.name: IDeviceManagerServiceImpl::OnSessionClosed + * @tc.desc: Send Session Closed event to the device manager service impl + * @tc.type: FUNC + */ + virtual void OnSessionClosed(int sessionId); + + /** + * @tc.name: IDeviceManagerServiceImpl::OnBytesReceived + * @tc.desc: Send Bytes Received event to the device manager service impl + * @tc.type: FUNC + */ + virtual void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen); +}; + +using CreateDMServiceFuncPtr = IDeviceManagerServiceImpl *(*)(void); +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_I_DM_SERVICE_IMPL_H diff --git a/services/service/include/idevice_manager_service_listener.h b/services/service/include/idevice_manager_service_listener.h new file mode 100644 index 0000000000000000000000000000000000000000..3c6aa2166b74a9f7592066f725b6cbcdbd148217 --- /dev/null +++ b/services/service/include/idevice_manager_service_listener.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2022 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_I_DM_SERVICE_LISTENER_H +#define OHOS_I_DM_SERVICE_LISTENER_H + +#include +#include + +#include "dm_device_info.h" + +namespace OHOS { +namespace DistributedHardware { +class IDeviceManagerServiceListener { +public: + virtual ~IDeviceManagerServiceListener() {} + + /** + * @tc.name: IDeviceManagerServiceListener::OnDeviceStateChange + * @tc.desc: Device State Change of the DeviceManager Service Listener + * @tc.type: FUNC + */ + virtual void OnDeviceStateChange(const std::string &pkgName, const DmDeviceState &state, const DmDeviceInfo &info); + + /** + * @tc.name: IDeviceManagerServiceListener::OnDeviceFound + * @tc.desc: Device Found of the DeviceManager Service Listener + * @tc.type: FUNC + */ + virtual void OnDeviceFound(const std::string &pkgName, uint16_t subscribeId, const DmDeviceInfo &info); + + /** + * @tc.name: IDeviceManagerServiceListener::OnDiscoveryFailed + * @tc.desc: Discovery Failed of the DeviceManager Service Listener + * @tc.type: FUNC + */ + virtual void OnDiscoveryFailed(const std::string &pkgName, uint16_t subscribeId, int32_t failedReason); + + /** + * @tc.name: IDeviceManagerServiceListener::OnDiscoverySuccess + * @tc.desc: Discovery Success of the DeviceManager Service Listener + * @tc.type: FUNC + */ + virtual void OnDiscoverySuccess(const std::string &pkgName, int32_t subscribeId); + + /** + * @tc.name: IDeviceManagerServiceListener::OnAuthResult + * @tc.desc: Auth Result of the DeviceManager Service Listener + * @tc.type: FUNC + */ + virtual void OnAuthResult(const std::string &pkgName, const std::string &deviceId, const std::string &token, + int32_t status, int32_t reason); + + /** + * @tc.name: IDeviceManagerServiceListener::OnVerifyAuthResult + * @tc.desc: Verify Auth Result of the DeviceManager Service Listener + * @tc.type: FUNC + */ + virtual void OnVerifyAuthResult(const std::string &pkgName, const std::string &deviceId, int32_t resultCode, + const std::string &flag); + + /** + * @tc.name: IDeviceManagerServiceListener::OnFaCall + * @tc.desc: Fa Call of the DeviceManager Service Listener + * @tc.type: FUNC + */ + virtual void OnFaCall(std::string &pkgName, std::string ¶mJson); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_I_DM_SERVICE_LISTENER_H diff --git a/services/devicemanagerservice/include/ipc/lite/ipc_server_listener.h b/services/service/include/ipc/lite/ipc_server_listener.h similarity index 100% rename from services/devicemanagerservice/include/ipc/lite/ipc_server_listener.h rename to services/service/include/ipc/lite/ipc_server_listener.h diff --git a/services/devicemanagerservice/include/ipc/lite/ipc_server_listenermgr.h b/services/service/include/ipc/lite/ipc_server_listenermgr.h similarity index 100% rename from services/devicemanagerservice/include/ipc/lite/ipc_server_listenermgr.h rename to services/service/include/ipc/lite/ipc_server_listenermgr.h diff --git a/services/devicemanagerservice/include/ipc/lite/ipc_server_stub.h b/services/service/include/ipc/lite/ipc_server_stub.h similarity index 100% rename from services/devicemanagerservice/include/ipc/lite/ipc_server_stub.h rename to services/service/include/ipc/lite/ipc_server_stub.h diff --git a/services/devicemanagerservice/include/ipc/standard/ipc_server_client_proxy.h b/services/service/include/ipc/standard/ipc_server_client_proxy.h similarity index 100% rename from services/devicemanagerservice/include/ipc/standard/ipc_server_client_proxy.h rename to services/service/include/ipc/standard/ipc_server_client_proxy.h diff --git a/services/devicemanagerservice/include/ipc/standard/ipc_server_listener.h b/services/service/include/ipc/standard/ipc_server_listener.h similarity index 100% rename from services/devicemanagerservice/include/ipc/standard/ipc_server_listener.h rename to services/service/include/ipc/standard/ipc_server_listener.h diff --git a/services/devicemanagerservice/include/ipc/standard/ipc_server_stub.h b/services/service/include/ipc/standard/ipc_server_stub.h similarity index 99% rename from services/devicemanagerservice/include/ipc/standard/ipc_server_stub.h rename to services/service/include/ipc/standard/ipc_server_stub.h index 2fa555d06b3730f968f9dcb77c9f312cd48dd59e..ee8ed98c6af3fdb30af203d13c4708de9828810c 100644 --- a/services/devicemanagerservice/include/ipc/standard/ipc_server_stub.h +++ b/services/service/include/ipc/standard/ipc_server_stub.h @@ -22,7 +22,6 @@ #include #include -#include "hichain_connector.h" #include "ipc_remote_broker.h" #include "iremote_stub.h" #include "nlohmann/json.hpp" diff --git a/services/service/include/softbus/softbus_listener.h b/services/service/include/softbus/softbus_listener.h new file mode 100644 index 0000000000000000000000000000000000000000..526a691733eaa34d5cb97247bca28fe066725911 --- /dev/null +++ b/services/service/include/softbus/softbus_listener.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2022 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_SOFTBUS_LISTENER_H +#define OHOS_DM_SOFTBUS_LISTENER_H + +#include +#include +#include +#include +#include + +#include "discovery_service.h" +#include "dm_device_info.h" +#include "dm_subscribe_info.h" +#include "inner_session.h" +#include "session.h" +#include "softbus_bus_center.h" + +namespace OHOS { +namespace DistributedHardware { +void DeviceOnLine(DmDeviceInfo deviceInfo); +void DeviceOffLine(DmDeviceInfo deviceInfo); +class SoftbusListener { +public: + static int OnSessionOpened(int sessionId, int result); + static void OnSessionClosed(int sessionId); + static void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen); + +public: + /** + * @tc.name: SoftbusListener::OnPublishSuccess + * @tc.desc: OnPublishSuccess of the SoftbusListener + * @tc.type: FUNC + */ + static void OnPublishSuccess(int publishId); + + /** + * @tc.name: SoftbusListener::OnPublishFail + * @tc.desc: OnPublishFail of the SoftbusListener + * @tc.type: FUNC + */ + static void OnPublishFail(int publishId, PublishFailReason reason); + + /** + * @tc.name: SoftbusListener::OnSoftBusDeviceOnline + * @tc.desc: OnSoftBus DeviceOnline of the SoftbusListener + * @tc.type: FUNC + */ + static void OnSoftBusDeviceOnline(NodeBasicInfo *info); + + /** + * @tc.name: SoftbusListener::OnSoftbusDeviceOffline + * @tc.desc: OnSoftbus DeviceOffline of the SoftbusListener + * @tc.type: FUNC + */ + static void OnSoftbusDeviceOffline(NodeBasicInfo *info); + + /** + * @tc.name: SoftbusListener::OnSoftbusDeviceInfoChanged + * @tc.desc: OnSoftbus DeviceInfoChanged of the SoftbusListener + * @tc.type: FUNC + */ + static void OnSoftbusDeviceInfoChanged(NodeBasicInfoType type, NodeBasicInfo *info); + + /** + * @tc.name: SoftbusListener::OnPublishSuccess + * @tc.desc: OnParameter Chg Callback of the SoftbusListener + * @tc.type: FUNC + */ + static void OnParameterChgCallback(const char *key, const char *value, void *context); + + /** + * @tc.name: SoftbusListener::GetUdidByNetworkId + * @tc.desc: Get Udid By NetworkId of the SoftbusListener + * @tc.type: FUNC + */ + static int32_t GetUdidByNetworkId(const char *networkId, std::string &udid); + + /** + * @tc.name: SoftbusListener::GetUuidByNetworkId + * @tc.desc: Get Uuid By NetworkId of the SoftbusListener + * @tc.type: FUNC + */ + static int32_t GetUuidByNetworkId(const char *networkId, std::string &uuid); + +public: + SoftbusListener(); + ~SoftbusListener(); + int32_t GetTrustedDeviceList(std::vector &deviceInfoList); + int32_t GetLocalDeviceInfo(DmDeviceInfo &deviceInfo); + +private: + int32_t Init(); + static int32_t CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nodeBasicInfo, DmDeviceInfo &dmDeviceInfo); + +private: + enum PulishStatus { + STATUS_UNKNOWN = 0, + ALLOW_BE_DISCOVERY = 1, + NOT_ALLOW_BE_DISCOVERY = 2, + }; + static PulishStatus publishStatus; + static INodeStateCb softbusNodeStateCb_; + static IPublishCallback softbusPublishCallback_; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_SOFTBUS_LISTENER_H diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d8d7f734b6ec92b7b1f69e55063a515466665eb3 --- /dev/null +++ b/services/service/src/device_manager_service.cpp @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2022 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_manager_service.h" + +#include +#include + +#include "dm_constants.h" +#include "dm_log.h" +#include "permission_manager.h" +#include "dm_distributed_hardware_load.h" + +const std::string LIB_IMPL_NAME = "libdevicemanagerserviceimpl.z.so"; + +namespace OHOS { +namespace DistributedHardware { +IMPLEMENT_SINGLE_INSTANCE(DeviceManagerService); + +DeviceManagerService::~DeviceManagerService() +{ + LOGI("DeviceManagerService destructor"); + if (dmServiceImpl_ != nullptr) { + dmServiceImpl_->Release(); + } + std::string soPathName = LIB_LOAD_PATH + LIB_IMPL_NAME; + void *so_handle = dlopen(soPathName.c_str(), RTLD_NOW | RTLD_NOLOAD); + if (so_handle != nullptr) { + dlclose(so_handle); + } +} + +int32_t DeviceManagerService::Init() +{ + if (softbusListener_ == nullptr) { + softbusListener_ = std::make_shared(); + } + + if (listener_ == nullptr) { + listener_ = std::make_shared(); + } + + LOGI("Init success, dm service single instance initialized."); + return DM_OK; +} + +int32_t DeviceManagerService::GetTrustedDeviceList(const std::string &pkgName, const std::string &extra, + std::vector &deviceList) +{ + if (pkgName.empty()) { + LOGE("GetTrustedDeviceList failed, pkgName is empty"); + return ERR_DM_INPUT_PARAMETER_EMPTY; + } + if (!PermissionManager::GetInstance().CheckPermission()) { + LOGI("The caller does not have permission to call"); + return ERR_DM_NO_PERMISSION; + } + int32_t ret = softbusListener_->GetTrustedDeviceList(deviceList); + if (ret != DM_OK) { + LOGE("GetTrustedDeviceList failed"); + } + return ret; +} + +int32_t DeviceManagerService::GetLocalDeviceInfo(DmDeviceInfo &info) +{ + if (!PermissionManager::GetInstance().CheckPermission()) { + LOGI("The caller does not have permission to call"); + return ERR_DM_NO_PERMISSION; + } + int32_t ret = softbusListener_->GetLocalDeviceInfo(info); + if (ret != DM_OK) { + LOGE("GetLocalDeviceInfo failed"); + } + return ret; +} + +int32_t DeviceManagerService::GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId, + std::string &udid) +{ + if (pkgName.empty()) { + LOGE("GetUdidByNetworkId failed, pkgName is empty"); + return ERR_DM_INPUT_PARAMETER_EMPTY; + } + SoftbusListener::GetUdidByNetworkId(netWorkId.c_str(), udid); + return DM_OK; +} + +int32_t DeviceManagerService::GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId, + std::string &uuid) +{ + if (pkgName.empty()) { + LOGE("GetUuidByNetworkId failed, pkgName is empty"); + return ERR_DM_INPUT_PARAMETER_EMPTY; + } + SoftbusListener::GetUuidByNetworkId(netWorkId.c_str(), uuid); + return DM_OK; +} + +int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo, + const std::string &extra) +{ + if (!IsDMServiceImplReady()) { + LOGE("StartDeviceDiscovery failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->StartDeviceDiscovery(pkgName, subscribeInfo, extra); +} + +int32_t DeviceManagerService::StopDeviceDiscovery(const std::string &pkgName, uint16_t subscribeId) +{ + if (!IsDMServiceImplReady()) { + LOGE("StopDeviceDiscovery failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->StopDeviceDiscovery(pkgName, subscribeId); +} + +int32_t DeviceManagerService::AuthenticateDevice(const std::string &pkgName, int32_t authType, + const std::string &deviceId, const std::string &extra) +{ + if (!IsDMServiceImplReady()) { + LOGE("AuthenticateDevice failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->AuthenticateDevice(pkgName, authType, deviceId, extra); +} + +int32_t DeviceManagerService::UnAuthenticateDevice(const std::string &pkgName, const std::string &deviceId) +{ + if (!IsDMServiceImplReady()) { + LOGE("UnAuthenticateDevice failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->UnAuthenticateDevice(pkgName, deviceId); +} + +int32_t DeviceManagerService::VerifyAuthentication(const std::string &authParam) +{ + if (!IsDMServiceImplReady()) { + LOGE("VerifyAuthentication failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->VerifyAuthentication(authParam); +} + +int32_t DeviceManagerService::GetFaParam(std::string &pkgName, DmAuthParam &authParam) +{ + if (!IsDMServiceImplReady()) { + LOGE("GetFaParam failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->GetFaParam(pkgName, authParam); +} + +int32_t DeviceManagerService::SetUserOperation(std::string &pkgName, int32_t action) +{ + if (!IsDMServiceImplReady()) { + LOGE("SetUserOperation failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->SetUserOperation(pkgName, action); +} + +int32_t DeviceManagerService::RegisterDevStateCallback(const std::string &pkgName, const std::string &extra) +{ + if (!IsDMServiceImplReady()) { + LOGE("RegisterDevStateCallback failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->RegisterDevStateCallback(pkgName, extra); +} + +int32_t DeviceManagerService::UnRegisterDevStateCallback(const std::string &pkgName, const std::string &extra) +{ + if (!IsDMServiceImplReady()) { + LOGE("UnRegisterDevStateCallback failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->UnRegisterDevStateCallback(pkgName, extra); +} + +void DeviceManagerService::HandleDeviceOnline(const DmDeviceInfo &info) +{ + if (!IsDMServiceImplReady()) { + LOGE("HandleDeviceOnline failed, instance not init or init failed."); + return; + } + dmServiceImpl_->HandleDeviceOnline(info); +} + +void DeviceManagerService::HandleDeviceOffline(const DmDeviceInfo &info) +{ + if (!IsDMServiceImplReady()) { + LOGE("HandleDeviceOffline failed, instance not init or init failed."); + return; + } + dmServiceImpl_->HandleDeviceOffline(info); +} + +int DeviceManagerService::OnSessionOpened(int sessionId, int result) +{ + if (!IsDMServiceImplReady()) { + LOGE("OnSessionOpened failed, instance not init or init failed."); + return ERR_DM_NOT_INIT; + } + return dmServiceImpl_->OnSessionOpened(sessionId, result); +} + +void DeviceManagerService::OnSessionClosed(int sessionId) +{ + if (!IsDMServiceImplReady()) { + LOGE("OnSessionClosed failed, instance not init or init failed."); + return; + } + dmServiceImpl_->OnSessionClosed(sessionId); +} + +void DeviceManagerService::OnBytesReceived(int sessionId, const void *data, unsigned int dataLen) +{ + if (!IsDMServiceImplReady()) { + LOGE("OnBytesReceived failed, instance not init or init failed."); + return; + } + dmServiceImpl_->OnBytesReceived(sessionId, data, dataLen); +} + +bool DeviceManagerService::IsDMServiceImplReady() +{ + if (isImplsoLoaded_ && (dmServiceImpl_ != nullptr)) { + return true; + } + + std::string soName = LIB_LOAD_PATH + LIB_IMPL_NAME; + void *so_handle = dlopen(soName.c_str(), RTLD_NOW | RTLD_NOLOAD); + if (so_handle == nullptr) { + so_handle = dlopen(soName.c_str(), RTLD_NOW); + if (so_handle == nullptr) { + LOGE("load profile so %s failed.", soName.c_str()); + return false; + } + } + dlerror(); + auto func = (CreateDMServiceFuncPtr)dlsym(so_handle, "CreateDMServiceObject"); + if (dlerror() != nullptr || func == nullptr) { + LOGE("Create object function is not exist."); + return false; + } + + dmServiceImpl_ = std::shared_ptr(func()); + if (dmServiceImpl_->Initialize(listener_) != DM_OK) { + dlclose(so_handle); + dmServiceImpl_ = nullptr; + isImplsoLoaded_ = false; + return false; + } + isImplsoLoaded_ = true; + return true; +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/devicemanagerservice/src/device_manager_service_listener.cpp b/services/service/src/device_manager_service_listener.cpp similarity index 100% rename from services/devicemanagerservice/src/device_manager_service_listener.cpp rename to services/service/src/device_manager_service_listener.cpp diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp b/services/service/src/ipc/lite/ipc_cmd_parser.cpp similarity index 100% rename from services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp rename to services/service/src/ipc/lite/ipc_cmd_parser.cpp diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp b/services/service/src/ipc/lite/ipc_server_listener.cpp similarity index 100% rename from services/devicemanagerservice/src/ipc/lite/ipc_server_listener.cpp rename to services/service/src/ipc/lite/ipc_server_listener.cpp diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp b/services/service/src/ipc/lite/ipc_server_listenermgr.cpp similarity index 100% rename from services/devicemanagerservice/src/ipc/lite/ipc_server_listenermgr.cpp rename to services/service/src/ipc/lite/ipc_server_listenermgr.cpp diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp b/services/service/src/ipc/lite/ipc_server_main.cpp similarity index 69% rename from services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp rename to services/service/src/ipc/lite/ipc_server_main.cpp index 2472fc94aa38a5dcf4d228abeaf02bea2531ee42..f99170147c0069ce215c95170caf006f44b23d54 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp +++ b/services/service/src/ipc/lite/ipc_server_main.cpp @@ -16,26 +16,12 @@ #include #include -#include "device_manager_service.h" #include "dm_constants.h" -#include "dm_log.h" -#include "ipc_server_stub.h" - -using namespace OHOS::DistributedHardware; static void InitAll() { const int32_t DM_SERVICE_INIT_DELAY = 2; sleep(DM_SERVICE_INIT_DELAY); - if (IpcServerStubInit() != DM_OK) { - LOGI("IpcServerStubInit failed"); - return; - } - if (DeviceManagerService::GetInstance().Init() != DM_OK) { - LOGI("DeviceManagerServic init failed"); - return; - } - LOGI("DM ipc server Init success"); } int32_t main(int32_t argc, char *argv[]) diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/service/src/ipc/lite/ipc_server_stub.cpp similarity index 100% rename from services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp rename to services/service/src/ipc/lite/ipc_server_stub.cpp diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/service/src/ipc/standard/ipc_cmd_parser.cpp similarity index 99% rename from services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp rename to services/service/src/ipc/standard/ipc_cmd_parser.cpp index 998c45fddfe634644087f1658ce5d0c76a6d5081..41366190b90b85ab0b4228345bd0e8443f5fc0ed 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/service/src/ipc/standard/ipc_cmd_parser.cpp @@ -441,7 +441,7 @@ ON_IPC_CMD(SERVER_GET_DMFA_INFO, MessageParcel &data, MessageParcel &reply) std::string packName = data.ReadString(); DmAuthParam authParam; if (DeviceManagerService::GetInstance().GetFaParam(packName, authParam) != DM_OK) { - LOGE("ipc read fa param failed"); + LOGE("ipc read fa parm failed"); return ERR_DM_IPC_READ_FAILED; } int32_t appIconLen = authParam.imageinfo.GetAppIconLen(); diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp b/services/service/src/ipc/standard/ipc_server_client_proxy.cpp similarity index 100% rename from services/devicemanagerservice/src/ipc/standard/ipc_server_client_proxy.cpp rename to services/service/src/ipc/standard/ipc_server_client_proxy.cpp diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp b/services/service/src/ipc/standard/ipc_server_listener.cpp similarity index 100% rename from services/devicemanagerservice/src/ipc/standard/ipc_server_listener.cpp rename to services/service/src/ipc/standard/ipc_server_listener.cpp diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/service/src/ipc/standard/ipc_server_stub.cpp similarity index 90% rename from services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp rename to services/service/src/ipc/standard/ipc_server_stub.cpp index b311fad166e7196d73bb1a1e172f77c193d05d13..63d6e11789b1641bac5641cc732b214ff3257b5a 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/service/src/ipc/standard/ipc_server_stub.cpp @@ -126,11 +126,6 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< return ERR_DM_POINT_NULL; } - if (!DeviceManagerService::GetInstance().IsServiceInitialized()) { - LOGE("Device manager service has not been initialized or initialized failed."); - return ERR_DM_NOT_INIT; - } - LOGI("Register device manager listener for package name: %s", pkgName.c_str()); std::lock_guard autoLock(listenerLock_); auto iter = dmListener_.find(pkgName); @@ -138,17 +133,13 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(std::string &pkgName, sptr< LOGI("RegisterDeviceManagerListener: listener already exists"); return DM_OK; } - try { - sptr appRecipient = sptr(new AppDeathRecipient()); - if (!listener->AddDeathRecipient(appRecipient)) { - LOGE("RegisterDeviceManagerListener: AddDeathRecipient Failed"); - } - dmListener_[pkgName] = listener; - appRecipient_[pkgName] = appRecipient; - } catch (const std::bad_alloc &e) { - LOGE("new AppDeathRecipient failed"); - return ERR_DM_MALLOC_FAILED; + + sptr appRecipient = sptr(new AppDeathRecipient()); + if (!listener->AddDeathRecipient(appRecipient)) { + LOGE("RegisterDeviceManagerListener: AddDeathRecipient Failed"); } + dmListener_[pkgName] = listener; + appRecipient_[pkgName] = appRecipient; return DM_OK; } diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4b5c5e1ce6770efde84e4c97ebdb917133b0a73 --- /dev/null +++ b/services/service/src/softbus/softbus_listener.cpp @@ -0,0 +1,334 @@ +/* + * Copyright (c) 2022 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 "softbus_listener.h" + +#include +#include +#if defined(__LITEOS_M__) +#include "dm_mutex.h" +#include "dm_thread.h" +#else +#include +#include +#endif + +#include "device_manager_service.h" +#include "dm_anonymous.h" +#include "dm_constants.h" +#include "dm_device_info.h" +#include "dm_log.h" +#include "nlohmann/json.hpp" +#include "parameter.h" +#include "system_ability_definition.h" + +namespace OHOS { +namespace DistributedHardware { +SoftbusListener::PulishStatus SoftbusListener::publishStatus = SoftbusListener::STATUS_UNKNOWN; +IPublishCallback SoftbusListener::softbusPublishCallback_ = {.OnPublishSuccess = SoftbusListener::OnPublishSuccess, + .OnPublishFail = SoftbusListener::OnPublishFail}; + +INodeStateCb SoftbusListener::softbusNodeStateCb_ = { + .events = EVENT_NODE_STATE_ONLINE | EVENT_NODE_STATE_OFFLINE | EVENT_NODE_STATE_INFO_CHANGED, + .onNodeOnline = SoftbusListener::OnSoftBusDeviceOnline, + .onNodeOffline = SoftbusListener::OnSoftbusDeviceOffline, + .onNodeBasicInfoChanged = SoftbusListener::OnSoftbusDeviceInfoChanged}; + +void DeviceOnLine(DmDeviceInfo deviceInfo) +{ +#if defined(__LITEOS_M__) + DmMutex lockDeviceOnLine; +#else + std::mutex lockDeviceOnLine; + std::lock_guard lock(lockDeviceOnLine); +#endif + DeviceManagerService::GetInstance().HandleDeviceOnline(deviceInfo); +} + +void DeviceOffLine(DmDeviceInfo deviceInfo) +{ +#if defined(__LITEOS_M__) + DmMutex lockDeviceOffLine; +#else + std::mutex lockDeviceOffLine; + std::lock_guard lock(lockDeviceOffLine); +#endif + DeviceManagerService::GetInstance().HandleDeviceOffline(deviceInfo); +} + +SoftbusListener::SoftbusListener() +{ + ISessionListener sessionListener = {.OnSessionOpened = SoftbusListener::OnSessionOpened, + .OnSessionClosed = SoftbusListener::OnSessionClosed, + .OnBytesReceived = SoftbusListener::OnBytesReceived, + .OnMessageReceived = nullptr, + .OnStreamReceived = nullptr}; + int32_t ret = CreateSessionServer(DM_PKG_NAME.c_str(), DM_SESSION_NAME.c_str(), &sessionListener); + if (ret != DM_OK) { + LOGE("CreateSessionServer failed"); + } else { + LOGI("CreateSessionServer ok"); + } + Init(); +} + +SoftbusListener::~SoftbusListener() +{ + RemoveSessionServer(DM_PKG_NAME.c_str(), DM_SESSION_NAME.c_str()); + LOGI("SoftbusListener destructor"); +} + +int32_t SoftbusListener::Init() +{ + int32_t ret; + int32_t retryTimes = 0; + do { + ret = RegNodeDeviceStateCb(DM_PKG_NAME.c_str(), &softbusNodeStateCb_); + if (ret != DM_OK) { + ++retryTimes; + LOGE("RegNodeDeviceStateCb failed with ret %d, retryTimes %d", ret, retryTimes); + usleep(SOFTBUS_CHECK_INTERVAL); + } + } while (ret != DM_OK); + + PublishInfo dmPublishInfo; + dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; + dmPublishInfo.mode = DiscoverMode::DISCOVER_MODE_ACTIVE; + dmPublishInfo.medium = ExchangeMedium::AUTO; + dmPublishInfo.freq = ExchangeFreq::HIGH; + dmPublishInfo.capability = DM_CAPABILITY_OSD; + dmPublishInfo.capabilityData = nullptr; + dmPublishInfo.dataLen = 0; +#if (defined(__LITEOS_M__) || defined(LITE_DEVICE)) + ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); + if (ret == DM_OK) { + publishStatus = ALLOW_BE_DISCOVERY; + } +#else + char discoverStatus[DISCOVER_STATUS_LEN + 1] = {0}; + ret = GetParameter(DISCOVER_STATUS_KEY.c_str(), "not exist", discoverStatus, DISCOVER_STATUS_LEN); + if (strcmp(discoverStatus, "not exist") == 0) { + ret = SetParameter(DISCOVER_STATUS_KEY.c_str(), DISCOVER_STATUS_ON.c_str()); + LOGI("service set parameter result is : %d", ret); + + ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); + if (ret == DM_OK) { + publishStatus = ALLOW_BE_DISCOVERY; + } + LOGI("service publish result is : %d", ret); + } else if (ret >= 0 && strcmp(discoverStatus, DISCOVER_STATUS_ON.c_str()) == 0) { + ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); + if (ret == DM_OK) { + publishStatus = ALLOW_BE_DISCOVERY; + } + LOGI("service publish result is : %d", ret); + } else if (ret >= 0 && strcmp(discoverStatus, DISCOVER_STATUS_OFF.c_str()) == 0) { + ret = UnPublishService(DM_PKG_NAME.c_str(), DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID); + if (ret == DM_OK) { + publishStatus = NOT_ALLOW_BE_DISCOVERY; + } + LOGI("service unpublish result is : %d", ret); + } + + ret = WatchParameter(DISCOVER_STATUS_KEY.c_str(), &SoftbusListener::OnParameterChgCallback, nullptr); +#endif + return ret; +} + +int32_t SoftbusListener::GetTrustedDeviceList(std::vector &deviceInfoList) +{ + LOGI("SoftbusListener::GetTrustDevices start"); + int32_t infoNum = 0; + NodeBasicInfo *nodeInfo = nullptr; + int32_t ret = GetAllNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeInfo, &infoNum); + if (ret != 0) { + LOGE("GetAllNodeDeviceInfo failed with ret %d", ret); + return ERR_DM_FAILED; + } + DmDeviceInfo *info = (DmDeviceInfo *)malloc(sizeof(DmDeviceInfo) * (infoNum)); + if (info == nullptr) { + FreeNodeInfo(nodeInfo); + return ERR_DM_MALLOC_FAILED; + } + DmDeviceInfo **pInfoList = &info; + for (int32_t i = 0; i < infoNum; ++i) { + NodeBasicInfo *nodeBasicInfo = nodeInfo + i; + DmDeviceInfo *deviceInfo = *pInfoList + i; + CovertNodeBasicInfoToDmDevice(*nodeBasicInfo, *deviceInfo); + deviceInfoList.push_back(*deviceInfo); + } + FreeNodeInfo(nodeInfo); + free(info); + LOGI("SoftbusListener::GetTrustDevices success, deviceCount %d", infoNum); + return DM_OK; +} + +int32_t SoftbusListener::GetLocalDeviceInfo(DmDeviceInfo &deviceInfo) +{ + LOGI("SoftbusListener::GetLocalDeviceInfo start"); + NodeBasicInfo nodeBasicInfo; + int32_t ret = GetLocalNodeDeviceInfo(DM_PKG_NAME.c_str(), &nodeBasicInfo); + if (ret != 0) { + LOGE("GetLocalNodeDeviceInfo failed with ret %d", ret); + return ERR_DM_FAILED; + } + CovertNodeBasicInfoToDmDevice(nodeBasicInfo, deviceInfo); + LOGI("SoftbusListener::GetLocalDeviceInfo success"); + return DM_OK; +} + +int32_t SoftbusListener::GetUdidByNetworkId(const char *networkId, std::string &udid) +{ + LOGI("GetUdidByNetworkId begin"); + uint8_t mUdid[UDID_BUF_LEN] = {0}; + int32_t ret = + GetNodeKeyInfo(DM_PKG_NAME.c_str(), networkId, NodeDeviceInfoKey::NODE_KEY_UDID, mUdid, sizeof(mUdid)); + if (ret != DM_OK) { + LOGE("GetUdidByNetworkId GetNodeKeyInfo failed"); + return ERR_DM_FAILED; + } + udid = (char *)mUdid; + LOGI("SoftbusListener::GetUdidByNetworkId completed"); + return DM_OK; +} + +int32_t SoftbusListener::GetUuidByNetworkId(const char *networkId, std::string &uuid) +{ + LOGI("GetUuidByNetworkId begin"); + uint8_t mUuid[UUID_BUF_LEN] = {0}; + int32_t ret = + GetNodeKeyInfo(DM_PKG_NAME.c_str(), networkId, NodeDeviceInfoKey::NODE_KEY_UUID, mUuid, sizeof(mUuid)); + if (ret != DM_OK) { + LOGE("GetUuidByNetworkId GetNodeKeyInfo failed"); + return ERR_DM_FAILED; + } + uuid = (char *)mUuid; + LOGI("SoftbusListener::GetUuidByNetworkId completed"); + return DM_OK; +} + +void SoftbusListener::OnSoftBusDeviceOnline(NodeBasicInfo *info) +{ + LOGI("OnSoftBusDeviceOnline: received device online callback from softbus."); + if (info == nullptr) { + LOGE("SoftbusListener::OnSoftbusDeviceOffline NodeBasicInfo is nullptr"); + return; + } + DmDeviceInfo dmDeviceInfo; + CovertNodeBasicInfoToDmDevice(*info, dmDeviceInfo); +#if defined(__LITEOS_M__) + DmThread deviceOnLine(DeviceOnLine, dmDeviceInfo); + deviceOnLine.DmCreatThread(); +#else + std::thread deviceOnLine(DeviceOnLine, dmDeviceInfo); + deviceOnLine.detach(); +#endif +} + +void SoftbusListener::OnSoftbusDeviceOffline(NodeBasicInfo *info) +{ + LOGI("OnSoftBusDeviceOnline: received device offline callback from softbus."); + if (info == nullptr) { + LOGE("OnSoftbusDeviceOffline NodeBasicInfo is nullptr"); + return; + } + DmDeviceInfo dmDeviceInfo; + CovertNodeBasicInfoToDmDevice(*info, dmDeviceInfo); +#if defined(__LITEOS_M__) + DmThread deviceOffLine(DeviceOffLine, dmDeviceInfo); + deviceOffLine.DmCreatThread(); +#else + std::thread deviceOffLine(DeviceOffLine, dmDeviceInfo); + deviceOffLine.detach(); +#endif +} + +int32_t SoftbusListener::CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nodeBasicInfo, DmDeviceInfo &dmDeviceInfo) +{ + (void)memset_s(&dmDeviceInfo, sizeof(DmDeviceInfo), 0, sizeof(DmDeviceInfo)); + if (memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), nodeBasicInfo.networkId, + std::min(sizeof(dmDeviceInfo.deviceId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { + LOGE("CovertNodeBasicInfoToDmDevice copy deviceId data failed"); + } + + if (memcpy_s(dmDeviceInfo.networkId, sizeof(dmDeviceInfo.networkId), nodeBasicInfo.networkId, + std::min(sizeof(dmDeviceInfo.networkId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { + LOGE("CovertNodeBasicInfoToDmDevice copy networkId data failed"); + } + + if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), nodeBasicInfo.deviceName, + std::min(sizeof(dmDeviceInfo.deviceName), sizeof(nodeBasicInfo.deviceName))) != DM_OK) { + LOGE("CovertNodeBasicInfoToDmDevice copy deviceName data failed"); + } + dmDeviceInfo.deviceTypeId = nodeBasicInfo.deviceTypeId; + return DM_OK; +} + +void SoftbusListener::OnParameterChgCallback(const char *key, const char *value, void *context) +{ + if (strcmp(value, DISCOVER_STATUS_ON.c_str()) == 0 && publishStatus != ALLOW_BE_DISCOVERY) { + PublishInfo dmPublishInfo; + dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; + dmPublishInfo.mode = DiscoverMode::DISCOVER_MODE_ACTIVE; + dmPublishInfo.medium = ExchangeMedium::AUTO; + dmPublishInfo.freq = ExchangeFreq::HIGH; + dmPublishInfo.capability = DM_CAPABILITY_OSD; + dmPublishInfo.capabilityData = nullptr; + dmPublishInfo.dataLen = 0; + int32_t ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); + if (ret == DM_OK) { + publishStatus = ALLOW_BE_DISCOVERY; + } + LOGI("service publish result is : %d", ret); + } else if (strcmp(value, DISCOVER_STATUS_OFF.c_str()) == 0 && publishStatus != NOT_ALLOW_BE_DISCOVERY) { + int32_t ret = UnPublishService(DM_PKG_NAME.c_str(), DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID); + if (ret == DM_OK) { + publishStatus = NOT_ALLOW_BE_DISCOVERY; + } + LOGI("service unpublish result is : %d", ret); + } +} + +int SoftbusListener::OnSessionOpened(int sessionId, int result) +{ + return DeviceManagerService::GetInstance().OnSessionOpened(sessionId, result); +} + +void SoftbusListener::OnSessionClosed(int sessionId) +{ + DeviceManagerService::GetInstance().OnSessionClosed(sessionId); +} + +void SoftbusListener::OnBytesReceived(int sessionId, const void *data, unsigned int dataLen) +{ + DeviceManagerService::GetInstance().OnBytesReceived(sessionId, data, dataLen); +} + +void SoftbusListener::OnPublishSuccess(int publishId) +{ + LOGI("SoftbusListener::OnPublishSuccess, publishId: %d", publishId); +} + +void SoftbusListener::OnPublishFail(int publishId, PublishFailReason reason) +{ + LOGI("SoftbusListener::OnPublishFail failed, publishId: %d, reason: %d", publishId, reason); +} + +void SoftbusListener::OnSoftbusDeviceInfoChanged(NodeBasicInfoType type, NodeBasicInfo *info) +{ + LOGI("SoftbusListener::OnSoftbusDeviceInfoChanged."); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/test/benchmarktest/device_manager_fa_test/BUILD.gn b/test/benchmarktest/device_manager_fa_test/BUILD.gn index d79ddfcbd13e30767ac098d4dde6d62f660f2a6d..bb36da0327c95299930ddecf0593995005617ba8 100644 --- a/test/benchmarktest/device_manager_fa_test/BUILD.gn +++ b/test/benchmarktest/device_manager_fa_test/BUILD.gn @@ -46,7 +46,8 @@ ohos_benchmarktest("DeviceManagerFaTest") { "//foundation/arkui/napi:ace_napi", "//foundation/communication/dsoftbus/sdk:softbus_client", "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", "//third_party/benchmark:benchmark", "//third_party/bounds_checking_function:libsec_shared", "//third_party/googletest:gtest_main", diff --git a/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn index 2818d6135a222a873435b789b63ceb27b16ed4e2..f51fec0af96247743ab6bb12c1591bd3e7fd648d 100644 --- a/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn +++ b/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn @@ -36,19 +36,18 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "${utils_path}/include/ipc/standard", - "${services_path}/include", - "${services_path}/include/dependency/timer", - "${services_path}/include/discovery", - "${services_path}/include/dependency/softbus", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", - "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo/", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/ipc/standard", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/ipc_lite/interfaces/kits", @@ -57,13 +56,13 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", "//third_party/bounds_checking_function/include", diff --git a/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn b/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn index 7f2c5a9ec5b2d58a6f5f0261baaa81fa00e4b697..9d2af939839e02fe4522876d86215d6fd03dc33b 100644 --- a/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn +++ b/test/fuzztest/devicemanagernotify_fuzzer/BUILD.gn @@ -34,19 +34,18 @@ ohos_fuzztest("DeviceManagerNotifyFuzzTest") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include", - "${services_path}/include/dependency/timer", - "${services_path}/include/discovery", - "${services_path}/include/dependency/softbus", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", - "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo/", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/ipc/standard", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/ipc_lite/interfaces/kits", @@ -55,13 +54,13 @@ ohos_fuzztest("DeviceManagerNotifyFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", ] cflags = [ "-g", @@ -73,7 +72,8 @@ ohos_fuzztest("DeviceManagerNotifyFuzzTest") { deps = [ "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", ] defines = [ diff --git a/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn index f5b4794fbba11df2e6c3b2ca16f746e11eabeafc..e35cc6a36e20ddb2f4fe5af6236c69763716fccb 100644 --- a/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn +++ b/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn @@ -34,19 +34,19 @@ ohos_fuzztest("DeviceManagerServiceFuzzTest") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include", - "${services_path}/include/dependency/timer", - "${services_path}/include/discovery", - "${services_path}/include/dependency/softbus", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", - "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo/", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/ipc/standard", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo/", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/ipc_lite/interfaces/kits", @@ -55,13 +55,13 @@ ohos_fuzztest("DeviceManagerServiceFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", ] cflags = [ "-g", @@ -73,7 +73,8 @@ ohos_fuzztest("DeviceManagerServiceFuzzTest") { deps = [ "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", ] defines = [ diff --git a/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn b/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn index f0a744eb48940a9160e0da6cbee9b06806e663a0..c8014736e4e5d917ea0855b0cb6224a4384e12b0 100644 --- a/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn @@ -39,16 +39,16 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include/dependency/timer", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/dsoftbus/interfaces/kits/common", @@ -56,13 +56,13 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", "//third_party/bounds_checking_function/include", @@ -93,7 +93,8 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", "//base/security/device_auth/services:deviceauth_sdk", "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", ] defines = [ diff --git a/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn b/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn index dd72be71adc856b25b79ad5f0062898c6f4dd20f..3bf38f55213f7e3b00a8bfdb17ebf96fed82f81e 100644 --- a/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn +++ b/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn @@ -39,16 +39,16 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include/dependency/timer", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/dsoftbus/interfaces/kits/common", @@ -56,13 +56,13 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", "//third_party/bounds_checking_function/include", @@ -76,7 +76,7 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "//third_party/jsframework/runtime/main/extend/systemplugin", "//third_party/node/benchmark", "//third_party/libuv/include", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice/include/ipc/lite", + "//foundation/distributedhardware/device_manager/services/service/include/ipc/lite", ] cflags = [ "-g", @@ -94,7 +94,8 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", "//base/security/device_auth/services:deviceauth_sdk", "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", ] defines = [ diff --git a/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn b/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn index 4032a8e35aa1212b891599ef5de3d8d430910390..d07c46f8ba1cf4512629f1b9a9afdd2c64a378a0 100644 --- a/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn @@ -39,16 +39,16 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include/dependency/timer", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/dsoftbus/interfaces/kits/common", @@ -56,13 +56,13 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", "//third_party/bounds_checking_function/include", @@ -93,7 +93,8 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", "//base/security/device_auth/services:deviceauth_sdk", "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", ] defines = [ diff --git a/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn b/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn index d3f366c23c1f6ea870cef9fe36e3b7594d461556..846f6fe054c8235c9817fe17fce25b50e84238a6 100644 --- a/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn @@ -39,16 +39,16 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include/dependency/timer", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/dsoftbus/interfaces/kits/common", @@ -56,13 +56,13 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", "//third_party/bounds_checking_function/include", @@ -93,7 +93,8 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", "//base/security/device_auth/services:deviceauth_sdk", "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", ] defines = [ diff --git a/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn b/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn index f22c21c7607f3fe33494db43b0f44ddf19bf9d45..ba382651c690ca690d17b9feb0b9938ce84405c8 100644 --- a/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn +++ b/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn @@ -39,16 +39,16 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", - "${services_path}/include/dependency/timer", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo", - "${services_path}/include/devicestate", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo", + "${servicesimpl_path}/include/devicestate", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/dsoftbus/interfaces/kits/common", @@ -56,13 +56,13 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "//utils/native/lite/include", "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", "//third_party/bounds_checking_function/include", @@ -93,7 +93,8 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", "//base/security/device_auth/services:deviceauth_sdk", "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/device_manager/services/devicemanagerservice:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", + "//foundation/distributedhardware/device_manager/services/service:devicemanagerservice", ] defines = [ diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 1cd8bdf1d35a17d531b6f784b8b9b39078521fc3..1b2f8ca9f43956a7714b32552f12efe243aae5f9 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -29,7 +29,6 @@ group("unittest") { ":UTTest_device_profile_adapter", ":UTTest_dm_adapter_manager", ":UTTest_dm_auth_manager", - ":UTTest_dm_device_info_manager", ":UTTest_dm_device_state_manager", ":UTTest_dm_discovery_manager", ":UTTest_dm_timer", @@ -45,6 +44,7 @@ group("unittest") { ":UTTest_multiple_user_connector", ":UTTest_profile_connector", ":UTTest_softbus_connector", + ":UTTest_softbus_listener", ":UTTest_softbus_session", ] } @@ -126,32 +126,34 @@ ohos_unittest("UTTest_hichain_connector") { ## UnitTest UTTest_hichain_connector }}} -## UnitTest UTTest_dm_device_info_manager {{{ -ohos_unittest("UTTest_dm_device_info_manager") { +## UnitTest UTTest_softbus_listener {{{ +ohos_unittest("UTTest_softbus_listener") { module_out_path = module_out_path - sources = [ "UTTest_dm_device_info_manager.cpp" ] + sources = [ "UTTest_softbus_listener.cpp" ] deps = [ ":device_manager_test_common" ] } -## UnitTest UTTest_dm_device_info_manager }}} +## UnitTest UTTest_softbus_listener }}} ## UnitTest UTTest_softbus_connector {{{ ohos_unittest("UTTest_softbus_connector") { module_out_path = module_out_path sources = [ - "${services_path}/src/adapter/standard/dm_adapter_manager.cpp", - "${services_path}/src/config/dm_config_manager.cpp", - "${services_path}/src/dependency/hichain/hichain_connector.cpp", - "${services_path}/src/dependency/multipleuser/multiple_user_connector.cpp", - "${services_path}/src/dependency/softbus/softbus_connector.cpp", - "${services_path}/src/dependency/softbus/softbus_session.cpp", - "${services_path}/src/dependency/timer/dm_timer.cpp", + "${services_path}/src/device_manager_service.cpp", "${services_path}/src/device_manager_service_listener.cpp", - "${services_path}/src/devicestate/dm_device_state_manager.cpp", - "${services_path}/src/discovery/dm_discovery_manager.cpp", + "${services_path}/src/softbus/softbus_listener.cpp", + "${servicesimpl_path}/src/adapter/standard/dm_adapter_manager.cpp", + "${servicesimpl_path}/src/config/dm_config_manager.cpp", + "${servicesimpl_path}/src/dependency/hichain/hichain_connector.cpp", + "${servicesimpl_path}/src/dependency/multipleuser/multiple_user_connector.cpp", + "${servicesimpl_path}/src/dependency/softbus/softbus_connector.cpp", + "${servicesimpl_path}/src/dependency/softbus/softbus_session.cpp", + "${servicesimpl_path}/src/dependency/timer/dm_timer.cpp", + "${servicesimpl_path}/src/devicestate/dm_device_state_manager.cpp", + "${servicesimpl_path}/src/discovery/dm_discovery_manager.cpp", "//foundation/distributedhardware/device_manager/test/unittest/mock/ipc_server_listener.cpp", "//foundation/distributedhardware/device_manager/test/unittest/mock/parameter.cpp", "UTTest_softbus_connector.cpp", @@ -357,16 +359,18 @@ ohos_unittest("UTTest_dm_device_state_manager") { module_out_path = module_out_path sources = [ - "${services_path}/src/adapter/standard/dm_adapter_manager.cpp", - "${services_path}/src/config/dm_config_manager.cpp", - "${services_path}/src/dependency/hichain/hichain_connector.cpp", - "${services_path}/src/dependency/multipleuser/multiple_user_connector.cpp", - "${services_path}/src/dependency/softbus/softbus_connector.cpp", - "${services_path}/src/dependency/softbus/softbus_session.cpp", - "${services_path}/src/dependency/timer/dm_timer.cpp", + "${services_path}/src/device_manager_service.cpp", "${services_path}/src/device_manager_service_listener.cpp", - "${services_path}/src/devicestate/dm_device_state_manager.cpp", - "${services_path}/src/discovery/dm_discovery_manager.cpp", + "${services_path}/src/softbus/softbus_listener.cpp", + "${servicesimpl_path}/src/adapter/standard/dm_adapter_manager.cpp", + "${servicesimpl_path}/src/config/dm_config_manager.cpp", + "${servicesimpl_path}/src/dependency/hichain/hichain_connector.cpp", + "${servicesimpl_path}/src/dependency/multipleuser/multiple_user_connector.cpp", + "${servicesimpl_path}/src/dependency/softbus/softbus_connector.cpp", + "${servicesimpl_path}/src/dependency/softbus/softbus_session.cpp", + "${servicesimpl_path}/src/dependency/timer/dm_timer.cpp", + "${servicesimpl_path}/src/devicestate/dm_device_state_manager.cpp", + "${servicesimpl_path}/src/discovery/dm_discovery_manager.cpp", "//foundation/distributedhardware/device_manager/test/unittest/mock/ipc_server_listener.cpp", "//foundation/distributedhardware/device_manager/test/unittest/mock/parameter.cpp", "UTTest_dm_device_state_manager.cpp", @@ -456,11 +460,13 @@ ohos_unittest("UTTest_dm_discovery_manager") { module_out_path = module_out_path sources = [ - "${services_path}/src/dependency/softbus/softbus_connector.cpp", - "${services_path}/src/dependency/softbus/softbus_session.cpp", - "${services_path}/src/dependency/timer/dm_timer.cpp", + "${services_path}/src/device_manager_service.cpp", "${services_path}/src/device_manager_service_listener.cpp", - "${services_path}/src/discovery/dm_discovery_manager.cpp", + "${services_path}/src/softbus/softbus_listener.cpp", + "${servicesimpl_path}/src/dependency/softbus/softbus_connector.cpp", + "${servicesimpl_path}/src/dependency/softbus/softbus_session.cpp", + "${servicesimpl_path}/src/dependency/timer/dm_timer.cpp", + "${servicesimpl_path}/src/discovery/dm_discovery_manager.cpp", "//foundation/distributedhardware/device_manager/test/unittest/mock/ipc_server_listener.cpp", "//foundation/distributedhardware/device_manager/test/unittest/mock/parameter.cpp", "UTTest_dm_discovery_manager.cpp", @@ -488,19 +494,20 @@ config("device_manager_test_common_public_config") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/deviceinfo/", + "${servicesimpl_path}/include/devicestate", "${services_path}/include", - "${services_path}/include/dependency/timer", - "${services_path}/include/discovery", - "${services_path}/include/dependency/softbus", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", - "${services_path}/include/ipc/standard", - "${services_path}/include/discovery", - "${services_path}/include/dependency/hichain", - "${services_path}/include/deviceinfo/", - "${services_path}/include/devicestate", + "${services_path}/include/softbus", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/softbus_lite/interfaces/kits/transport", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", @@ -509,13 +516,13 @@ config("device_manager_test_common_public_config") { "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", "//foundation/distributedhardware/device_manager/test/unittest/mock", "//foundation/distributedschedule/safwk/interfaces/innerkits/safwk", - "//foundation/distributedhardware/device_manager/ext/mini/services/devicemanagerservice/include/dispatch", + "//foundation/distributedhardware/device_manager/ext/mini/services/service/include/dispatch", "//foundation/distributedhardware/device_manager/ext/profile/include", "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", "//foundation/distributedhardware/device_manager/ext/mini/common/include", "//base/security/device_auth/interfaces/innerkits", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", ] cflags = [ @@ -543,6 +550,7 @@ ohos_static_library("device_manager_test_common") { public_deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservice", + "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutils", "//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core", "//foundation/distributedhardware/device_manager/ext/profile:devicemanagerext_profile", @@ -570,22 +578,24 @@ config("device_manager_test_common_public") { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/standard", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/dependency/timer", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/dependency/hichain", + "${servicesimpl_path}/include/dependency/multipleuser", + "${servicesimpl_path}/include/dependency/softbus", + "${servicesimpl_path}/include/authentication", + "${servicesimpl_path}/include/adapter", + "${servicesimpl_path}/include", + "${servicesimpl_path}/include/discovery", + "${servicesimpl_path}/include/deviceinfo/", + "${servicesimpl_path}/include/devicestate", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "${services_path}/include", - "${services_path}/include/dependency/timer", - "${services_path}/include/discovery", - "${services_path}/include/dependency/softbus", - "${services_path}/include/dependency/hichain", - "${services_path}/include/dependency/multipleuser", - "${services_path}/include/dependency/softbus", - "${services_path}/include/authentication", - "${services_path}/include/adapter", - "${services_path}/include", - "${services_path}/include/discovery", - "${services_path}/include/deviceinfo/", - "${services_path}/include/devicestate", + "${services_path}/include/softbus", "//foundation/distributedhardware/device_manager/test/unittest/mock/", - "${services_path}/include/ability", - "${services_path}/include/config", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/communication/dsoftbus/interfaces/kits/common", diff --git a/test/unittest/UTTest_auth_message_processor.cpp b/test/unittest/UTTest_auth_message_processor.cpp index fd60acecb635e8e6bf8f6ebc94aaed892e16e74a..63b7ec948e6bf7e6b985237a10dcb2662edaecc1 100644 --- a/test/unittest/UTTest_auth_message_processor.cpp +++ b/test/unittest/UTTest_auth_message_processor.cpp @@ -13,13 +13,15 @@ * limitations under the License. */ +#include "UTTest_auth_message_processor.h" + #include "dm_log.h" #include "dm_constants.h" #include "auth_message_processor.h" #include "softbus_connector.h" #include "softbus_session.h" #include "dm_auth_manager.h" -#include "UTTest_auth_message_processor.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_auth_request_state.cpp b/test/unittest/UTTest_auth_request_state.cpp index 5e2326682e3acd9c357a6491d95026a5e1f58098..615da6e9d79333cb347f34df466116c987b1e602 100644 --- a/test/unittest/UTTest_auth_request_state.cpp +++ b/test/unittest/UTTest_auth_request_state.cpp @@ -18,6 +18,7 @@ #include "auth_message_processor.h" #include "dm_auth_manager.h" #include "dm_constants.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_auth_response_state.cpp b/test/unittest/UTTest_auth_response_state.cpp index 348bf9f33e6390abc6c44e0240f2744f287135c0..d0dcc3e9cbdfd9f278b1cf007ff5a1ad449fab0f 100644 --- a/test/unittest/UTTest_auth_response_state.cpp +++ b/test/unittest/UTTest_auth_response_state.cpp @@ -20,6 +20,7 @@ #include "dm_auth_manager.h" #include "dm_constants.h" #include "dm_log.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_device_manager_service.cpp b/test/unittest/UTTest_device_manager_service.cpp index c8ce9a54af05a941e7fcb6a48cec190cecdfe7f7..43645cd88be7aa98a8a1719359facf8a7cb10892 100644 --- a/test/unittest/UTTest_device_manager_service.cpp +++ b/test/unittest/UTTest_device_manager_service.cpp @@ -42,18 +42,17 @@ void DeviceManagerServiceTest::TearDownTestCase() namespace { /** * @tc.name: StartDeviceDiscovery_001 - * @tc.desc: Set StartDeviceDiscovery's flag bit intFlag_ to False and return ERR_DM_NOT_INIT + * @tc.desc: Start device discovery and return ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string pkgName = "com.ohos.test"; DmSubscribeInfo subscribeInfo; std::string extra = "test"; int ret = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeInfo, extra); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -92,17 +91,16 @@ HWTEST_F(DeviceManagerServiceTest, StartDeviceDiscovery_003, testing::ext::TestS /** * @tc.name: StopDeviceDiscovery_001 - * @tc.desc: Set StopDeviceDiscovery's flag bit intFlag_ to false and return ERR_DM_NOT_INIT + * @tc.desc: Stop device discovery and return ERR_DM_NOT_INIT * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string pkgName = "com.ohos.test"; uint16_t subscribeId = 1; int ret = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -128,10 +126,9 @@ HWTEST_F(DeviceManagerServiceTest, StopDeviceDiscovery_002, testing::ext::TestSi */ HWTEST_F(DeviceManagerServiceTest, GetLocalDeviceInfo_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; DmDeviceInfo info; int ret = DeviceManagerService::GetInstance().GetLocalDeviceInfo(info); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -156,9 +153,8 @@ HWTEST_F(DeviceManagerServiceTest, GetLocalDeviceInfo_002, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, Init_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; int ret = DeviceManagerService::GetInstance().Init(); - EXPECT_EQ(ret, ERR_DM_INIT_REPEATED); + EXPECT_EQ(ret, DM_OK); } /** @@ -169,7 +165,6 @@ HWTEST_F(DeviceManagerServiceTest, Init_001, testing::ext::TestSize.Level0) */ HWTEST_F(DeviceManagerServiceTest, Init_002, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::shared_ptr softbusConnector_ = nullptr; int ret = DeviceManagerService::GetInstance().Init(); EXPECT_EQ(ret, DM_OK); @@ -184,12 +179,11 @@ HWTEST_F(DeviceManagerServiceTest, Init_002, testing::ext::TestSize.Level0) HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string pkgName = "com.ohos.test"; std::string extra = "jdddd"; std::vector deviceList; int ret = DeviceManagerService::GetInstance().GetTrustedDeviceList(pkgName, extra, deviceList); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -200,7 +194,6 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_001, testing::ext::TestS */ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_002, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName; std::string extra = "jdddd"; std::vector deviceList; @@ -216,13 +209,12 @@ HWTEST_F(DeviceManagerServiceTest, GetTrustedDeviceList_002, testing::ext::TestS */ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string pkgName = "com.ohos.test"; std::string extra = "jdddd"; int32_t authType = 0; std::string deviceId = "2345"; int ret = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -233,7 +225,6 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_001, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_002, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName; std::string extra = "jdddd"; int32_t authType = 0; @@ -250,7 +241,6 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_002, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_003, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName = "com.ohos.test"; std::string extra = "jdddd"; int32_t authType = 0; @@ -266,7 +256,6 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_003, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_004, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName = "com.ohos.test"; std::string extra = "jdddd"; int32_t authType = 0; @@ -283,11 +272,10 @@ HWTEST_F(DeviceManagerServiceTest, AuthenticateDevice_004, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string pkgName = "com.ohos.test"; std::string deviceId = "12345"; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -298,7 +286,6 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_001, testing::ext::TestS */ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_002, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName; std::string deviceId = "12345"; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); @@ -314,7 +301,6 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_002, testing::ext::TestS */ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_003, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName = "com.ohos.test"; std::string deviceId; int ret = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId); @@ -330,10 +316,9 @@ HWTEST_F(DeviceManagerServiceTest, UnAuthenticateDevice_003, testing::ext::TestS */ HWTEST_F(DeviceManagerServiceTest, VerifyAuthentication_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string authParam = "jdjjjj"; int ret = DeviceManagerService::GetInstance().VerifyAuthentication(authParam); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -345,7 +330,6 @@ HWTEST_F(DeviceManagerServiceTest, VerifyAuthentication_001, testing::ext::TestS */ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName = "com.ohos.test"; std::string netWorkId = ""; std::string udid = ""; @@ -362,12 +346,11 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_001, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_002, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string pkgName = "com.ohos.test"; std::string netWorkId = ""; std::string udid = ""; int ret = DeviceManagerService::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -379,7 +362,6 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_002, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_003, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName = ""; std::string netWorkId = ""; std::string udid = ""; @@ -396,7 +378,6 @@ HWTEST_F(DeviceManagerServiceTest, GetUdidByNetworkId_003, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_001, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName = "com.ohos.test"; std::string netWorkId = ""; std::string uuid = ""; @@ -413,12 +394,11 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_001, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_002, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = false; std::string pkgName = "com.ohos.test"; std::string netWorkId = ""; std::string uuid = ""; int ret = DeviceManagerService::GetInstance().GetUuidByNetworkId(pkgName, netWorkId, uuid); - EXPECT_EQ(ret, ERR_DM_NOT_INIT); + EXPECT_EQ(ret, DM_OK); } /** @@ -430,7 +410,6 @@ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_002, testing::ext::TestSiz */ HWTEST_F(DeviceManagerServiceTest, GetUuidByNetworkId_003, testing::ext::TestSize.Level0) { - DeviceManagerService::GetInstance().intFlag_ = true; std::string pkgName = ""; std::string netWorkId = ""; std::string uuid = ""; diff --git a/test/unittest/UTTest_device_manager_service.h b/test/unittest/UTTest_device_manager_service.h index 59e92293e103c35399b88aaaf1e4560e36f13f57..47138c52dbe3aedbdff46b67076ab6714522e951 100644 --- a/test/unittest/UTTest_device_manager_service.h +++ b/test/unittest/UTTest_device_manager_service.h @@ -24,7 +24,6 @@ #include "device_manager_service.h" #include "device_manager_service_listener.h" #include "dm_auth_manager.h" -#include "dm_device_info_manager.h" #include "dm_device_state_manager.h" #include "dm_discovery_manager.h" #include "single_instance.h" diff --git a/test/unittest/UTTest_device_profile_adapter.cpp b/test/unittest/UTTest_device_profile_adapter.cpp index c07d386851cc48c5bcac18ea9b5fc0d4820d188d..7cb59d8e17a3b0fd05321ecaf812a5a69edd2bb9 100644 --- a/test/unittest/UTTest_device_profile_adapter.cpp +++ b/test/unittest/UTTest_device_profile_adapter.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "UTTest_device_profile_adapter.h" + #include "dm_constants.h" #include "dm_device_state_manager.h" #include "profile_adapter.h" @@ -20,7 +22,7 @@ #include "profile_connector.h" #include "device_profile_adapter.h" #include "distributed_device_profile_client.h" -#include "UTTest_device_profile_adapter.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { @@ -46,7 +48,7 @@ std::shared_ptr deviceStateMgr = std::make_shared #include "dm_log.h" @@ -24,7 +27,7 @@ #include "ipc_notify_device_found_req.h" #include "ipc_notify_discover_result_req.h" #include "hichain_connector.h" -#include "UTTest_dm_device_state_manager.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_dm_discovery_manager.cpp b/test/unittest/UTTest_dm_discovery_manager.cpp index c168d029586a20a791342dcecfef1e0e12ef2abf..b05a84c46c607f0c8f2c43a977e7f145bc94df49 100644 --- a/test/unittest/UTTest_dm_discovery_manager.cpp +++ b/test/unittest/UTTest_dm_discovery_manager.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "UTTest_dm_discovery_manager.h" + #include #include #include @@ -23,7 +25,7 @@ #include "ipc_server_listener.h" #include "device_manager_service_listener.h" #include "discovery_service.h" -#include "UTTest_dm_discovery_manager.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_dm_timer.cpp b/test/unittest/UTTest_dm_timer.cpp index 114cdde82e4a0c43c88458fb5d918d183c3477da..178fe123460d552cfdd8d81576de904c9b6710dd 100644 --- a/test/unittest/UTTest_dm_timer.cpp +++ b/test/unittest/UTTest_dm_timer.cpp @@ -101,7 +101,7 @@ HWTEST_F(TimeHeapTest, DeleteTimer_001, testing::ext::TestSize.Level0) EXPECT_EQ(ERR_DM_INPUT_PARAMETER_EMPTY, ret); ret = timer->DeleteTimer(name); - EXPECT_EQ(ERR_DM_INPUT_PARAMETER_EMPTY, ret); + EXPECT_EQ(DM_OK, ret); } /** diff --git a/test/unittest/UTTest_hichain_connector.cpp b/test/unittest/UTTest_hichain_connector.cpp index 5d407635fae8e020133ef28d109956543993e377..a928b8e14e1dde0ce562ae8577e60ce9db68b393 100644 --- a/test/unittest/UTTest_hichain_connector.cpp +++ b/test/unittest/UTTest_hichain_connector.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "UTTest_hichain_connector.h" + #include #include #include @@ -24,7 +26,7 @@ #include "dm_constants.h" #include "dm_random.h" #include "hichain_connector.h" -#include "UTTest_hichain_connector.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index 564b78a482aba7884dc38df65dffdbbf453c8b2b..a61aa6a0bf041b738fd6dc72776e5bf0dd78e974 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -13,8 +13,8 @@ * limitations under the License. */ - #include "UTTest_ipc_client_manager.h" + #include "device_manager_notify.h" #include "dm_device_info.h" #include "ipc_client_stub.h" diff --git a/test/unittest/UTTest_ipc_client_manager.h b/test/unittest/UTTest_ipc_client_manager.h index 909df5e887d7aed853d2e6a28de5ac818f00ab9f..ccedcdb3b6b9bac6fecb387f3c6eb4d36185cafb 100644 --- a/test/unittest/UTTest_ipc_client_manager.h +++ b/test/unittest/UTTest_ipc_client_manager.h @@ -22,6 +22,7 @@ #include "mock/mock_ipc_client_manager.h" #include "ipc_client_manager.h" #include "device_manager_callback.h" + namespace OHOS { namespace DistributedHardware { class IpcClientManagerTest : public testing::Test { diff --git a/test/unittest/UTTest_ipc_client_proxy.cpp b/test/unittest/UTTest_ipc_client_proxy.cpp index fa3d647991849cef363a27c9b0e84214435dcde0..1659f6e5fa45e6ae0ddd226c3cb642922e9e539c 100644 --- a/test/unittest/UTTest_ipc_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_proxy.cpp @@ -14,6 +14,9 @@ */ #include "UTTest_ipc_client_proxy.h" + +#include + #include "dm_device_info.h" #include "ipc_remote_broker.h" #include "iremote_object.h" @@ -22,8 +25,6 @@ #include "ipc_client_manager.h" #include "dm_constants.h" -#include - namespace OHOS { namespace DistributedHardware { void IpcClientProxyTest::SetUp() diff --git a/test/unittest/UTTest_ipc_client_proxy.h b/test/unittest/UTTest_ipc_client_proxy.h index a066594eb9f96f0153c130526ecff9a2522ad446..d7661723f81dfa42f3a4b1ce81f6698d14c38118 100644 --- a/test/unittest/UTTest_ipc_client_proxy.h +++ b/test/unittest/UTTest_ipc_client_proxy.h @@ -24,6 +24,7 @@ #include "ipc_client.h" #include "ipc_req.h" #include "ipc_rsp.h" + namespace OHOS { namespace DistributedHardware { class IpcClientProxyTest : public testing::Test { diff --git a/test/unittest/UTTest_ipc_client_server_proxy.cpp b/test/unittest/UTTest_ipc_client_server_proxy.cpp index a1b6886005f18c2838bcc5dce62f17ed6a52ebdb..7e9dd8759147ebafc7a24619edc63a2f550d43ed 100644 --- a/test/unittest/UTTest_ipc_client_server_proxy.cpp +++ b/test/unittest/UTTest_ipc_client_server_proxy.cpp @@ -14,7 +14,9 @@ */ #include "UTTest_ipc_client_server_proxy.h" + #include + #include "dm_constants.h" #include "dm_log.h" #include "ipc_cmd_register.h" @@ -24,7 +26,6 @@ #include "ipc_stop_discovery_req.h" #include "ipc_start_discovery_req.h" - namespace OHOS { namespace DistributedHardware { void IpcClientServerProxyTest::SetUp() diff --git a/test/unittest/UTTest_ipc_client_server_proxy.h b/test/unittest/UTTest_ipc_client_server_proxy.h index 8e3de0c10eaea4c93c18ef1cf528d02119f17465..1b9a0e227a83cf3de14ee8585d9f969855cb181a 100644 --- a/test/unittest/UTTest_ipc_client_server_proxy.h +++ b/test/unittest/UTTest_ipc_client_server_proxy.h @@ -22,6 +22,7 @@ #include "ipc_remote_broker.h" #include "ipc_client_server_proxy.h" #include "iremote_proxy.h" + namespace OHOS { namespace DistributedHardware { class IpcClientServerProxyTest : public testing::Test { diff --git a/test/unittest/UTTest_ipc_client_stub.cpp b/test/unittest/UTTest_ipc_client_stub.cpp index 7869d68175b11fd13b2924cc855ff05620e97fd9..73413d487575f70e04f52c4832b073fad3b49f0d 100644 --- a/test/unittest/UTTest_ipc_client_stub.cpp +++ b/test/unittest/UTTest_ipc_client_stub.cpp @@ -14,6 +14,9 @@ */ #include "UTTest_ipc_client_stub.h" + +#include + #include "dm_device_info.h" #include "ipc_remote_broker.h" #include "iremote_object.h" @@ -28,8 +31,6 @@ #include "ipc_def.h" #include "dm_constants.h" -#include - namespace OHOS { namespace DistributedHardware { void IpcClientStubTest::SetUp() diff --git a/test/unittest/UTTest_ipc_client_stub.h b/test/unittest/UTTest_ipc_client_stub.h index 748ac3eb9090fb75dd5916835326490111d93587..b906e3bc0b254be12e46437049223c7b1f76c19d 100644 --- a/test/unittest/UTTest_ipc_client_stub.h +++ b/test/unittest/UTTest_ipc_client_stub.h @@ -20,6 +20,7 @@ #include #include "ipc_client_stub.h" + namespace OHOS { namespace DistributedHardware { class IpcClientStubTest : public testing::Test { diff --git a/test/unittest/UTTest_ipc_cmd_register.cpp b/test/unittest/UTTest_ipc_cmd_register.cpp index 92ff36ccab0477bf515ec3e95c347ee6392d8ce0..2aece47f5e8aa9c5aa5638ffbf574173bdf26e53 100644 --- a/test/unittest/UTTest_ipc_cmd_register.cpp +++ b/test/unittest/UTTest_ipc_cmd_register.cpp @@ -14,7 +14,9 @@ */ #include "UTTest_ipc_cmd_register.h" + #include + #include "ipc_client_manager.h" #include "ipc_register_listener_req.h" #include "ipc_get_trustdevice_rsp.h" diff --git a/test/unittest/UTTest_ipc_cmd_register.h b/test/unittest/UTTest_ipc_cmd_register.h index f0ee2a0ac2872aae22529417c1dc36d8cc1aba99..f5cbc6ea8dfefbc7f02a25502147173e33f325d3 100644 --- a/test/unittest/UTTest_ipc_cmd_register.h +++ b/test/unittest/UTTest_ipc_cmd_register.h @@ -30,6 +30,7 @@ #include "ipc_types.h" #include "ipc_req.h" #include "ipc_rsp.h" + namespace OHOS { namespace DistributedHardware { class IpcCmdRegisterTest : public testing::Test { diff --git a/test/unittest/UTTest_ipc_server_client_proxy.cpp b/test/unittest/UTTest_ipc_server_client_proxy.cpp index e6254856836630d999e0b03036a5175cbab675d1..5a0107a188075a87e8969569d24cd5618e2b4bc5 100644 --- a/test/unittest/UTTest_ipc_server_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_server_client_proxy.cpp @@ -14,7 +14,9 @@ */ #include "UTTest_ipc_server_client_proxy.h" + #include + #include "dm_device_info.h" #include "ipc_remote_broker.h" #include "iremote_object.h" diff --git a/test/unittest/UTTest_ipc_server_listener.cpp b/test/unittest/UTTest_ipc_server_listener.cpp index fa36ad2c26c60bf45d2c7766b3f025930f632a65..1e057be0de5bd616946b11eb7ef88ad3732e92b5 100644 --- a/test/unittest/UTTest_ipc_server_listener.cpp +++ b/test/unittest/UTTest_ipc_server_listener.cpp @@ -16,6 +16,7 @@ #include "UTTest_ipc_server_listener.h" #include + #include "dm_device_info.h" #include "ipc_remote_broker.h" #include "iremote_object.h" diff --git a/test/unittest/UTTest_ipc_server_listener.h b/test/unittest/UTTest_ipc_server_listener.h index 8cf5057c75901ca5a290b92494775fa1cb47c2a4..8fd83a5c7f6b728c5b7c6a25adc37f904dd81035 100644 --- a/test/unittest/UTTest_ipc_server_listener.h +++ b/test/unittest/UTTest_ipc_server_listener.h @@ -21,6 +21,7 @@ #include "ipc_client_stub.h" #include "ipc_server_stub.h" #include "ipc_server_listener.h" + namespace OHOS { namespace DistributedHardware { class IpcServerListenerTest : public testing::Test { diff --git a/test/unittest/UTTest_ipc_server_stub.cpp b/test/unittest/UTTest_ipc_server_stub.cpp index 97082dc2d61c5e21bbc0467d71a22a586854b968..4f8b1b3a81c57720b76c7254629392c48cd992a5 100644 --- a/test/unittest/UTTest_ipc_server_stub.cpp +++ b/test/unittest/UTTest_ipc_server_stub.cpp @@ -14,6 +14,11 @@ */ #include "UTTest_ipc_server_stub.h" + +#include +#include +#include + #include "dm_device_info.h" #include "ipc_server_stub.h" #include "device_manager_impl.h" @@ -26,10 +31,6 @@ #include "string_ex.h" #include "system_ability_definition.h" -#include -#include -#include - namespace OHOS { namespace DistributedHardware { void IpcServerStubTest::SetUp() diff --git a/test/unittest/UTTest_ipc_server_stub.h b/test/unittest/UTTest_ipc_server_stub.h index d4e48c164912b987d1e5e3fd5543a5fc241d6dc1..0fcd65370f2caf590a3bd9ba7c953999fb6390e1 100644 --- a/test/unittest/UTTest_ipc_server_stub.h +++ b/test/unittest/UTTest_ipc_server_stub.h @@ -21,6 +21,7 @@ #include "ipc_client_stub.h" #include "ipc_server_stub.h" #include "ipc_server_listener.h" + namespace OHOS { namespace DistributedHardware { class IpcServerStubTest : public testing::Test { diff --git a/test/unittest/UTTest_multiple_user_connector.cpp b/test/unittest/UTTest_multiple_user_connector.cpp index 5e917427eded9af5978838a388547e055f654513..e712fe23bceae2b316724810c086ef9e03bb390e 100644 --- a/test/unittest/UTTest_multiple_user_connector.cpp +++ b/test/unittest/UTTest_multiple_user_connector.cpp @@ -13,9 +13,10 @@ * limitations under the License. */ +#include "UTTest_multiple_user_connector.h" + #include "dm_constants.h" #include "multiple_user_connector.h" -#include "UTTest_multiple_user_connector.h" namespace OHOS { namespace DistributedHardware { @@ -35,7 +36,7 @@ void MultipleUserConnectorTest::TearDownTestCase() namespace { /** * @tc.name: OnDecisionFilterResult_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC @@ -50,7 +51,7 @@ HWTEST_F(MultipleUserConnectorTest, GetCurrentAccountUserID_001, testing::ext::T /** * @tc.name: SetSwitchOldUserId_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC @@ -67,7 +68,7 @@ HWTEST_F(MultipleUserConnectorTest, SetSwitchOldUserId_001, testing::ext::TestSi /** * @tc.name: GetSwitchOldUserId_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC diff --git a/test/unittest/UTTest_pin_auth.cpp b/test/unittest/UTTest_pin_auth.cpp index 363379940cd76085302285ad40681d48be5d1477..8cef1b41f8e3931d847183aaa1a8b95b09198ba8 100644 --- a/test/unittest/UTTest_pin_auth.cpp +++ b/test/unittest/UTTest_pin_auth.cpp @@ -16,12 +16,12 @@ #include "UTTest_pin_auth.h" #include - #include #include "dm_constants.h" #include "dm_log.h" #include "nlohmann/json.hpp" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_pin_auth_ui.cpp b/test/unittest/UTTest_pin_auth_ui.cpp index b1055473db954642ec7bf65bd483f28137ac923b..4ac1952c5966649ca15fc16f397a45d923ffc9e5 100644 --- a/test/unittest/UTTest_pin_auth_ui.cpp +++ b/test/unittest/UTTest_pin_auth_ui.cpp @@ -16,7 +16,6 @@ #include "UTTest_pin_auth_ui.h" #include - #include #include "dm_ability_manager.h" @@ -24,6 +23,7 @@ #include "dm_log.h" #include "nlohmann/json.hpp" #include "ui_service_mgr_client.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { diff --git a/test/unittest/UTTest_profile_connector.cpp b/test/unittest/UTTest_profile_connector.cpp index 86f69ee90c33c3731dcaa1f835171905cde24e70..3518a3ac087ab57a98b3fa5e516d3789b823a31c 100644 --- a/test/unittest/UTTest_profile_connector.cpp +++ b/test/unittest/UTTest_profile_connector.cpp @@ -13,6 +13,8 @@ * limitations under the License. */ +#include "UTTest_profile_connector.h" + #include "dm_constants.h" #include "dm_device_state_manager.h" #include "profile_adapter.h" @@ -20,7 +22,7 @@ #include "profile_connector.h" #include "device_profile_adapter.h" #include "distributed_device_profile_client.h" -#include "UTTest_profile_connector.h" +#include "device_manager_service_listener.h" namespace OHOS { namespace DistributedHardware { @@ -41,12 +43,12 @@ namespace { std::shared_ptr softbusConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr hiChainConnector = std::make_shared(); -std::shared_ptr deviceStateMgr = std::make_shared(softbusConnector, - listener, - hiChainConnector); +std::shared_ptr deviceStateMgr = + std::make_shared(softbusConnector, listener, hiChainConnector); + /** * @tc.name: OnDecisionFilterResult_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC @@ -69,7 +71,7 @@ HWTEST_F(ProfileConnectorTest, RegisterProfileCallback_001, testing::ext::TestSi /** * @tc.name: OnDecisionFilterResult_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC @@ -87,7 +89,7 @@ HWTEST_F(ProfileConnectorTest, UnRegisterProfileCallback_001, testing::ext::Test /** * @tc.name: OnDecisionFilterResult_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC @@ -106,7 +108,7 @@ HWTEST_F(ProfileConnectorTest, SubscribeProfileEvents_001, testing::ext::TestSiz /** * @tc.name: OnDecisionFilterResult_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC @@ -126,7 +128,7 @@ HWTEST_F(ProfileConnectorTest, UnSubscribeProfileEvents_001, testing::ext::TestS /** * @tc.name: OnDecisionFilterResult_002 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC @@ -143,7 +145,7 @@ HWTEST_F(ProfileConnectorTest, UnSubscribeProfileEvents_002, testing::ext::TestS /** * @tc.name: OnDecisionFilterResult_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC diff --git a/test/unittest/UTTest_softbus_connector.cpp b/test/unittest/UTTest_softbus_connector.cpp index 01b7976d23038af0ac4885d12a71aea554eadb72..0188a30fd2ef827fdc2b77ab4e4db4d997f7edc3 100644 --- a/test/unittest/UTTest_softbus_connector.cpp +++ b/test/unittest/UTTest_softbus_connector.cpp @@ -16,7 +16,6 @@ #include #include - #include #include #include @@ -31,7 +30,6 @@ #include "ipc_notify_discover_result_req.h" #include "ipc_notify_verify_auth_result_req.h" #include "parameter.h" -#include "softbus_connector.h" #include "system_ability_definition.h" namespace OHOS { @@ -53,6 +51,7 @@ namespace { std::shared_ptr hiChainConnector = std::make_shared(); std::shared_ptr listener = std::make_shared(); std::shared_ptr softbusConnector = std::make_shared(); +std::shared_ptr softbusListener = std::make_shared(); std::shared_ptr deviceStateMgr = std::make_shared(softbusConnector, listener, hiChainConnector); std::shared_ptr discoveryMgr = std::make_shared(softbusConnector, listener); @@ -68,13 +67,13 @@ HWTEST_F(SoftbusConnectorTest, DeviceOnLine_001, testing::ext::TestSize.Level0) DmDeviceInfo info; strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); deviceStateMgr->RegisterSoftbusStateCallback(); - DeviceOnLine(SoftbusConnector::stateCallbackMap_, info); + DeviceOnLine(info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { ret = true; listener->ipcServerListener_.req_ = nullptr; } - EXPECT_EQ(ret, true); + EXPECT_EQ(ret, false); SoftbusConnector::stateCallbackMap_.clear(); } @@ -89,7 +88,7 @@ HWTEST_F(SoftbusConnectorTest, DeviceOnLine_002, testing::ext::TestSize.Level0) std::string pkgName = "123"; DmDeviceInfo info; strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); - DeviceOnLine(SoftbusConnector::stateCallbackMap_, info); + DeviceOnLine(info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { ret = true; @@ -111,13 +110,13 @@ HWTEST_F(SoftbusConnectorTest, DeviceOffLine_001, testing::ext::TestSize.Level0) DmDeviceInfo info; strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); deviceStateMgr->RegisterSoftbusStateCallback(); - DeviceOffLine(SoftbusConnector::stateCallbackMap_, info); + DeviceOffLine(info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { ret = true; listener->ipcServerListener_.req_ = nullptr; } - EXPECT_EQ(ret, true); + EXPECT_EQ(ret, false); SoftbusConnector::stateCallbackMap_.clear(); } @@ -132,7 +131,7 @@ HWTEST_F(SoftbusConnectorTest, DeviceOffLine_002, testing::ext::TestSize.Level0) std::string pkgName = "123"; DmDeviceInfo info; strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); - DeviceOffLine(SoftbusConnector::stateCallbackMap_, info); + DeviceOffLine(info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { ret = true; @@ -167,18 +166,6 @@ HWTEST_F(SoftbusConnectorTest, SoftbusConnector_002, testing::ext::TestSize.Leve EXPECT_EQ(m_SoftbusConnector, nullptr); } -/** - * @tc.name: Init_001 - * @tc.desc: go to the corrort case and return DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(SoftbusConnectorTest, Init_001, testing::ext::TestSize.Level0) -{ - int ret = softbusConnector->Init(); - EXPECT_EQ(ret, DM_OK); -} - /** * @tc.name: RegisterSoftbusDiscoveryCallback_001 * @tc.desc: set pkgName = "com.ohos.helloworld";call RegisterSoftbusDiscoveryCallback function to corrort ,return DM_OK @@ -252,7 +239,7 @@ HWTEST_F(SoftbusConnectorTest, UnRegisterSoftbusStateCallback_001, testing::ext: HWTEST_F(SoftbusConnectorTest, GetTrustedDeviceList_001, testing::ext::TestSize.Level0) { std::vector deviceInfoList; - int ret = softbusConnector->GetTrustedDeviceList(deviceInfoList); + int ret = softbusListener->GetTrustedDeviceList(deviceInfoList); EXPECT_EQ(ret, DM_OK); } @@ -266,7 +253,7 @@ HWTEST_F(SoftbusConnectorTest, GetLocalDeviceInfo_001, testing::ext::TestSize.Le { std::string pkgName = "com.softbus.test"; DmDeviceInfo deviceInfo; - int ret = softbusConnector->GetLocalDeviceInfo(deviceInfo); + int ret = softbusListener->GetLocalDeviceInfo(deviceInfo); EXPECT_EQ(ret, DM_OK); } @@ -507,7 +494,7 @@ HWTEST_F(SoftbusConnectorTest, CovertNodeBasicInfoToDmDevice_001, testing::ext:: { NodeBasicInfo nodeBasicInfo; DmDeviceInfo dmDeviceInfo; - int ret = softbusConnector->CovertNodeBasicInfoToDmDevice(nodeBasicInfo, dmDeviceInfo); + int ret = softbusListener->CovertNodeBasicInfoToDmDevice(nodeBasicInfo, dmDeviceInfo); EXPECT_EQ(ret, DM_OK); } @@ -549,7 +536,7 @@ HWTEST_F(SoftbusConnectorTest, OnSoftBusDeviceOnline_001, testing::ext::TestSize std::string deviceId = "123456"; SoftbusConnector::discoveryDeviceInfoMap_[deviceId]; NodeBasicInfo *info = nullptr; - softbusConnector->OnSoftBusDeviceOnline(info); + softbusListener->OnSoftBusDeviceOnline(info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { listener->ipcServerListener_.req_ = nullptr; @@ -575,14 +562,14 @@ HWTEST_F(SoftbusConnectorTest, OnSoftBusDeviceOnline_002, testing::ext::TestSize std::string pkgName = "com.ohos.helloworld"; softbusConnector->RegisterSoftbusStateCallback( pkgName, std::shared_ptr(deviceStateMgr)); - softbusConnector->OnSoftBusDeviceOnline(&info); + softbusListener->OnSoftBusDeviceOnline(&info); sleep(1); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { listener->ipcServerListener_.req_ = nullptr; ret = true; } - EXPECT_EQ(ret, true); + EXPECT_EQ(ret, false); softbusConnector->UnRegisterSoftbusStateCallback(pkgName); } @@ -602,7 +589,7 @@ HWTEST_F(SoftbusConnectorTest, OnSoftBusDeviceOnline_003, testing::ext::TestSize }; std::string oldName = DM_PKG_NAME; std::string DM_PKG_NAME = "com.ohos.test"; - softbusConnector->OnSoftBusDeviceOnline(&info); + softbusListener->OnSoftBusDeviceOnline(&info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { listener->ipcServerListener_.req_ = nullptr; @@ -621,7 +608,7 @@ HWTEST_F(SoftbusConnectorTest, OnSoftBusDeviceOnline_003, testing::ext::TestSize HWTEST_F(SoftbusConnectorTest, OnSoftbusDeviceOffline_001, testing::ext::TestSize.Level0) { NodeBasicInfo *info = nullptr; - softbusConnector->OnSoftbusDeviceOffline(info); + softbusListener->OnSoftbusDeviceOffline(info); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { ret = true; @@ -645,14 +632,14 @@ HWTEST_F(SoftbusConnectorTest, OnSoftbusDeviceOffline_002, testing::ext::TestSiz std::string pkgName = "com.ohos.helloworld"; softbusConnector->RegisterSoftbusStateCallback( pkgName, std::shared_ptr(deviceStateMgr)); - softbusConnector->OnSoftbusDeviceOffline(&info); + softbusListener->OnSoftbusDeviceOffline(&info); sleep(1); bool ret = false; if (listener->ipcServerListener_.req_ != nullptr) { listener->ipcServerListener_.req_ = nullptr; ret = true; } - EXPECT_EQ(ret, true); + EXPECT_EQ(ret, false); softbusConnector->UnRegisterSoftbusStateCallback(pkgName); } @@ -718,17 +705,6 @@ HWTEST_F(SoftbusConnectorTest, OnSoftbusDiscoverySuccess_001, testing::ext::Test EXPECT_EQ(ret, true); softbusConnector->UnRegisterSoftbusDiscoveryCallback(pkgName); } - -/** - * @tc.name: OnParameterChgCallback_001 - * @tc.desc: set some corrort para and return DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(SoftbusConnectorTest, OnParameterChgCallback_001, testing::ext::TestSize.Level0) -{ - EXPECT_EQ(DM_OK, DM_OK); -} } // namespace } // namespace DistributedHardware -} // namespace OHOS +} // namespace OHOS- \ No newline at end of file diff --git a/test/unittest/UTTest_softbus_connector.h b/test/unittest/UTTest_softbus_connector.h index 02e62ca14c55999f68e5844a10793e6b8309fbf2..07825b865b483821c9905cc6c6659e176231b789 100644 --- a/test/unittest/UTTest_softbus_connector.h +++ b/test/unittest/UTTest_softbus_connector.h @@ -17,7 +17,6 @@ #include #include - #include #include #include @@ -32,6 +31,7 @@ #include "dm_subscribe_info.h" #include "softbus_bus_center.h" #include "softbus_connector.h" +#include "softbus_listener.h" #include "softbus_discovery_callback.h" #include "softbus_session.h" #include "softbus_state_callback.h" diff --git a/test/unittest/UTTest_dm_device_info_manager.cpp b/test/unittest/UTTest_softbus_listener.cpp similarity index 44% rename from test/unittest/UTTest_dm_device_info_manager.cpp rename to test/unittest/UTTest_softbus_listener.cpp index 768c081ec5d51f671978f34c9d65223b130767c8..9f70b1dd811ee9986146ede6a7cca8852e4a4067 100644 --- a/test/unittest/UTTest_dm_device_info_manager.cpp +++ b/test/unittest/UTTest_softbus_listener.cpp @@ -13,81 +13,72 @@ * limitations under the License. */ -#include "UTTest_dm_device_info_manager.h" +#include "UTTest_softbus_listener.h" #include "dm_constants.h" #include "dm_log.h" +#include "softbus_listener.h" namespace OHOS { namespace DistributedHardware { -void DeviceManagerImplTest::SetUp() +void SoftbusListenerTest::SetUp() { } -void DeviceManagerImplTest::TearDown() +void SoftbusListenerTest::TearDown() { } -void DeviceManagerImplTest::SetUpTestCase() +void SoftbusListenerTest::SetUpTestCase() { } -void DeviceManagerImplTest::TearDownTestCase() +void SoftbusListenerTest::TearDownTestCase() { } namespace { -std::shared_ptr softbusConnector = std::make_shared(); -std::shared_ptr listener_ = std::make_shared(); -std::shared_ptr dmDeviceStateManager = std::make_shared(softbusConnector); +std::shared_ptr softbusListener = std::make_shared(); /** - * @tc.name: DmDeviceInfoManager_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new - * to construct an environment where the device has been discovered, and stop discovering - * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY + * @tc.name: Init_001 + * @tc.desc: go to the corrort case and return DM_OK * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DeviceManagerImplTest, DmDeviceInfoManager_001, testing::ext::TestSize.Level0) +HWTEST_F(SoftbusListenerTest, Init_001, testing::ext::TestSize.Level0) { - std::shared_ptr deviceInfoManager = std::make_shared(softbusConnector); - ASSERT_NE(deviceInfoManager, nullptr); + int ret = softbusListener->Init(); + EXPECT_EQ(ret, DM_OK); } /** * @tc.name: GetTrustedDeviceList_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DeviceManagerImplTest, GetTrustedDeviceList_001, testing::ext::TestSize.Level0) +HWTEST_F(SoftbusListenerTest, GetTrustedDeviceList_001, testing::ext::TestSize.Level0) { - int32_t ret = DM_OK; - std::string pkgName = ""; - std::string extra = ""; std::vector deviceList; - std::shared_ptr deviceInfoManager = std::make_shared(softbusConnector); - ret = deviceInfoManager->GetTrustedDeviceList(pkgName, extra, deviceList); + int32_t ret = softbusListener->GetTrustedDeviceList(deviceList); ASSERT_EQ(ret, DM_OK); } /** * @tc.name: GetLocalDeviceInfo_001 - * @tc.desc: Returns a new pointer to the constructor DmDeviceInfoManager new + * @tc.desc: Returns a new pointer to the constructor * to construct an environment where the device has been discovered, and stop discovering * the device. Its return value is ERR_DM_INPUT_PARAMETER_EMPTY * @tc.type: FUNC * @tc.require: AR000GHSJK */ -HWTEST_F(DeviceManagerImplTest, GetLocalDeviceInfo_001, testing::ext::TestSize.Level0) +HWTEST_F(SoftbusListenerTest, GetLocalDeviceInfo_001, testing::ext::TestSize.Level0) { DmDeviceInfo deviceInfo; - int32_t ret = DM_OK; - std::shared_ptr deviceInfoManager = std::make_shared(softbusConnector); - ret = deviceInfoManager->GetLocalDeviceInfo(deviceInfo); + int32_t ret = softbusListener->GetLocalDeviceInfo(deviceInfo); ASSERT_EQ(ret, DM_OK); } } diff --git a/test/unittest/UTTest_dm_device_info_manager.h b/test/unittest/UTTest_softbus_listener.h similarity index 86% rename from test/unittest/UTTest_dm_device_info_manager.h rename to test/unittest/UTTest_softbus_listener.h index cd1360c1bde2809da72dda80404f452afb6b619d..5f3600965530e6f521ec477ba1881263b080b2a2 100644 --- a/test/unittest/UTTest_dm_device_info_manager.h +++ b/test/unittest/UTTest_softbus_listener.h @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef OHOS_UTTEST_DM_DEVICEINFO_MANAGER_H -#define OHOS_UTTEST_DM_DEVICEINFO_MANAGER_H +#ifndef OHOS_UTTEST_DM_SOFTBUS_LISTENER_H +#define OHOS_UTTEST_DM_SOFTBUS_LISTENER_H #include #include @@ -24,13 +24,12 @@ #include "device_manager_service_listener.h" #include "dm_adapter_manager.h" #include "dm_device_info.h" -#include "dm_device_info_manager.h" #include "softbus_connector.h" #include "softbus_session_callback.h" namespace OHOS { namespace DistributedHardware { -class DeviceManagerImplTest : public testing::Test { +class SoftbusListenerTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase();