diff --git a/BUILD.gn b/BUILD.gn index 13f478c6..0807f582 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,7 +16,8 @@ if (defined(ohos_lite)) { lite_component("devicemanager_mini") { features = [ "utils:devicemanagerutils_mini", - "services/devicemanagerservice:devicemanagerservice_mini", + "services/service:devicemanagerservice_mini", + "services/implementation:devicemanagerserviceimpl_mini", "interfaces/inner_kits/native_cpp:devicemanagersdk_mini", "interfaces/kits/js_mini:devicemanager_native_js", ] @@ -29,7 +30,8 @@ if (defined(ohos_lite)) { lite_component("device_manager") { features = [ "utils:devicemanagerutils", - "services/devicemanagerservice:devicemanagerservice", + "services/service:devicemanagerservice", + "services/implementation:devicemanagerserviceimpl", "interfaces/inner_kits/native_cpp:devicemanagersdk", "ext/pin_auth:devicemanagerext_pin_auth", ] @@ -46,12 +48,13 @@ if (defined(ohos_lite)) { "interfaces/inner_kits/native_cpp:devicemanagersdk", "interfaces/kits:devicemanager_native_js", "sa_profile:dm_sa_profile", - "services/devicemanagerservice:devicemanagerservice", + "services/service:devicemanagerservice", + "services/implementation:devicemanagerserviceimpl", "utils:devicemanagerutils", ] } group("device_manager_test") { testonly = true - deps = [ "test:test" ] + deps = [] } } diff --git a/bundle.json b/bundle.json index a7456984..78d0d850 100644 --- a/bundle.json +++ b/bundle.json @@ -63,7 +63,6 @@ } ], "test": [ - "//foundation/distributedhardware/device_manager:device_manager_test" ] } } diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 3fe442c1..fb711dd5 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 450accdf..89701e68 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 cb0f192a..cc65c40c 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/service:devicemanagerservice", + "//foundation/distributedhardware/device_manager/services/implementation:devicemanagerserviceimpl", "//utils/native/base:utils", ] diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 68e45a96..fc0da72e 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 f33fa1ff..cde0584a 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 b9b12866..4034822f 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/device_manager_service.h b/services/devicemanagerservice/include/device_manager_service.h deleted file mode 100644 index 31278f7b..00000000 --- a/services/devicemanagerservice/include/device_manager_service.h +++ /dev/null @@ -1,154 +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_SERVICE_H -#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 "single_instance.h" -#include "softbus_connector.h" - -namespace OHOS { -namespace DistributedHardware { -class DeviceManagerService { -DECLARE_SINGLE_INSTANCE_BASE(DeviceManagerService); -public: - int32_t Init(); - ~DeviceManagerService(); - - /** - * @tc.name: DeviceManagerService::GetTrustedDeviceList - * @tc.desc: Get Trusted DeviceList of the Device Manager Service - * @tc.type: FUNC - */ - 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(); - -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_; - std::shared_ptr listener_; - std::shared_ptr abilityMgr_; - std::shared_ptr hiChainConnector_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DM_SERVICE_H 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 9504f32f..00000000 --- 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 37e9da32..00000000 --- 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/devicemanagerservice/BUILD.gn b/services/implementation/BUILD.gn old mode 100755 new mode 100644 similarity index 88% rename from services/devicemanagerservice/BUILD.gn rename to services/implementation/BUILD.gn index 87535c8d..08aef94d --- a/services/devicemanagerservice/BUILD.gn +++ b/services/implementation/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", ] @@ -104,7 +103,7 @@ if (defined(ohos_lite)) { defines = [ "__LITEOS_M__", "HI_LOG_ENABLE", - "DH_LOG_TAG=\"devicemanagerservice\"", + "DH_LOG_TAG=\"devicemanagerserviceimpl\"", "LOG_DOMAIN=0xD004100", ] @@ -134,7 +133,7 @@ if (defined(ohos_lite)) { ] } } else { - executable("devicemanagerservice") { + executable("devicemanagerserviceimpl") { include_dirs = [ "include", "include/config", @@ -142,7 +141,6 @@ if (defined(ohos_lite)) { "include/authentication", "include/authentication/showconfirm/lite", "include/ability", - "include/deviceinfo", "include/devicestate", "include/discovery", "include/dependency/multipleuser/", @@ -213,7 +211,7 @@ if (defined(ohos_lite)) { defines = [ "LITE_DEVICE", "HI_LOG_ENABLE", - "DH_LOG_TAG=\"devicemanagerservice\"", + "DH_LOG_TAG=\"devicemanagerserviceimpl\"", "LOG_DOMAIN=0xD004100", ] @@ -234,11 +232,11 @@ if (defined(ohos_lite)) { } } } else if (!support_jsapi) { - group("devicemanagerservice") { + group("devicemanagerserviceimpl") { deps = [] } } else { - config("devicemanagerservice_config") { + config("devicemanagerserviceimpl_config") { include_dirs = [ "include", "include/config", @@ -246,7 +244,6 @@ if (defined(ohos_lite)) { "include/authentication", "include/authentication/showconfirm/standard", "include/ability", - "include/deviceinfo", "include/devicestate", "include/discovery", "include/dependency/commonevent", @@ -254,9 +251,6 @@ if (defined(ohos_lite)) { "include/dependency/hichain", "include/dependency/softbus", "include/dependency/timer", - "include/ipc", - "include/ipc/standard", - "include/eventbus", "${common_path}/include", "${common_path}/include/ipc", "${common_path}/include/ipc/model", @@ -267,6 +261,8 @@ if (defined(ohos_lite)) { "${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) { @@ -274,7 +270,7 @@ if (defined(ohos_lite)) { } } - ohos_shared_library("devicemanagerservice") { + ohos_shared_library("devicemanagerserviceimpl") { sources = [ "src/ability/standard/dm_ability_manager.cpp", "src/adapter/standard/dm_adapter_manager.cpp", @@ -290,22 +286,16 @@ if (defined(ohos_lite)) { "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/device_manager_service_impl.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", ] - public_configs = [ ":devicemanagerservice_config" ] + public_configs = [ ":devicemanagerserviceimpl_config" ] defines = [ "HI_LOG_ENABLE", - "DH_LOG_TAG=\"devicemanagerservice\"", + "DH_LOG_TAG=\"devicemanagerserviceimpl\"", "LOG_DOMAIN=0xD004100", ] 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 83726a5f..bada1758 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 bc20a47b..c734a68c 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 00000000..9dccd133 --- /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 06d9a1bc..eec4a38c --- 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 7234c97a..81bfd3f4 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 36f423a8..ce134e4e 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 c10272ba..e7c59fb7 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 c13dc691..7a49e6cd 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 57% rename from services/devicemanagerservice/src/device_manager_service.cpp rename to services/implementation/src/device_manager_service_impl.cpp index 0c97d234..72383e1e 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) +void DeviceManagerServiceImpl::Release() { - if (!PermissionManager::GetInstance().CheckPermission()) { - LOGI("The caller does not have permission to call"); - return ERR_DM_NO_PERMISSION; + 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"); } - 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); +#endif + softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback(); + hiChainConnector_->UnRegisterHiChainCallback(); + + authMgr_ = nullptr; + deviceStateMgr_ = nullptr; + discoveryMgr_ = nullptr; + softbusConnector_ = nullptr; + abilityMgr_ = nullptr; + hiChainConnector_ = nullptr; } -int32_t DeviceManagerService::GetLocalDeviceInfo(DmDeviceInfo &info) -{ - 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; - } - - if (pkgName.empty()) { - LOGE("StartDeviceDiscovery failed, pkgName is empty"); - return ERR_DM_INPUT_PARAMETER_EMPTY; - } - SoftbusConnector::GetUuidByNetworkId(netWorkId.c_str(), uuid); - return DM_OK; -} - -int32_t DeviceManagerService::StartDeviceDiscovery(const std::string &pkgName, const DmSubscribeInfo &subscribeInfo, +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, +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) { - return intFlag_; + 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 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 0b089ef2..1032a6a0 --- 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 9ecadecf..9dd3bdbf 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 067f2ab8..8a346b51 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/service/BUILD.gn b/services/service/BUILD.gn new file mode 100644 index 00000000..24a6bc4f --- /dev/null +++ b/services/service/BUILD.gn @@ -0,0 +1,297 @@ +# 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_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", + "${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=\"devicemanagerservice\"", + "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 { + executable("devicemanagerservice") { + include_dirs = [ + "include", + "include/config", + "include/adapter", + "include/authentication", + "include/authentication/showconfirm/lite", + "include/ability", + "include/devicestate", + "include/discovery", + "include/dependency/multipleuser/", + "include/dependency/hichain", + "include/dependency/softbus", + "include/dependency/timer", + "include", + "include/ipc/lite", + "include/eventbus", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/fwkload/lite", + "${utils_path}/include/dfx", + "${utils_path}/include/dfx/lite", + "${utils_path}/include/ipc/lite", + "${utils_path}/include/permission/lite", + "${innerkits_path}/native_cpp/include", + "${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", + "//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/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", + ] + + 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_listener.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 + + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerservice\"", + "LOG_DOMAIN=0xD004100", + ] + + 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", + "//base/security/device_auth/services:deviceauth_sdk", + "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", + "//foundation/communication/dsoftbus/sdk:softbus_client", + "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/mbedtls:mbedtls_shared", + "//utils/native/lite:utils", + ] + } + } +} else if (!support_jsapi) { + group("devicemanagerservice") { + deps = [] + } +} else { + config("devicemanagerservice_config") { + include_dirs = [ + "include", + "include/softbus", + "include/ipc", + "include/ipc/standard", + "${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", + ] + } + + ohos_shared_library("devicemanagerservice") { + sources = [ + "src/device_manager_service.cpp", + "src/device_manager_service_listener.cpp", + "src/softbus/softbus_listener.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", + ] + + public_configs = [ ":devicemanagerservice_config" ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerservice\"", + "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", + ] + + external_deps = [ + "dsoftbus:softbus_client", + "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/service/include/device_manager_service.h b/services/service/include/device_manager_service.h new file mode 100644 index 00000000..1531c0ec --- /dev/null +++ b/services/service/include/device_manager_service.h @@ -0,0 +1,92 @@ +/* + * 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_H +#define OHOS_DM_SERVICE_H + +#include +#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_listener.h" + +namespace OHOS { +namespace DistributedHardware { +class DeviceManagerService { +DECLARE_SINGLE_INSTANCE_BASE(DeviceManagerService); +public: + DeviceManagerService() {} + + ~DeviceManagerService(); + + int32_t Init(); + + int32_t GetTrustedDeviceList(const std::string &pkgName, const std::string &extra, + std::vector &deviceList); + + int32_t GetLocalDeviceInfo(DmDeviceInfo &info); + + int32_t GetUdidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &udid); + + int32_t GetUuidByNetworkId(const std::string &pkgName, const std::string &netWorkId, std::string &uuid); + + 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); + + bool IsDMServiceImplReady(); + +private: + bool isImplsoLoaded_ = false; + std::shared_ptr softbusListener_; + std::shared_ptr listener_; + std::shared_ptr dmServiceImpl_; +}; +} // namespace DistributedHardware +} // namespace OHOS +#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 ce0b3e95..eae8b145 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 00000000..4c8af046 --- /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 00000000..89b74519 --- /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 2fa555d0..ee8ed98c 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 00000000..526a6917 --- /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 00000000..f7a67c40 --- /dev/null +++ b/services/service/src/device_manager_service.cpp @@ -0,0 +1,293 @@ +/* + * 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("StartDeviceDiscovery 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("StartDeviceDiscovery 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 (!PermissionManager::GetInstance().CheckPermission()) { + LOGI("The caller does not have permission to call."); + return ERR_DM_NO_PERMISSION; + } + 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 (!PermissionManager::GetInstance().CheckPermission()) { + LOGI("The caller does not have permission to call"); + return ERR_DM_NO_PERMISSION; + } + 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 (!PermissionManager::GetInstance().CheckPermission()) { + LOGI("The caller does not have permission to call"); + return ERR_DM_NO_PERMISSION; + } + 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 (!PermissionManager::GetInstance().CheckPermission()) { + LOGI("The caller does not have permission to call"); + return ERR_DM_NO_PERMISSION; + } + 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 (!PermissionManager::GetInstance().CheckPermission()) { + LOGI("The caller does not have permission to call"); + return ERR_DM_NO_PERMISSION; + } + 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 100% rename from services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp rename to services/service/src/ipc/lite/ipc_server_main.cpp 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 998c45fd..41366190 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 b311fad1..63d6e117 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 00000000..6dd11bb9 --- /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/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerimpl_fuzzer/BUILD.gn index 2818d613..bcba2769 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", @@ -62,8 +61,8 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") { "//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 7f2c5a9e..26b2ce1c 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", @@ -60,8 +59,8 @@ ohos_fuzztest("DeviceManagerNotifyFuzzTest") { "//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", diff --git a/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn b/test/fuzztest/devicemanagerservice_fuzzer/BUILD.gn index f5b4794f..8b03cc13 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", @@ -60,8 +60,8 @@ ohos_fuzztest("DeviceManagerServiceFuzzTest") { "//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", diff --git a/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn b/test/fuzztest/ipcclientmanager_fuzzer/BUILD.gn index f0a744eb..f391099c 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", @@ -61,8 +61,8 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { "//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/ipccmdregister_fuzzer/BUILD.gn b/test/fuzztest/ipccmdregister_fuzzer/BUILD.gn index dd72be71..e26081c9 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", @@ -61,8 +61,8 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "//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/ipcserverclientproxy_fuzzer/BUILD.gn b/test/fuzztest/ipcserverclientproxy_fuzzer/BUILD.gn index 4032a8e3..ecf9a8e9 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", @@ -61,8 +61,8 @@ ohos_fuzztest("IpcServerClientProxyFuzzTest") { "//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/ipcserverlistener_fuzzer/BUILD.gn b/test/fuzztest/ipcserverlistener_fuzzer/BUILD.gn index d3f366c2..b7a2d105 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", @@ -61,8 +61,8 @@ ohos_fuzztest("IpcServerListenerFuzzTest") { "//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/ipcserverstub_fuzzer/BUILD.gn b/test/fuzztest/ipcserverstub_fuzzer/BUILD.gn index f22c21c7..50e47484 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", @@ -61,8 +61,8 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "//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/unittest/BUILD.gn b/test/unittest/BUILD.gn index 1cd8bdf1..aa8b90be 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -488,19 +488,19 @@ config("device_manager_test_common_public_config") { "${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", + "${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", "${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/ipc/interfaces/innerkits/c/ipc/include", @@ -514,8 +514,8 @@ config("device_manager_test_common_public_config") { "//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 = [ @@ -570,22 +570,22 @@ config("device_manager_test_common_public") { "${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/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", + "${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", "//foundation/distributedhardware/device_manager/test/unittest/mock/", - "${services_path}/include/ability", - "${services_path}/include/config", + "${servicesimpl_path}/include/ability", + "${servicesimpl_path}/include/config", "//foundation/communication/dsoftbus/interfaces/kits/bus_center", "//foundation/communication/ipc/interfaces/innerkits/c/ipc/include", "//foundation/communication/dsoftbus/interfaces/kits/common",