diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 2068a5585b19c581039241a6e5110ae529ed7035..adfd9fd4e52d1db7d3bc7220bfde3bb805e15f0d 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -15,6 +15,7 @@ if (defined(ohos_lite)) { import("//build/lite/config/component/lite_component.gni") } else { import("//build/ohos.gni") + import("//build/config/components/idl_tool/idl.gni") } import("//foundation/distributedhardware/device_manager/device_manager.gni") @@ -146,13 +147,43 @@ if (defined(ohos_lite)) { "${devicemanager_path}/radar/include", "${utils_path}/include", "${json_path}/include", + "${devicemanager_path}/services/service/include", + "${target_gen_dir}", ] } + idl_gen_interface("device_manager_interface") { + src_idl = rebase_path("${devicemanager_path}/services/service/IDeviceManagerIpc.idl") + log_tag = "devicemanagerservice" + log_domainid = "0xD004110" + } + ohos_source_set("device_manager_ipc") { + sanitize = { + debug = false + cfi = true + cfi_cross_dso = true + } + output_values = get_target_outputs(":device_manager_interface") + sources = [] + sources += filter_include(output_values, [ "*.cpp" ]) + public_configs = [ ":devicemanagersdk_config" ] + deps = [ ":device_manager_interface" ] + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + ] + subsystem_name = "distributedhardware" + part_name = "device_manager" + } ohos_shared_library("devicemanagersdk") { branch_protector_ret = "pac_ret" - sanitize = { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false boundary_sanitize = true integer_overflow = true ubsan = true @@ -181,6 +212,7 @@ if (defined(ohos_lite)) { "src/device_manager.cpp", "src/device_manager_impl.cpp", "src/dm_device_info.cpp", + "src/dm_device_profile_info.cpp", "src/ipc/ipc_client_proxy.cpp", "src/ipc/standard/dm_service_load.cpp", "src/ipc/standard/ipc_client_manager.cpp", @@ -188,6 +220,8 @@ if (defined(ohos_lite)) { "src/ipc/standard/ipc_client_stub.cpp", "src/ipc/standard/ipc_cmd_parser.cpp", "src/notify/device_manager_notify.cpp", + "src/notify/device_manager_notify_service.cpp", + "${devicemanager_path}/utils/src/dm_ipc_utils.cpp", ] public_configs = [ ":devicemanagersdk_config" ] @@ -200,7 +234,10 @@ if (defined(ohos_lite)) { "LOG_DOMAIN=0xD004111", ] - deps = [ "${json_path}:devicemanagerjson" ] + deps = [ + "${json_path}:devicemanagerjson", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "access_token:libaccesstoken_sdk", diff --git a/interfaces/inner_kits/native_cpp/include/dm_device_info.h b/interfaces/inner_kits/native_cpp/include/dm_device_info.h index 67c3a32aec0a6114bef43e50c0ce4ad577cbf7eb..f8bb4b348430aed60a0f7302a166139fe45b4a52 100644 --- a/interfaces/inner_kits/native_cpp/include/dm_device_info.h +++ b/interfaces/inner_kits/native_cpp/include/dm_device_info.h @@ -20,7 +20,7 @@ #include #include "dm_app_image_info.h" - +#include "parcel.h" #define DM_MAX_DEVICE_ID_LEN (97) #define DM_MAX_DEVICE_NAME_LEN (129) @@ -194,6 +194,23 @@ typedef struct DmDeviceInfo { std::string extraData; } DmDeviceInfo; +typedef struct DmDeviceInfoExt : public DmDeviceInfo, public Parcelable { + using DmDeviceInfo::DmDeviceInfo; + DmDeviceInfoExt(const DmDeviceInfo &devInfo) + { + memcpy_s(deviceId, DM_MAX_DEVICE_ID_LEN, devInfo.deviceId, DM_MAX_DEVICE_ID_LEN); + memcpy_s(deviceName, DM_MAX_DEVICE_NAME_LEN, devInfo.deviceName, DM_MAX_DEVICE_NAME_LEN); + deviceTypeId = devInfo.deviceTypeId; + memcpy_s(networkId, DM_MAX_DEVICE_ID_LEN, devInfo.networkId, DM_MAX_DEVICE_ID_LEN); + range = devInfo.range; + networkType = devInfo.networkType; + authForm = devInfo.authForm; + extraData = devInfo.extraData; + } + virtual bool Marshalling(Parcel &parcel) const override; + static DmDeviceInfoExt *Unmarshalling(Parcel &parcel); +} DmDeviceInfoExt; + /** * @brief Device Basic Information. */ @@ -222,6 +239,20 @@ DmDeviceBasicInfo { std::string extraData; } DmDeviceBasicInfo; +typedef struct DmDeviceBasicInfoExt : public DmDeviceBasicInfo, public Parcelable { + using DmDeviceBasicInfo::DmDeviceBasicInfo; + DmDeviceBasicInfoExt(const DmDeviceBasicInfo &devBasicInfo) + { + memcpy_s(deviceId, DM_MAX_DEVICE_ID_LEN, devBasicInfo.deviceId, DM_MAX_DEVICE_ID_LEN); + memcpy_s(deviceName, DM_MAX_DEVICE_NAME_LEN, devBasicInfo.deviceName, DM_MAX_DEVICE_NAME_LEN); + deviceTypeId = devBasicInfo.deviceTypeId; + memcpy_s(networkId, DM_MAX_DEVICE_ID_LEN, devBasicInfo.networkId, DM_MAX_DEVICE_ID_LEN); + extraData = devBasicInfo.extraData; + } + virtual bool Marshalling(Parcel &parcel) const override; + static DmDeviceBasicInfoExt *Unmarshalling(Parcel &parcel); +} DmDeviceBasicInfoExt; + /** * @brief Device Authentication param. */ @@ -310,6 +341,34 @@ typedef struct PeerTargetId { } } PeerTargetId; +typedef struct PeerTargetIdExt : public PeerTargetId, public Parcelable { + using PeerTargetId::PeerTargetId; + PeerTargetIdExt(const PeerTargetId &peerTargetId) + { + deviceId = peerTargetId.deviceId; + brMac = peerTargetId.brMac; + bleMac = peerTargetId.bleMac; + wifiIp = peerTargetId.wifiIp; + wifiPort = peerTargetId.wifiPort; + } + bool operator==(const PeerTargetIdExt &other) const + { + return (deviceId == other.deviceId) && (brMac == other.brMac) && + (bleMac == other.bleMac) && (wifiIp == other.wifiIp) && (wifiPort == other.wifiPort); + } + bool operator<(const PeerTargetIdExt &other) const + { + return (deviceId < other.deviceId) || + (deviceId == other.deviceId && brMac < other.brMac) || + (deviceId == other.deviceId && brMac == other.brMac && bleMac < other.bleMac) || + (deviceId == other.deviceId && brMac == other.brMac && bleMac == other.bleMac && wifiIp < other.wifiIp) || + (deviceId == other.deviceId && brMac == other.brMac && bleMac == other.bleMac && wifiIp == other.wifiIp && + wifiPort < other.wifiPort); + } + virtual bool Marshalling(Parcel &parcel) const override; + static PeerTargetIdExt *Unmarshalling(Parcel &parcel); +} PeerTargetIdExt; + typedef enum { BIT_NETWORK_TYPE_UNKNOWN = 0, /**< Unknown network type */ BIT_NETWORK_TYPE_WIFI, /**< WIFI network type */ @@ -407,6 +466,26 @@ typedef struct ProcessInfo { } } ProcessInfo; +typedef struct ProcessInfoExt : public ProcessInfo, public Parcelable { + using ProcessInfo::ProcessInfo; + ProcessInfoExt(const ProcessInfo &processInfo) + { + userId = processInfo.userId; + pkgName = processInfo.pkgName; + } + bool operator==(const ProcessInfoExt &other) const + { + return (userId == other.userId) && (pkgName == other.pkgName); + } + bool operator<(const ProcessInfoExt &other) const + { + return (userId < other.userId) || + (userId == other.userId && pkgName < other.pkgName); + } + virtual bool Marshalling(Parcel &parcel) const override; + static ProcessInfoExt *Unmarshalling(Parcel &parcel); +} ProcessInfoExt; + typedef struct DmNotifyKey { int32_t processUserId; std::string processPkgName; diff --git a/interfaces/inner_kits/native_cpp/include/dm_device_profile_info.h b/interfaces/inner_kits/native_cpp/include/dm_device_profile_info.h index 21bde5a1eabd48704fc3c4913abf7102e1e352e9..0a4fad4211cafb5c385f370fd69994d889836f6b 100644 --- a/interfaces/inner_kits/native_cpp/include/dm_device_profile_info.h +++ b/interfaces/inner_kits/native_cpp/include/dm_device_profile_info.h @@ -20,7 +20,7 @@ #include #include #include - +#include "parcel.h" namespace OHOS { namespace DistributedHardware { typedef struct DmProductInfo { @@ -59,6 +59,24 @@ typedef struct DmDeviceIconInfo { } } DmDeviceIconInfo; +typedef struct DmDeviceIconInfoExt : public DmDeviceIconInfo, public Parcelable { + using DmDeviceIconInfo::DmDeviceIconInfo; + DmDeviceIconInfoExt(const DmDeviceIconInfo &iconInfo) + { + productId = iconInfo.productId; + subProductId = iconInfo.subProductId; + internalModel = iconInfo.internalModel; + imageType = iconInfo.imageType; + specName = iconInfo.specName; + wiseVersion = iconInfo.wiseVersion; + version = iconInfo.version; + url = iconInfo.url; + icon = iconInfo.icon; + } + virtual bool Marshalling(Parcel &parcel) const override; + static DmDeviceIconInfoExt *Unmarshalling(Parcel &parcel); +} DmDeviceIconInfoExt; + typedef struct DmServiceProfileInfo { std::string deviceId = ""; std::string serviceId = ""; @@ -101,6 +119,42 @@ typedef struct DmDeviceProfileInfo { std::vector services = {}; } DmDeviceProfileInfo; +typedef struct DmDeviceProfileInfoExt : public DmDeviceProfileInfo, public Parcelable { + using DmDeviceProfileInfo::DmDeviceProfileInfo; + DmDeviceProfileInfoExt(const DmDeviceProfileInfo &profileInfo) + { + deviceId = profileInfo.deviceId; + deviceSn = profileInfo.deviceSn; + mac = profileInfo.mac; + model = profileInfo.model; + internalModel = profileInfo.internalModel; + deviceType = profileInfo.deviceType; + manufacturer = profileInfo.manufacturer; + deviceName = profileInfo.deviceName; + productName = profileInfo.productName; + productId = profileInfo.productId; + subProductId = profileInfo.subProductId; + sdkVersion = profileInfo.sdkVersion; + bleMac = profileInfo.bleMac; + brMac = profileInfo.brMac; + sleMac = profileInfo.sleMac; + firmwareVersion = profileInfo.firmwareVersion; + hardwareVersion = profileInfo.hardwareVersion; + softwareVersion = profileInfo.softwareVersion; + protocolType = profileInfo.protocolType; + setupType = profileInfo.setupType; + wiseDeviceId = profileInfo.wiseDeviceId; + wiseUserId = profileInfo.wiseUserId; + registerTime = profileInfo.registerTime; + modifyTime = profileInfo.modifyTime; + shareTime = profileInfo.shareTime; + isLocalDevice = profileInfo.isLocalDevice; + services = profileInfo.services; + } + virtual bool Marshalling(Parcel &parcel) const override; + static DmDeviceProfileInfoExt *Unmarshalling(Parcel &parcel); +} DmDeviceProfileInfoExt; + typedef struct NetworkIdQueryFilter { std::string wiseDeviceId = ""; int32_t onlineStatus = 0; diff --git a/interfaces/inner_kits/native_cpp/include/ipc/standard/ipc_client_manager.h b/interfaces/inner_kits/native_cpp/include/ipc/standard/ipc_client_manager.h index ef49a67ea933013c0a5c8f55e7280b4746c2f513..d62dc534386ff8e3a56b61947c05cdf9c3f41aec 100644 --- a/interfaces/inner_kits/native_cpp/include/ipc/standard/ipc_client_manager.h +++ b/interfaces/inner_kits/native_cpp/include/ipc/standard/ipc_client_manager.h @@ -19,7 +19,7 @@ #include "ipc_client.h" #include "ipc_client_stub.h" #include "system_ability_status_change_stub.h" - +#include "idevice_manager_ipc.h" namespace OHOS { namespace DistributedHardware { class DmDeathRecipient : public IRemoteObject::DeathRecipient { @@ -70,7 +70,7 @@ private: void SubscribeDMSAChangeListener(); private: std::mutex lock_; - std::map> dmListener_; + std::map> dmListener_; sptr dmInterface_ { nullptr }; sptr dmRecipient_ { nullptr }; std::atomic isSubscribeDMSAChangeListener = false; diff --git a/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify.h b/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify.h index 39a229cc8fa23bb023351d03ab785b694637c7ab..178f263824d85d5d35b49242bc1f6498bb7db5c7 100644 --- a/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify.h +++ b/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify.h @@ -120,7 +120,7 @@ public: void OnPublishResult(const std::string &pkgName, int32_t publishId, int32_t publishResult); void OnAuthResult(const std::string &pkgName, const std::string &deviceId, const std::string &token, int32_t status, int32_t reason); - void OnUiCall(std::string &pkgName, std::string ¶mJson); + void OnUiCall(const std::string &pkgName, const std::string ¶mJson); void OnCredentialResult(const std::string &pkgName, int32_t &action, const std::string &credentialResult); void OnPinHolderCreate(const std::string &deviceId, const std::string &pkgName, DmPinType pinType, const std::string &payload); diff --git a/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify_service.h b/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify_service.h new file mode 100644 index 0000000000000000000000000000000000000000..5319a037d05a8bf9d3a3e9f41398e65825ee7d74 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify_service.h @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2025 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 DEVICE_MANAGER_NOTIFY_SERVICE_H +#define DEVICE_MANAGER_NOTIFY_SERVICE_H +#include +#include +#include +#include +#include +#include +#include + +#include "device_manager_ipc_stub.h" +#include "device_manager_notify.h" +#include "dm_device_info.h" +#include "dm_device_profile_info.h" +#include "dm_ipc_utils.h" +#include "dm_single_instance.h" +#include "idevice_manager_ipc.h" +namespace OHOS { +namespace DistributedHardware { +class DeviceManagerNotifyService : public DeviceManagerIpcStub { + DM_DECLARE_SINGLE_INSTANCE_BASE(DeviceManagerNotifyService); +public: + DeviceManagerNotifyService(); + ~DeviceManagerNotifyService() = default; + + void RegisterSystemAbility(); + ErrCode ServerDeviceStateNotify( + const std::string &pkgName, + int32_t deviceState, + const DmDeviceInfoExt &dmDeviceInfoExt, + const DmDeviceBasicInfoExt &dmDeviceBasicInfoExt, + const ProcessInfoExt& exprocessInfoExt) override; + + ErrCode ServerDeviceFound( + const std::string &pkgName, + uint16_t subscribeId, + const DmDeviceInfoExt &dmDeviceInfoExt, + const DmDeviceBasicInfoExt &devBasicInfoExt, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerDeviceDiscovery( + const std::string &pkgName, + short subscribeId, + const DmDeviceBasicInfoExt &dmDeviceBasicInfoExt) override; + + ErrCode ServerDiscoverFinish( + const std::string &pkgName, + uint16_t subscribeId, + int32_t failedReason, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerPublishFinish( + const std::string &pkgName, + int32_t publishId, + int32_t publishResult) override; + + ErrCode ServerAuthResult( + const std::string &pkgName, + const std::string &deviceId, + const std::string &token, + int32_t status, + int32_t reason, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerDeviceFaNotify( + const std::string &packagename, + const std::string ¶mJson, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerCredentialResult( + const std::string &pkgName, + int32_t action, + const std::string &credentialResult, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerCreatePinHolder( + const std::string &pkgName, + const std::string &deviceId, + int32_t pinType, + const std::string &payload, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerDestroyPinHolder( + const std::string &pkgName, + int32_t pinType, + const std::string &payload, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerCreatePinHolderResult( + const std::string &pkgName, + int32_t ret, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerDesTroyPinHolderResult( + const std::string &pkgName, + int32_t ret, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerOnPinHolderEvent( + const std::string &pkgName, + int32_t ret, + int32_t pinHolderEvent, + const std::string &content, + const ProcessInfoExt &processInfoExt) override; + + ErrCode BindTargetResult( + const std::string &pkgName, + const PeerTargetIdExt &targetIdExt, + int32_t ret, + int32_t status, + const std::string &content, + const ProcessInfoExt &processInfoExt) override; + + ErrCode UnbindTargetResult( + const std::string &pkgName, + const PeerTargetIdExt &targetIdExt, + int32_t ret, + const std::string &content, + const ProcessInfoExt &processInfoExt) override; + + ErrCode RemoteDeviceTrustChange( + const std::string &pkgName, + const std::string &udid, + int32_t authForm, + const std::string &uuid, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerDeviceScreenStateNotify( + const std::string &pkgName, + const DmDeviceInfoExt &dmDeviceInfoExt, + const ProcessInfoExt &processInfoExt) override; + + ErrCode ServerCredentialAuthStatusNotify( + const std::string &pkgName, + const std::string &deviceList, + const ProcessInfoExt &processInfoExt, + uint16_t deviceTypeId, + int32_t err) override; + + ErrCode SinkBindTargetResult( + const std::string &pkgName, + const PeerTargetIdExt &targetIdExt, + int32_t ret, + int32_t status, + const std::string &content, + const ProcessInfoExt &processInfoExt) override; + + ErrCode GetDeviceProfileInfoListResult( + const std::string &pkgName, + int32_t code, + int32_t deviceNum, + const std::vector &deviceProfileInfosExt, + const ProcessInfoExt &processInfoExt) override; + + ErrCode GetDeviceIconInfoResult( + const std::string &pkgName, + int32_t code, + const DmDeviceIconInfoExt &deviceIconInfoExt, + const ProcessInfoExt &processInfoExt) override; + + ErrCode SetRemoteDeviceNameResult( + const std::string &pkgName, + const std::string &deviceId, + int32_t code, + const ProcessInfoExt &processInfoExt) override; + + ErrCode SetLocalDeviceNameResult( + const std::string &pkgName, + int32_t code, + const ProcessInfoExt& processInfoExt) override; + +private: + DmPinType Int32ToDmPinType(int32_t value); + DmPinHolderEvent Int32ToDmPinHolderEvent(int32_t value); + DmAuthForm Int32ToDmAuthForm(int32_t value); + +private: + std::shared_ptr dmIpcUtils_; +}; + +} +} +#endif // DEVICE_MANAGER_NOTIFY_SERVICE_H diff --git a/interfaces/inner_kits/native_cpp/src/dm_device_info.cpp b/interfaces/inner_kits/native_cpp/src/dm_device_info.cpp index c80cbb4a4b72f9f5ce1096228e4d3b16335f732d..cd66e9f6a97eceaf535a21e8a3f8b6d69bff1ba6 100644 --- a/interfaces/inner_kits/native_cpp/src/dm_device_info.cpp +++ b/interfaces/inner_kits/native_cpp/src/dm_device_info.cpp @@ -12,7 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include +#include +#include +#include "dm_device_info.h" +#include "dm_log.h" +#include "dm_error_type.h" namespace OHOS { namespace DistributedHardware { const char* DEVICE_TYPE_UNKNOWN_STRING = "UNKNOWN"; @@ -25,5 +31,141 @@ const char* DEVICE_TYPE_WIFICAMERA_STRING = "WiFiCamera"; const char* DEVICE_TYPE_PC_STRING = "PC"; const char* DEVICE_TYPE_SMART_DISPLAY_STRING = "SMART_DISPLAY"; const char* DEVICE_TYPE_2IN1_STRING = "2IN1"; + +bool DmDeviceBasicInfoExt::Marshalling(Parcel &parcel) const +{ + bool bRet = true; + std::string deviceIdStr(deviceId); + bRet = (bRet && parcel.WriteString(deviceIdStr)); + std::string deviceNameStr(deviceName); + bRet = (bRet && parcel.WriteString(deviceNameStr)); + bRet = (bRet && parcel.WriteUint16(deviceTypeId)); + std::string networkIdStr(networkId); + bRet = (bRet && parcel.WriteString(networkIdStr)); + return bRet; +} + +DmDeviceBasicInfoExt *DmDeviceBasicInfoExt::Unmarshalling(Parcel &parcel) +{ + DmDeviceBasicInfoExt *deviceBasicInfoExt = new (std::nothrow) DmDeviceBasicInfoExt(); + if (deviceBasicInfoExt == nullptr) { + LOGE("Create DmDeviceBasicInfoExt failed"); + return nullptr; + } + std::string deviceIdStr = parcel.ReadString(); + if (strcpy_s(deviceBasicInfoExt->deviceId, deviceIdStr.size() + 1, deviceIdStr.c_str()) != DM_OK) { + LOGE("strcpy_s deviceId failed!"); + return nullptr; + } + std::string deviceNameStr = parcel.ReadString(); + if (strcpy_s(deviceBasicInfoExt->deviceName, deviceNameStr.size() + 1, deviceNameStr.c_str()) != DM_OK) { + LOGE("strcpy_s deviceName failed!"); + return nullptr; + } + deviceBasicInfoExt->deviceTypeId = parcel.ReadUint16(); + std::string networkIdStr = parcel.ReadString(); + if (strcpy_s(deviceBasicInfoExt->networkId, networkIdStr.size() + 1, networkIdStr.c_str()) != DM_OK) { + LOGE("strcpy_s networkId failed!"); + return nullptr; + } + return deviceBasicInfoExt; +} + +bool PeerTargetIdExt::Marshalling(Parcel &parcel) const +{ + bool bRet = true; + bRet = (bRet && parcel.WriteString(deviceId)); + bRet = (bRet && parcel.WriteString(brMac)); + bRet = (bRet && parcel.WriteString(bleMac)); + bRet = (bRet && parcel.WriteString(wifiIp)); + bRet = (bRet && parcel.WriteUint16(wifiPort)); + return bRet; +} + +PeerTargetIdExt *PeerTargetIdExt::Unmarshalling(Parcel &parcel) +{ + PeerTargetIdExt *targetIdExt = new (std::nothrow) PeerTargetIdExt(); + if (targetIdExt == nullptr) { + LOGE("Create PeerTargetIdExt failed"); + return nullptr; + } + targetIdExt->deviceId = parcel.ReadString(); + targetIdExt->brMac = parcel.ReadString(); + targetIdExt->bleMac = parcel.ReadString(); + targetIdExt->wifiIp = parcel.ReadString(); + targetIdExt->wifiPort = parcel.ReadUint16(); + return targetIdExt; +} + +bool DmDeviceInfoExt::Marshalling(Parcel &parcel) const +{ + bool bRet = true; + std::string deviceIdStr(deviceId); + bRet = (bRet && parcel.WriteString(deviceIdStr)); + std::string deviceNameStr(deviceName); + bRet = (bRet && parcel.WriteString(deviceNameStr)); + bRet = (bRet && parcel.WriteUint16(deviceTypeId)); + std::string networkIdStr(networkId); + bRet = (bRet && parcel.WriteString(networkIdStr)); + bRet = (bRet && parcel.WriteInt32(range)); + bRet = (bRet && parcel.WriteInt32(networkType)); + bRet = (bRet && parcel.WriteInt32(static_cast(authForm))); + bRet = (bRet && parcel.WriteString(extraData)); + return bRet; +} + +DmDeviceInfoExt *DmDeviceInfoExt::Unmarshalling(Parcel &parcel) +{ + DmDeviceInfoExt *deviceInfoExt = new (std::nothrow) DmDeviceInfoExt(); + if (deviceInfoExt == nullptr) { + LOGE("Create DmDeviceInfoExt failed"); + return nullptr; + } + std::string deviceIdStr = parcel.ReadString(); + if (strcpy_s(deviceInfoExt->deviceId, deviceIdStr.size() + 1, deviceIdStr.c_str()) != DM_OK) { + LOGE("strcpy_s deviceId failed!"); + delete deviceInfoExt; + return nullptr; + } + std::string deviceNameStr = parcel.ReadString(); + if (strcpy_s(deviceInfoExt->deviceName, deviceNameStr.size() + 1, deviceNameStr.c_str()) != DM_OK) { + LOGE("strcpy_s deviceName failed!"); + delete deviceInfoExt; + return nullptr; + } + deviceInfoExt->deviceTypeId = parcel.ReadUint16(); + std::string networkIdStr = parcel.ReadString(); + if (strcpy_s(deviceInfoExt->networkId, networkIdStr.size() + 1, networkIdStr.c_str()) != DM_OK) { + LOGE("strcpy_s networkId failed!"); + delete deviceInfoExt; + return nullptr; + } + deviceInfoExt->range = parcel.ReadInt32(); + deviceInfoExt->networkType = parcel.ReadInt32(); + deviceInfoExt->authForm = static_cast(parcel.ReadInt32()); + deviceInfoExt->extraData = parcel.ReadString(); + return deviceInfoExt; +} + +bool ProcessInfoExt::Marshalling(Parcel &parcel) const +{ + bool bRet = true; + bRet = (bRet && parcel.WriteInt32(userId)); + bRet = (bRet && parcel.WriteString(pkgName)); + return bRet; +} + +ProcessInfoExt *ProcessInfoExt::Unmarshalling(Parcel &parcel) +{ + auto *processInfoExt = new (std::nothrow) ProcessInfoExt(); + if (processInfoExt == nullptr) { + return nullptr; + } + + processInfoExt->userId = parcel.ReadInt32(); + processInfoExt->pkgName = parcel.ReadString(); + + return processInfoExt; +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/src/dm_device_profile_info.cpp b/interfaces/inner_kits/native_cpp/src/dm_device_profile_info.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a4fa3a5b3565c0b171976cda30393c95258e058 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/src/dm_device_profile_info.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2025 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 +#include +#include + +#include "dm_device_profile_info.h" +#include "dm_log.h" +namespace OHOS { +namespace DistributedHardware { +bool DmDeviceProfileInfoExt::Marshalling(Parcel &parcel) const +{ + bool bRet = true; + bRet = (bRet && parcel.WriteString(deviceId)); + bRet = (bRet && parcel.WriteString(deviceSn)); + bRet = (bRet && parcel.WriteString(mac)); + bRet = (bRet && parcel.WriteString(model)); + bRet = (bRet && parcel.WriteString(internalModel)); + bRet = (bRet && parcel.WriteString(deviceType)); + bRet = (bRet && parcel.WriteString(manufacturer)); + bRet = (bRet && parcel.WriteString(deviceName)); + bRet = (bRet && parcel.WriteString(productName)); + bRet = (bRet && parcel.WriteString(productId)); + bRet = (bRet && parcel.WriteString(subProductId)); + bRet = (bRet && parcel.WriteString(sdkVersion)); + bRet = (bRet && parcel.WriteString(bleMac)); + bRet = (bRet && parcel.WriteString(brMac)); + bRet = (bRet && parcel.WriteString(sleMac)); + bRet = (bRet && parcel.WriteString(firmwareVersion)); + bRet = (bRet && parcel.WriteString(hardwareVersion)); + bRet = (bRet && parcel.WriteString(softwareVersion)); + bRet = (bRet && parcel.WriteInt32(protocolType)); + bRet = (bRet && parcel.WriteInt32(setupType)); + bRet = (bRet && parcel.WriteString(wiseDeviceId)); + bRet = (bRet && parcel.WriteString(wiseUserId)); + bRet = (bRet && parcel.WriteString(registerTime)); + bRet = (bRet && parcel.WriteString(modifyTime)); + bRet = (bRet && parcel.WriteString(shareTime)); + bRet = (bRet && parcel.WriteBool(isLocalDevice)); + bRet = (bRet && parcel.WriteUint32(services.size())); + for (const auto &service : services) { + bRet = (bRet && parcel.WriteString(service.deviceId)); + bRet = (bRet && parcel.WriteString(service.serviceId)); + bRet = (bRet && parcel.WriteString(service.serviceType)); + bRet = (bRet && parcel.WriteUint32(service.data.size())); + for (const auto &entry : service.data) { + bRet = (bRet && parcel.WriteString(entry.first)); + bRet = (bRet && parcel.WriteString(entry.second)); + } + } + return bRet; +} + +DmDeviceProfileInfoExt *DmDeviceProfileInfoExt::Unmarshalling(Parcel &parcel) +{ + auto *profileInfoExt = new (std::nothrow) DmDeviceProfileInfoExt(); + if (profileInfoExt == nullptr) { + return nullptr; + } + + profileInfoExt->deviceId = parcel.ReadString(); + profileInfoExt->deviceSn = parcel.ReadString(); + profileInfoExt->mac = parcel.ReadString(); + profileInfoExt->model = parcel.ReadString(); + profileInfoExt->internalModel = parcel.ReadString(); + profileInfoExt->deviceType = parcel.ReadString(); + profileInfoExt->manufacturer = parcel.ReadString(); + profileInfoExt->deviceName = parcel.ReadString(); + profileInfoExt->productName = parcel.ReadString(); + profileInfoExt->productId = parcel.ReadString(); + profileInfoExt->subProductId = parcel.ReadString(); + profileInfoExt->sdkVersion = parcel.ReadString(); + profileInfoExt->bleMac = parcel.ReadString(); + profileInfoExt->brMac = parcel.ReadString(); + profileInfoExt->sleMac = parcel.ReadString(); + profileInfoExt->firmwareVersion = parcel.ReadString(); + profileInfoExt->hardwareVersion = parcel.ReadString(); + profileInfoExt->softwareVersion = parcel.ReadString(); + profileInfoExt->protocolType = parcel.ReadInt32(); + profileInfoExt->setupType = parcel.ReadInt32(); + profileInfoExt->wiseDeviceId = parcel.ReadString(); + profileInfoExt->wiseUserId = parcel.ReadString(); + profileInfoExt->registerTime = parcel.ReadString(); + profileInfoExt->modifyTime = parcel.ReadString(); + profileInfoExt->shareTime = parcel.ReadString(); + profileInfoExt->isLocalDevice = parcel.ReadBool(); + + uint32_t servicesSize = parcel.ReadUint32(); + for (uint32_t i = 0; i < servicesSize; ++i) { + DmServiceProfileInfo service; + service.deviceId = parcel.ReadString(); + service.serviceId = parcel.ReadString(); + service.serviceType = parcel.ReadString(); + + uint32_t dataSize = parcel.ReadUint32(); + for (uint32_t j = 0; j < dataSize; ++j) { + std::string key = parcel.ReadString(); + std::string value = parcel.ReadString(); + service.data[key] = value; + } + + profileInfoExt->services.push_back(service); + } + + return profileInfoExt; +} + +bool DmDeviceIconInfoExt::Marshalling(Parcel &parcel) const +{ + bool bRet = true; + bRet = (bRet && parcel.WriteString(productId)); + bRet = (bRet && parcel.WriteString(subProductId)); + bRet = (bRet && parcel.WriteString(internalModel)); + bRet = (bRet && parcel.WriteString(imageType)); + bRet = (bRet && parcel.WriteString(specName)); + bRet = (bRet && parcel.WriteString(wiseVersion)); + bRet = (bRet && parcel.WriteString(version)); + bRet = (bRet && parcel.WriteString(url)); + bRet = (bRet && parcel.WriteUint32(icon.size())); + for (const auto &byte : icon) { + bRet = (bRet && parcel.WriteUint8(byte)); + } + return bRet; +} + +DmDeviceIconInfoExt *DmDeviceIconInfoExt::Unmarshalling(Parcel &parcel) +{ + auto *iconInfoExt = new (std::nothrow) DmDeviceIconInfoExt(); + if (iconInfoExt == nullptr) { + return nullptr; + } + + iconInfoExt->productId = parcel.ReadString(); + iconInfoExt->subProductId = parcel.ReadString(); + iconInfoExt->internalModel = parcel.ReadString(); + iconInfoExt->imageType = parcel.ReadString(); + iconInfoExt->specName = parcel.ReadString(); + iconInfoExt->wiseVersion = parcel.ReadString(); + iconInfoExt->version = parcel.ReadString(); + iconInfoExt->url = parcel.ReadString(); + + uint32_t iconSize = parcel.ReadUint32(); + for (uint32_t i = 0; i < iconSize; ++i) { + uint8_t byte = parcel.ReadUint8(); + iconInfoExt->icon.push_back(byte); + } + + return iconInfoExt; +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp index f912db8d9b4b7a98b7e23f8ff8101002f7bfa4fc..777257b78d39aac99d91acf34a564053063e72e5 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp @@ -31,7 +31,8 @@ #include "iservice_registry.h" #include "system_ability_definition.h" #include - +#include "device_manager_notify_service.h" +#include "idevice_manager_ipc.h" namespace OHOS { namespace DistributedHardware { void DmDeathRecipient::OnRemoteDied(const wptr &remote) @@ -73,6 +74,7 @@ int32_t IpcClientManager::ClientInit() int32_t IpcClientManager::Init(const std::string &pkgName) { + LOGI("DM IDL begin, pkgName: %{public}s", pkgName.c_str()); if (pkgName.empty()) { LOGE("Invalid parameter, pkgName is empty."); return ERR_DM_INPUT_PARA_INVALID; @@ -84,12 +86,11 @@ int32_t IpcClientManager::Init(const std::string &pkgName) LOGE("InitDeviceManager Failed with ret %{public}d", ret); return ret; } - - sptr listener = sptr(new IpcClientStub()); + sptr listener = sptr(new (std::nothrow) DeviceManagerNotifyService()); std::shared_ptr req = std::make_shared(); std::shared_ptr rsp = std::make_shared(); req->SetPkgName(pkgName); - req->SetListener(listener); + req->SetListener(listener->AsObject()); ret = dmInterface_->SendCmd(REGISTER_DEVICE_MANAGER_LISTENER, req, rsp); if (ret != DM_OK) { LOGE("InitDeviceManager: RegisterDeviceManagerListener Failed with ret %{public}d", ret); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index a30e5493b2b6ea81ff6113a7f7f820ed819f662a..a4465bc14ef07c1019c0b15803b52e456ac5f0ed 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -117,6 +117,8 @@ ON_IPC_SET_REQUEST(REGISTER_DEVICE_MANAGER_LISTENER, std::shared_ptr pBa LOGE("write listener failed"); return ERR_DM_IPC_WRITE_FAILED; } + LOGI("Listener successfully written to MessageParcel. pkgName: %{public}s, listener address: 0x%lx", + pkgName.c_str(), static_cast(reinterpret_cast(listener.GetRefPtr()))); return DM_OK; } @@ -124,6 +126,7 @@ ON_IPC_READ_RESPONSE(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &reply, std { CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); pBaseRsp->SetErrCode(reply.ReadInt32()); + LOGI("REGISTER_DEVICE_MANAGER_LISTENER response read, errCode: %{public}d", pBaseRsp->GetErrCode()); return DM_OK; } @@ -452,123 +455,6 @@ ON_IPC_READ_RESPONSE(SERVER_USER_AUTH_OPERATION, MessageParcel &reply, std::shar return DM_OK; } -ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - DmDeviceState deviceState = static_cast(data.ReadInt32()); - DmDeviceInfo dmDeviceInfo; - IpcModelCodec::DecodeDmDeviceInfo(data, dmDeviceInfo); - - DmDeviceBasicInfo dmDeviceBasicInfo; - IpcModelCodec::DecodeDmDeviceBasicInfo(data, dmDeviceBasicInfo); - switch (deviceState) { - case DEVICE_STATE_ONLINE: - LOGI("Online pkgName:%{public}s", pkgName.c_str()); - DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, dmDeviceInfo); - DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, dmDeviceBasicInfo); - break; - case DEVICE_STATE_OFFLINE: - LOGI("Offline pkgName:%{public}s", pkgName.c_str()); - DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, dmDeviceInfo); - DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, dmDeviceBasicInfo); - break; - case DEVICE_INFO_CHANGED: - DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, dmDeviceInfo); - DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, dmDeviceBasicInfo); - break; - case DEVICE_INFO_READY: - LOGI("OnDeviceReady in, pkgName:%{public}s, networkId: %{public}s.", - pkgName.c_str(), GetAnonyString(dmDeviceInfo.networkId).c_str()); - DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, dmDeviceInfo); - DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, dmDeviceBasicInfo); - break; - default: - LOGE("unknown device state:%{public}d", deviceState); - break; - } - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_DEVICE_FOUND, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int16_t subscribeId = data.ReadInt16(); - DmDeviceInfo dmDeviceInfo; - IpcModelCodec::DecodeDmDeviceInfo(data, dmDeviceInfo); - DmDeviceBasicInfo devBasicInfo; - IpcModelCodec::DecodeDmDeviceBasicInfo(data, devBasicInfo); - LOGD("pkgName:%{public}s, subscribeId:%{public}d.", GetAnonyString(pkgName).c_str(), (int32_t)subscribeId); - DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); - DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, devBasicInfo); - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_DEVICE_DISCOVERY, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int16_t subscribeId = data.ReadInt16(); - DmDeviceBasicInfo dmDeviceBasicInfo; - IpcModelCodec::DecodeDmDeviceBasicInfo(data, dmDeviceBasicInfo); - DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceBasicInfo); - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_DISCOVER_FINISH, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int16_t subscribeId = data.ReadInt16(); - int32_t failedReason = data.ReadInt32(); - - if (failedReason == DM_OK) { - DeviceManagerNotify::GetInstance().OnDiscoverySuccess(pkgName, subscribeId); - } else { - DeviceManagerNotify::GetInstance().OnDiscoveryFailed(pkgName, subscribeId, failedReason); - } - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_PUBLISH_FINISH, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int32_t publishId = data.ReadInt32(); - int32_t publishResult = data.ReadInt32(); - - DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, publishId, publishResult); - if (!reply.WriteInt32(DM_OK)) { - LOGE("write return failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_CMD(SERVER_AUTH_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - std::string deviceId = data.ReadString(); - std::string token = data.ReadString(); - int32_t status = data.ReadInt32(); - int32_t reason = data.ReadInt32(); - DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, (uint32_t)status, reason); - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_DEVICE_FA_NOTIFY, MessageParcel &data, MessageParcel &reply) -{ - std::string packagename = data.ReadString(); - std::string paramJson = data.ReadString(); - DeviceManagerNotify::GetInstance().OnUiCall(packagename, paramJson); - if (!reply.WriteInt32(DM_OK)) { - LOGE("write return failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - ON_IPC_SET_REQUEST(REQUEST_CREDENTIAL, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -743,17 +629,6 @@ ON_IPC_READ_RESPONSE(UNREGISTER_CREDENTIAL_CALLBACK, MessageParcel &reply, std:: return DM_OK; } -ON_IPC_CMD(SERVER_CREDENTIAL_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int32_t action = data.ReadInt32(); - std::string credentialResult = data.ReadString(); - - DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_SET_REQUEST(NOTIFY_EVENT, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1218,33 +1093,6 @@ ON_IPC_READ_RESPONSE(UNBIND_TARGET, MessageParcel &reply, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1371,49 +1219,6 @@ ON_IPC_READ_RESPONSE(STOP_AUTHENTICATE_DEVICE, MessageParcel &reply, std::shared return DM_OK; } -ON_IPC_CMD(SERVER_CREATE_PIN_HOLDER, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - std::string deviceId = data.ReadString(); - DmPinType pinType = static_cast(data.ReadInt32()); - std::string payload = data.ReadString(); - - DeviceManagerNotify::GetInstance().OnPinHolderCreate(pkgName, deviceId, pinType, payload); - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_DESTROY_PIN_HOLDER, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - DmPinType pinType = static_cast(data.ReadInt32()); - std::string payload = data.ReadString(); - - DeviceManagerNotify::GetInstance().OnPinHolderDestroy(pkgName, pinType, payload); - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_CREATE_PIN_HOLDER_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int32_t result = data.ReadInt32(); - - DeviceManagerNotify::GetInstance().OnCreateResult(pkgName, result); - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SERVER_DESTROY_PIN_HOLDER_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int32_t result = data.ReadInt32(); - - DeviceManagerNotify::GetInstance().OnDestroyResult(pkgName, result); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_SET_REQUEST(DP_ACL_ADD, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1457,18 +1262,6 @@ ON_IPC_READ_RESPONSE(GET_SECURITY_LEVEL, MessageParcel &reply, std::shared_ptr(data.ReadInt32()); - std::string content = data.ReadString(); - - DeviceManagerNotify::GetInstance().OnPinHolderEvent(pkgName, pinHolderEvent, result, content); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_SET_REQUEST(IS_SAME_ACCOUNT, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1545,28 +1338,6 @@ ON_IPC_READ_RESPONSE(SHIFT_LNN_GEAR, MessageParcel &reply, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1635,32 +1406,6 @@ ON_IPC_READ_RESPONSE(GET_NETWORKID_BY_UDID, MessageParcel &reply, std::shared_pt return DM_OK; } -ON_IPC_CMD(SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - std::string deviceList = data.ReadString(); - uint16_t deviceTypeId = data.ReadUint16(); - int32_t errCode = data.ReadInt32(); - DeviceManagerNotify::GetInstance().OnCredentialAuthStatus(pkgName, deviceList, deviceTypeId, errCode); - - reply.WriteInt32(DM_OK); - return DM_OK; -} - -ON_IPC_CMD(SINK_BIND_TARGET_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - PeerTargetId targetId; - IpcModelCodec::DecodePeerTargetId(data, targetId); - int32_t result = data.ReadInt32(); - int32_t status = data.ReadInt32(); - std::string content = data.ReadString(); - - DeviceManagerNotify::GetInstance().OnSinkBindResult(pkgName, targetId, result, status, content); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_SET_REQUEST(REGISTER_DEV_STATE_CALLBACK, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1749,25 +1494,6 @@ ON_IPC_READ_RESPONSE(GET_DEVICE_PROFILE_INFO_LIST, MessageParcel &reply, std::sh return DM_OK; } -ON_IPC_CMD(GET_DEVICE_PROFILE_INFO_LIST_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int32_t code = data.ReadInt32(); - int32_t deviceNum = data.ReadInt32(); - std::vector deviceProfileInfos; - if (deviceNum > 0 && deviceNum <= MAX_DEVICE_PROFILE_SIZE) { - for (int32_t i = 0; i < deviceNum; ++i) { - DmDeviceProfileInfo deviceInfo; - IpcModelCodec::DecodeDmDeviceProfileInfo(data, deviceInfo); - deviceProfileInfos.emplace_back(deviceInfo); - } - } - - DeviceManagerNotify::GetInstance().OnGetDeviceProfileInfoListResult(pkgName, deviceProfileInfos, code); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_SET_REQUEST(GET_DEVICE_ICON_INFO, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1791,17 +1517,6 @@ ON_IPC_READ_RESPONSE(GET_DEVICE_ICON_INFO, MessageParcel &reply, std::shared_ptr return DM_OK; } -ON_IPC_CMD(GET_DEVICE_ICON_INFO_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int32_t code = data.ReadInt32(); - DmDeviceIconInfo deviceIconInfo; - IpcModelCodec::DecodeDmDeviceIconInfo(data, deviceIconInfo); - DeviceManagerNotify::GetInstance().OnGetDeviceIconInfoResult(pkgName, deviceIconInfo, code); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_SET_REQUEST(PUT_DEVICE_PROFILE_INFO_LIST, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -2009,15 +1724,6 @@ ON_IPC_READ_RESPONSE(SET_LOCAL_DEVICE_NAME, MessageParcel &reply, std::shared_pt return DM_OK; } -ON_IPC_CMD(SET_LOCAL_DEVICE_NAME_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - int32_t code = data.ReadInt32(); - DeviceManagerNotify::GetInstance().OnSetLocalDeviceNameResult(pkgName, code); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_READ_RESPONSE(SET_REMOTE_DEVICE_NAME, MessageParcel &reply, std::shared_ptr pBaseRsp) { if (pBaseRsp == nullptr) { @@ -2053,16 +1759,6 @@ ON_IPC_SET_REQUEST(SET_REMOTE_DEVICE_NAME, std::shared_ptr pBaseReq, Mes return DM_OK; } -ON_IPC_CMD(SET_REMOTE_DEVICE_NAME_RESULT, MessageParcel &data, MessageParcel &reply) -{ - std::string pkgName = data.ReadString(); - std::string deviceId = data.ReadString(); - int32_t code = data.ReadInt32(); - DeviceManagerNotify::GetInstance().OnSetRemoteDeviceNameResult(pkgName, deviceId, code); - reply.WriteInt32(DM_OK); - return DM_OK; -} - ON_IPC_READ_RESPONSE(RESTORE_LOCAL_DEVICE_NAME, MessageParcel &reply, std::shared_ptr pBaseRsp) { if (pBaseRsp == nullptr) { diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index 278ebade4d53d5d46cd43c5f43211105821592bf..812b2fb4b19f0dba3264c54ece5565f4f981d9af 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -675,7 +675,7 @@ void DeviceManagerNotify::OnAuthResult(const std::string &pkgName, const std::st } } -void DeviceManagerNotify::OnUiCall(std::string &pkgName, std::string ¶mJson) +void DeviceManagerNotify::OnUiCall(const std::string &pkgName, const std::string ¶mJson) { if (pkgName.empty()) { LOGE("DeviceManagerNotify::OnUiCall error: Invalid parameter, pkgName: %{public}s", pkgName.c_str()); diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify_service.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify_service.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ce1f5c3f3d9deaef257892b69383c753662d9d64 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify_service.cpp @@ -0,0 +1,412 @@ +/* + * Copyright (c) 2025 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 +#include "device_manager_notify_service.h" +#include "device_manager_notify.h" +#include "dm_error_type.h" +#include "dm_log.h" +#include "dm_constants.h" +#include "dm_anonymous.h" +namespace OHOS { +namespace DistributedHardware { +DM_IMPLEMENT_SINGLE_INSTANCE(DeviceManagerNotifyService); +DeviceManagerNotifyService::DeviceManagerNotifyService() +{ + dmIpcUtils_ = std::make_shared(); + LOGI("DeviceManagerNotifyService constructor called."); +} + +ErrCode DeviceManagerNotifyService::ServerDeviceStateNotify( + const std::string &pkgName, + int32_t deviceState, + const DmDeviceInfoExt &dmDeviceInfoExt, + const DmDeviceBasicInfoExt &dmDeviceBasicInfoExt, + const ProcessInfoExt& exprocessInfoExt) +{ + LOGI("DM IDL DMNS::ServerDeviceStateNotify pkgName %{public}s", + exprocessInfoExt.pkgName.c_str()); + DmDeviceInfo dmDeviceInfo = dmIpcUtils_->ConvertToDmDeviceInfo(dmDeviceInfoExt); + DmDeviceBasicInfo devBasicInfo = dmIpcUtils_->ConvertToDmDeviceBasicInfo(dmDeviceBasicInfoExt); + switch (deviceState) { + case DEVICE_STATE_ONLINE: + LOGI("Online pkgName:%{public}s", pkgName.c_str()); + DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, dmDeviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, devBasicInfo); + break; + case DEVICE_STATE_OFFLINE: + LOGI("Offline pkgName:%{public}s", pkgName.c_str()); + DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, dmDeviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, devBasicInfo); + break; + case DEVICE_INFO_CHANGED: + DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, dmDeviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, devBasicInfo); + break; + case DEVICE_INFO_READY: + LOGI("OnDeviceReady in, pkgName:%{public}s, networkId: %{public}s.", + pkgName.c_str(), GetAnonyString(dmDeviceInfo.networkId).c_str()); + DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, dmDeviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceReady(pkgName, devBasicInfo); + break; + default: + LOGE("unknown device state:%{public}d", deviceState); + break; + } + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerDeviceFound( + const std::string &pkgName, + uint16_t subscribeId, + const DmDeviceInfoExt &dmDeviceInfoExt, + const DmDeviceBasicInfoExt &devBasicInfoExt, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerDeviceFound, pkgName: %{public}s, subscribeId: %{public}d", + pkgName.c_str(), subscribeId); + DmDeviceInfo dmDeviceInfo = dmIpcUtils_->ConvertToDmDeviceInfo(dmDeviceInfoExt); + DmDeviceBasicInfo devBasicInfo = dmIpcUtils_->ConvertToDmDeviceBasicInfo(devBasicInfoExt); + DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceInfo); + DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, devBasicInfo); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerDeviceDiscovery( + const std::string &pkgName, + short subscribeId, + const DmDeviceBasicInfoExt &dmDeviceBasicInfoExt) +{ + DmDeviceBasicInfoExt dmDeviceBasicInfo = dmIpcUtils_->ConvertToDmDeviceBasicInfo(dmDeviceBasicInfoExt); + DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, dmDeviceBasicInfo); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerDiscoverFinish( + const std::string &pkgName, + uint16_t subscribeId, + int32_t failedReason, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerDiscoverFinish, pkgName: %{public}s, subscribeId: %{public}d, reason: %{public}d", + pkgName.c_str(), subscribeId, failedReason); + if (failedReason == DM_OK) { + DeviceManagerNotify::GetInstance().OnDiscoverySuccess(pkgName, subscribeId); + } else { + DeviceManagerNotify::GetInstance().OnDiscoveryFailed(pkgName, subscribeId, failedReason); + } + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerPublishFinish( + const std::string &pkgName, + int32_t publishId, + int32_t publishResult) +{ + LOGI("DM IDL DMNS::ServerPublishFinish : pkgName: %{public}s, publishId: %{public}d, publishResult: %{public}d", + pkgName.c_str(), publishResult, publishResult); + DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, publishId, publishResult); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerAuthResult( + const std::string &pkgName, + const std::string &deviceId, + const std::string &token, + int32_t status, + int32_t reason, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerAuthResult, pkgName %{public}s, deviceId %{public}s, token %{public}s, status %{public}d," + "reason: %{public}d", pkgName.c_str(), deviceId.c_str(), + GetAnonyString(token).c_str(), status, reason); + DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, (uint32_t)status, reason); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerDeviceFaNotify( + const std::string &packagename, + const std::string ¶mJson, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerDeviceFaNotify, pkgName: %{public}s, paramJson: %{public}s, packagename: %{public}s", + processInfoExt.pkgName.c_str(), paramJson.c_str(), packagename.c_str()); + DeviceManagerNotify::GetInstance().OnUiCall(packagename, paramJson); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerCredentialResult( + const std::string &pkgName, + int32_t action, + const std::string &credentialResult, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerCredentialResult %{public}s, action %{public}d, resultInfo %{public}s, pkgName %{public}s", + processInfoExt.pkgName.c_str(), action, credentialResult.c_str(), pkgName.c_str()); + DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerCreatePinHolder( + const std::string &pkgName, + const std::string &deviceId, + int32_t pinType, + const std::string &payload, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerCreatePinHolder : pkgName %{public}s, deviceId %{public}s, payload %{public}s, %{public}s", + pkgName.c_str(), deviceId.c_str(), payload.c_str(), processInfoExt.pkgName.c_str()); + DmPinType dmpinType = Int32ToDmPinType(pinType); + DeviceManagerNotify::GetInstance().OnPinHolderCreate(pkgName, deviceId, dmpinType, payload); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerDestroyPinHolder( + const std::string &pkgName, + int32_t pinType, + const std::string &payload, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerDestroyPinHolder : pkgName %{public}s, payload %{public}s", + processInfoExt.pkgName.c_str(), payload.c_str()); + DmPinType dmpinType = Int32ToDmPinType(pinType); + DeviceManagerNotify::GetInstance().OnPinHolderDestroy(pkgName, dmpinType, payload); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerCreatePinHolderResult( + const std::string &pkgName, + int32_t ret, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerCreatePinHolderResult pkgName %{public}s, result %{public}d", + processInfoExt.pkgName.c_str(), ret); + DeviceManagerNotify::GetInstance().OnCreateResult(pkgName, ret); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerDesTroyPinHolderResult( + const std::string &pkgName, + int32_t ret, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerDesTroyPinHolderResult pkgName %{public}s, result %{public}d", + processInfoExt.pkgName.c_str(), ret); + DeviceManagerNotify::GetInstance().OnDestroyResult(pkgName, ret); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerOnPinHolderEvent( + const std::string &pkgName, + int32_t ret, + int32_t pinHolderEvent, + const std::string &content, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::ServerOnPinHolderEvent pkgName %{public}s, content %{public}s", + processInfoExt.pkgName.c_str(), content.c_str()); + DmPinHolderEvent dmpinHolderEvent = Int32ToDmPinHolderEvent(pinHolderEvent); + DeviceManagerNotify::GetInstance().OnPinHolderEvent(pkgName, dmpinHolderEvent, ret, content); + return 0; +} + +ErrCode DeviceManagerNotifyService::BindTargetResult( + const std::string &pkgName, + const PeerTargetIdExt &targetIdExt, + int32_t ret, + int32_t status, + const std::string &content, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::BindTargetResult pkgName %{public}s, ret %{public}d, status %{public}d, content %{public}s.", + processInfoExt.pkgName.c_str(), ret, status, content.c_str()); + PeerTargetId targetId = dmIpcUtils_->ConvertToPeerTargetId(targetIdExt); + DeviceManagerNotify::GetInstance().OnBindResult(pkgName, targetId, ret, status, content); + return 0; +} + +ErrCode DeviceManagerNotifyService::UnbindTargetResult( + const std::string &pkgName, + const PeerTargetIdExt &targetIdExt, + int32_t ret, + const std::string &content, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::UnbindTargetResult pkgName %{public}s, ret %{public}d, content %{public}s.", + processInfoExt.pkgName.c_str(), ret, content.c_str()); + PeerTargetId targetId = dmIpcUtils_->ConvertToPeerTargetId(targetIdExt); + DeviceManagerNotify::GetInstance().OnUnbindResult(pkgName, targetId, ret, content); + return 0; +} + +ErrCode DeviceManagerNotifyService::RemoteDeviceTrustChange( + const std::string &pkgName, + const std::string &udid, + int32_t authForm, + const std::string &uuid, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::RemoteDeviceTrustChange udid %{public}s, authForm %{public}d, uuid %{public}s.", + GetAnonyString(udid).c_str(), authForm, GetAnonyString(uuid).c_str()); + DmAuthForm dmAuthForm = Int32ToDmAuthForm(authForm); + DeviceManagerNotify::GetInstance().OnDeviceTrustChange(pkgName, udid, uuid, dmAuthForm); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerDeviceScreenStateNotify( + const std::string &pkgName, + const DmDeviceInfoExt &dmDeviceInfoExt, + const ProcessInfoExt &processInfoExt) +{ + DmDeviceInfo dmDeviceInfo = dmIpcUtils_->ConvertToDmDeviceInfo(dmDeviceInfoExt); + DeviceManagerNotify::GetInstance().OnDeviceScreenStatus(pkgName, dmDeviceInfo); + return 0; +} + +ErrCode DeviceManagerNotifyService::ServerCredentialAuthStatusNotify( + const std::string &pkgName, + const std::string &deviceList, + const ProcessInfoExt &processInfoExt, + uint16_t deviceTypeId, + int32_t err) +{ + LOGI("DM IDL DMNS::ServerCredentialAuthStatusNotify, pkgName = %{public}s, deviceList = %{public}s," + "deviceTypeId = %{public}u, err = %{public}d", + processInfoExt.pkgName.c_str(), deviceList.c_str(), deviceTypeId, err); + DeviceManagerNotify::GetInstance().OnCredentialAuthStatus(pkgName, deviceList, deviceTypeId, err); + return 0; +} + +ErrCode DeviceManagerNotifyService::SinkBindTargetResult( + const std::string &pkgName, + const PeerTargetIdExt &targetIdExt, + int32_t ret, + int32_t status, + const std::string &content, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::OnSinkBindResult pkgName %{public}s, userId %{public}d.", + processInfoExt.pkgName.c_str(), processInfoExt.userId); + PeerTargetId targetId = dmIpcUtils_->ConvertToPeerTargetId(targetIdExt); + DeviceManagerNotify::GetInstance().OnSinkBindResult(pkgName, targetId, ret, status, content); + return 0; +} + +ErrCode DeviceManagerNotifyService::GetDeviceProfileInfoListResult( + const std::string &pkgName, + int32_t code, + int32_t deviceNum, + const std::vector &deviceProfileInfosExt, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::GetDeviceProfileInfoListResult pkgName %{public}s.", processInfoExt.pkgName.c_str()); + std::vector deviceProfileInfos; + if (deviceNum > 0 && deviceNum <= MAX_DEVICE_PROFILE_SIZE) { + for (int32_t i = 0; i < deviceNum; ++i) { + DmDeviceProfileInfo deviceInfo; + dmIpcUtils_->ConvertToDmDeviceProfileInfo(deviceProfileInfos, deviceProfileInfosExt); + } + } + + DeviceManagerNotify::GetInstance().OnGetDeviceProfileInfoListResult(pkgName, deviceProfileInfos, code); + return 0; +} + +ErrCode DeviceManagerNotifyService::GetDeviceIconInfoResult( + const std::string &pkgName, + int32_t code, + const DmDeviceIconInfoExt &deviceIconInfoExt, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::GetDeviceIconInfoResult pkgName %{public}s.", processInfoExt.pkgName.c_str()); + DmDeviceIconInfo deviceIconInfo = dmIpcUtils_->ConvertToDmDeviceIconInfo(deviceIconInfoExt); + DeviceManagerNotify::GetInstance().OnGetDeviceIconInfoResult(pkgName, deviceIconInfo, code); + return 0; +} + +ErrCode DeviceManagerNotifyService::SetRemoteDeviceNameResult( + const std::string &pkgName, + const std::string &deviceId, + int32_t code, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::SetRemoteDeviceNameResult pkgName %{public}s.", processInfoExt.pkgName.c_str()); + DeviceManagerNotify::GetInstance().OnSetRemoteDeviceNameResult(pkgName, deviceId, code); + return 0; +} + +ErrCode DeviceManagerNotifyService::SetLocalDeviceNameResult( + const std::string &pkgName, + int32_t code, + const ProcessInfoExt& processInfoExt) +{ + LOGI("DM IDL DMNS::SetLocalDeviceNameResult pkgName %{public}s.", processInfoExt.pkgName.c_str()); + DeviceManagerNotify::GetInstance().OnSetLocalDeviceNameResult(pkgName, code); + return 0; +} + +DmPinType DeviceManagerNotifyService::Int32ToDmPinType(int32_t value) +{ + switch (value) { + case static_cast(DmPinType::NUMBER_PIN_CODE): + return DmPinType::NUMBER_PIN_CODE; + case static_cast(DmPinType::QR_CODE): + return DmPinType::QR_CODE; + case static_cast(DmPinType::VISIBLE_LLIGHT): + return DmPinType::VISIBLE_LLIGHT; + case static_cast(DmPinType::SUPER_SONIC): + return DmPinType::SUPER_SONIC; + default: + return static_cast(-1); + } +} + +DmPinHolderEvent DeviceManagerNotifyService::Int32ToDmPinHolderEvent(int32_t value) +{ + switch (value) { + case static_cast(DmPinHolderEvent::CREATE): + return DmPinHolderEvent::CREATE; + case static_cast(DmPinHolderEvent::CREATE_RESULT): + return DmPinHolderEvent::CREATE_RESULT; + case static_cast(DmPinHolderEvent::DESTROY): + return DmPinHolderEvent::DESTROY; + case static_cast(DmPinHolderEvent::DESTROY_RESULT): + return DmPinHolderEvent::DESTROY_RESULT; + case static_cast(DmPinHolderEvent::PIN_TYPE_CHANGE): + return DmPinHolderEvent::PIN_TYPE_CHANGE; + case static_cast(DmPinHolderEvent::PIN_TYPE_CHANGE_RESULT): + return DmPinHolderEvent::PIN_TYPE_CHANGE_RESULT; + default: + return static_cast(-1); + } +} + +DmAuthForm DeviceManagerNotifyService::Int32ToDmAuthForm(int32_t value) +{ + switch (value) { + case static_cast(DmAuthForm::INVALID_TYPE): + return DmAuthForm::INVALID_TYPE; + case static_cast(DmAuthForm::PEER_TO_PEER): + return DmAuthForm::PEER_TO_PEER; + case static_cast(DmAuthForm::IDENTICAL_ACCOUNT): + return DmAuthForm::IDENTICAL_ACCOUNT; + case static_cast(DmAuthForm::ACROSS_ACCOUNT): + return DmAuthForm::ACROSS_ACCOUNT; + default: + return static_cast(-1); + } +} +} +} \ No newline at end of file diff --git a/services/service/BUILD.gn b/services/service/BUILD.gn index 8f1711c48ddf429198c46d31baad4c813d0ac3a5..4a815b3f616e5bf64d9169206a9fe4c126dae544 100644 --- a/services/service/BUILD.gn +++ b/services/service/BUILD.gn @@ -155,7 +155,9 @@ if (defined(ohos_lite)) { "${utils_path}/include/crypto", "${utils_path}/include/kvadapter", "${utils_path}/include/timer", + "${devicemanager_path}/services/service/include", "${json_path}/include", + "${target_gen_dir}", ] } config("cflags_config") { @@ -201,6 +203,7 @@ if (defined(ohos_lite)) { "${common_path}/src/dm_anonymous.cpp", "${common_path}/src/ipc/standard/ipc_cmd_register.cpp", "${common_path}/src/ipc/standard/ipc_model_codec.cpp", + "${devicemanager_path}/utils/src/dm_ipc_utils.cpp", "src/advertise/advertise_manager.cpp", "src/device_manager_service.cpp", "src/device_manager_service_listener.cpp", @@ -211,7 +214,6 @@ if (defined(ohos_lite)) { "src/hichain/hichain_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", "src/notify/device_manager_service_notify.cpp", "src/permission/standard/permission_manager.cpp", @@ -238,6 +240,7 @@ if (defined(ohos_lite)) { ] deps = [ + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", "${devicemanager_path}/commondependency:devicemanagerdependency", "${devicemanager_path}/radar:devicemanagerradar", "${innerkits_path}/native_cpp:devicemanagersdk", @@ -354,7 +357,6 @@ if (defined(ohos_lite)) { "src/hichain/hichain_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", "src/notify/device_manager_service_notify.cpp", "src/permission/standard/permission_manager.cpp", @@ -381,6 +383,7 @@ if (defined(ohos_lite)) { ] deps = [ + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", "${devicemanager_path}/commondependency:devicemanagerdependency", "${devicemanager_path}/radar:devicemanagerradar", "${innerkits_path}/native_cpp:devicemanagersdk", diff --git a/services/service/IDeviceManagerIpc.idl b/services/service/IDeviceManagerIpc.idl new file mode 100644 index 0000000000000000000000000000000000000000..3d7ad9144554a18d13b175aa3db94fa5324f40c1 --- /dev/null +++ b/services/service/IDeviceManagerIpc.idl @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2025 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. + */ +sequenceable DmDeviceInfo..OHOS.DistributedHardware.DmDeviceBasicInfoExt; +sequenceable DmDeviceInfo..OHOS.DistributedHardware.PeerTargetIdExt; +sequenceable DmDeviceInfo..OHOS.DistributedHardware.DmDeviceInfoExt; +sequenceable DmDeviceInfo..OHOS.DistributedHardware.ProcessInfoExt; +sequenceable DmDeviceProfileInfo..OHOS.DistributedHardware.DmDeviceProfileInfoExt; +sequenceable DmDeviceProfileInfo..OHOS.DistributedHardware.DmDeviceIconInfoExt; +interface OHOS.DistributedHardware.IDeviceManagerIpc { +[ipccode 13] void ServerDeviceStateNotify([in] String pkgName, [in] int deviceState, [in] DmDeviceInfoExt dmDeviceInfoExt, + [in] DmDeviceBasicInfoExt dmDeviceBasicInfoExt, [in] ProcessInfoExt exprocessInfoExt); +[ipccode 14] void ServerDeviceFound([in] String pkgName, [in] unsigned short subscribeId, [in] DmDeviceInfoExt dmDeviceInfoExt, + [in] DmDeviceBasicInfoExt devBasicInfoExt, [in] ProcessInfoExt processInfoExt); +[ipccode 15] void ServerDeviceDiscovery([in] String pkgName, [in] short subscribeId, + [in] DmDeviceBasicInfoExt dmDeviceBasicInfoExt); +[ipccode 16] void ServerDiscoverFinish([in] String pkgName, [in] unsigned short subscribeId, [in] int failedReason, + [in] ProcessInfoExt processInfoExt); +[ipccode 17] void ServerPublishFinish([in] String pkgName, [in] int publishId, [in] int publishResult); +[ipccode 18] void ServerAuthResult([in] String pkgName, [in] String deviceId, [in] String token, [in] int status, [in] int reason, + [in] ProcessInfoExt processInfoExt); +[ipccode 22] void ServerDeviceFaNotify([in] String packagename, [in] String paramJson, [in] ProcessInfoExt processInfoExt); +[ipccode 23] void ServerCredentialResult([in] String pkgName, [in] int action, [in] String credentialResult, + [in] ProcessInfoExt processInfoExt); +[ipccode 44] void ServerCreatePinHolder([in] String pkgName, [in] String deviceId, [in] int pinType, [in] String payload, + [in] ProcessInfoExt processInfoExt); +[ipccode 45] void ServerDestroyPinHolder([in] String pkgName, [in] int pinType, [in] String payload, + [in] ProcessInfoExt processInfoExt); +[ipccode 46] void ServerCreatePinHolderResult([in] String pkgName, [in] int ret, [in] ProcessInfoExt processInfoExt); +[ipccode 47] void ServerDesTroyPinHolderResult([in] String pkgName, [in] int ret, [in] ProcessInfoExt processInfoExt); +[ipccode 48] void ServerOnPinHolderEvent([in] String pkgName, [in] int ret, [in] int pinHolderEvent, [in] String content, + [in] ProcessInfoExt processInfoExt); +[ipccode 57] void BindTargetResult([in] String pkgName, [in] PeerTargetIdExt targetIdExt, [in] int ret, + [in] int status, [in] String content, [in] ProcessInfoExt processInfoExt); +[ipccode 58] void UnbindTargetResult([in] String pkgName, [in] PeerTargetIdExt targetIdExt, [in] int ret, [in] String content, + [in] ProcessInfoExt processInfoExt); +[ipccode 67] void RemoteDeviceTrustChange([in] String pkgName, [in] String udid, [in] int authForm, [in] String uuid, + [in] ProcessInfoExt processInfoExt); +[ipccode 68] void ServerDeviceScreenStateNotify([in] String pkgName, [in] DmDeviceInfoExt dmDeviceInfoExt, + [in] ProcessInfoExt processInfoExt); +[ipccode 71] void ServerCredentialAuthStatusNotify([in] String pkgName, [in] String deviceList, [in] ProcessInfoExt processInfoExt, + [in] unsigned short deviceTypeId, [in] int err); +[ipccode 72] void SinkBindTargetResult([in] String pkgName, [in] PeerTargetIdExt targetIdExt, [in] int ret, [in] int status, + [in] String content, [in] ProcessInfoExt processInfoExt); +[ipccode 77] void GetDeviceProfileInfoListResult([in] String pkgName, [in] int code, [in] int deviceNum, + [in] List deviceProfileInfosExt, [in] ProcessInfoExt processInfoExt); +[ipccode 79] void GetDeviceIconInfoResult([in] String pkgName, [in] int code, [in] DmDeviceIconInfoExt deviceIconInfoExt, + [in] ProcessInfoExt processInfoExt); +[ipccode 83] void SetRemoteDeviceNameResult([in] String pkgName, [in] String deviceId, [in] int code, + [in] ProcessInfoExt processInfoExt); +[ipccode 85] void SetLocalDeviceNameResult([in] String pkgName, [in] int code, [in] ProcessInfoExt processInfoExt); +} \ No newline at end of file diff --git a/services/service/include/device_manager_service_listener.h b/services/service/include/device_manager_service_listener.h index c6b9128b6d27389805d67f6422ed776f0485286b..2ed5fbbba673d08f11b3f09112bd9fd296e6a55a 100644 --- a/services/service/include/device_manager_service_listener.h +++ b/services/service/include/device_manager_service_listener.h @@ -25,20 +25,21 @@ #include "dm_device_info.h" #include "dm_device_profile_info.h" #include "idevice_manager_service_listener.h" +#include "dm_ipc_utils.h" +#include "idevice_manager_ipc.h" #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "kv_adapter_manager.h" #endif #if !defined(__LITEOS_M__) #include "ipc_notify_dmfa_result_req.h" -#include "ipc_server_listener.h" #endif #include "ipc_notify_device_state_req.h" - +#include "ipc_server_stub.h" namespace OHOS { namespace DistributedHardware { class DM_EXPORT DeviceManagerServiceListener : public IDeviceManagerServiceListener { public: - DeviceManagerServiceListener() {}; + DeviceManagerServiceListener(); virtual ~DeviceManagerServiceListener() {}; void OnDeviceStateChange(const ProcessInfo &processInfo, const DmDeviceState &state, @@ -128,13 +129,14 @@ private: void RemoveNotExistProcess(); private: #if !defined(__LITEOS_M__) - IpcServerListener ipcServerListener_; static std::mutex alreadyNotifyPkgNameLock_; static std::map alreadyOnlinePkgName_; static std::unordered_set highPriorityPkgNameSet_; static std::mutex actUnrelatedPkgNameLock_; static std::set actUnrelatedPkgName_; #endif +private: + std::shared_ptr ipcServerStub_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/service/include/ipc/standard/ipc_server_stub.h b/services/service/include/ipc/standard/ipc_server_stub.h index 4756323015470d3d3237c4062accb45a41c08fe8..f3d5afe406328ae8859b8ebe4d41f6c68e42aa85 100644 --- a/services/service/include/ipc/standard/ipc_server_stub.h +++ b/services/service/include/ipc/standard/ipc_server_stub.h @@ -32,7 +32,7 @@ #include "dm_device_info.h" #include "dm_single_instance.h" - +#include "idevice_manager_ipc.h" namespace OHOS { namespace DistributedHardware { enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; @@ -54,6 +54,8 @@ class IpcServerStub : public SystemAbility, public IRemoteStub DM_DECLARE_SINGLE_INSTANCE_BASE(IpcServerStub); public: + IpcServerStub(); + ~IpcServerStub() override = default; /** * @tc.name: IpcServerStub::OnStart * @tc.desc: OnStart of the IpcServerStub @@ -87,7 +89,7 @@ public: * @tc.desc: Register DeviceManager Listener of the IpcServerStub * @tc.type: FUNC */ - int32_t RegisterDeviceManagerListener(const ProcessInfo &processInfo, sptr listener); + int32_t RegisterDeviceManagerListener(const ProcessInfo &processInfo, sptr listener); /** * @tc.name: IpcServerStub::UnRegisterDeviceManagerListener @@ -115,7 +117,7 @@ public: * @tc.desc: Get DmListener of the IpcServerStub * @tc.type: FUNC */ - const sptr GetDmListener(ProcessInfo processInfo) const; + const sptr GetDmListener(ProcessInfo processInfo) const; /** * @tc.name: IpcServerStub::GetDmListenerPkgName @@ -147,8 +149,6 @@ public: std::set GetSystemSA(); private: - IpcServerStub(); - ~IpcServerStub() override = default; bool Init(); void AddSystemSA(const std::string &pkgName); void RemoveSystemSA(const std::string &pkgName); @@ -164,7 +164,7 @@ private: ServiceRunningState state_; mutable std::mutex listenerLock_; std::map> appRecipient_; - std::map> dmListener_; + std::map> dmListener_; std::set systemSA_; int64_t startBeginTime_ = 0; }; diff --git a/services/service/src/device_manager_service_listener.cpp b/services/service/src/device_manager_service_listener.cpp index 7bf14c146627fbc118e152d31e4f6f073774712f..dac227c6fc8f613c51489783e8115975fe5c8f78 100644 --- a/services/service/src/device_manager_service_listener.cpp +++ b/services/service/src/device_manager_service_listener.cpp @@ -42,6 +42,7 @@ #include "ipc_notify_set_local_device_name_req.h" #include "ipc_notify_set_remote_device_name_req.h" #include "ipc_server_stub.h" +#include "dm_ipc_utils.h" #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "datetime_ex.h" #include "device_name_manager.h" @@ -50,7 +51,8 @@ #endif #include "parameter.h" #include "permission_manager.h" - +#include "iservice_registry.h" +#include "system_ability_definition.h" namespace OHOS { namespace DistributedHardware { std::mutex DeviceManagerServiceListener::alreadyNotifyPkgNameLock_; @@ -60,6 +62,12 @@ std::set DeviceManagerServiceListener::actUnrelatedPkgName_ = {}; std::unordered_set DeviceManagerServiceListener::highPriorityPkgNameSet_ = { "ohos.deviceprofile", "ohos.distributeddata.service" }; +DeviceManagerServiceListener::DeviceManagerServiceListener() +{ + LOGI("DeviceManagerServiceListener constructor called."); + ipcServerStub_ = std::make_shared(); +} + void handleExtraData(const DmDeviceInfo &info, DmDeviceBasicInfo &deviceBasicInfo) { cJSON *extraDataJsonObj = cJSON_Parse(info.extraData.c_str()); @@ -122,41 +130,6 @@ void DeviceManagerServiceListener::ConvertDeviceInfoToDeviceBasicInfo(const std: handleExtraData(info, deviceBasicInfo); } -void DeviceManagerServiceListener::SetDeviceInfo(std::shared_ptr pReq, - const ProcessInfo &processInfo, const DmDeviceState &state, const DmDeviceInfo &deviceInfo, - const DmDeviceBasicInfo &deviceBasicInfo) -{ - pReq->SetPkgName(processInfo.pkgName); - pReq->SetProcessInfo(processInfo); - pReq->SetDeviceState(state); - DmDeviceInfo dmDeviceInfo = deviceInfo; - FillUdidAndUuidToDeviceInfo(processInfo.pkgName, dmDeviceInfo); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - std::string appId = ""; - if (AppManager::GetInstance().GetAppIdByPkgName(processInfo.pkgName, appId) != DM_OK) { - pReq->SetDeviceInfo(dmDeviceInfo); - pReq->SetDeviceBasicInfo(deviceBasicInfo); - return; - } - ConvertUdidHashToAnoyAndSave(processInfo.pkgName, dmDeviceInfo); - DmDeviceBasicInfo dmDeviceBasicInfo = deviceBasicInfo; - if (memset_s(dmDeviceBasicInfo.deviceId, DM_MAX_DEVICE_ID_LEN, 0, DM_MAX_DEVICE_ID_LEN) != DM_OK) { - LOGE("ConvertNodeBasicInfoToDmDevice memset failed."); - return; - } - if (memcpy_s(dmDeviceBasicInfo.deviceId, sizeof(dmDeviceBasicInfo.deviceId), dmDeviceInfo.deviceId, - std::min(sizeof(dmDeviceBasicInfo.deviceId), sizeof(dmDeviceInfo.deviceId))) != DM_OK) { - LOGE("ConvertNodeBasicInfoToDmDevice copy deviceId data failed."); - return; - } - pReq->SetDeviceInfo(dmDeviceInfo); - pReq->SetDeviceBasicInfo(dmDeviceBasicInfo); - return; -#endif - pReq->SetDeviceInfo(dmDeviceInfo); - pReq->SetDeviceBasicInfo(deviceBasicInfo); -} - int32_t DeviceManagerServiceListener::FillUdidAndUuidToDeviceInfo(const std::string &pkgName, DmDeviceInfo &dmDeviceInfo) { @@ -192,6 +165,8 @@ int32_t DeviceManagerServiceListener::FillUdidAndUuidToDeviceInfo(const std::str void DeviceManagerServiceListener::ProcessDeviceStateChange(const ProcessInfo &processInfo, const DmDeviceState &state, const DmDeviceInfo &info, const DmDeviceBasicInfo &deviceBasicInfo) { + LOGI("DM IDL ProcessDeviceStateChange In, pkgName: %{public}s, state: %{public}d", + processInfo.pkgName.c_str(), static_cast(state)); std::vector processInfoVec = GetNotifyProcessInfoByUserId(processInfo.userId, DmCommonNotifyEvent::REG_DEVICE_STATE); std::vector hpProcessInfoVec; @@ -226,11 +201,12 @@ void DeviceManagerServiceListener::ProcessDeviceStateChange(const ProcessInfo &p void DeviceManagerServiceListener::ProcessAppStateChange(const ProcessInfo &processInfo, const DmDeviceState &state, const DmDeviceInfo &info, const DmDeviceBasicInfo &deviceBasicInfo) { - LOGI("In"); + LOGI("DM IDL DMSL::ProcessAppStateChange In, pkgName: %{public}s, state: %{public}d", + processInfo.pkgName.c_str(), static_cast(state)); std::vector processInfoVec = GetWhiteListSAProcessInfo(DmCommonNotifyEvent::REG_DEVICE_STATE); ProcessInfo bindProcessInfo = DealBindProcessInfo(processInfo); processInfoVec.push_back(bindProcessInfo); - std::vector allProcessInfos = ipcServerListener_.GetAllProcessInfo(); + std::vector allProcessInfos = ipcServerStub_->GetAllProcessInfo(); switch (static_cast(state)) { case static_cast(DmDeviceState::DEVICE_STATE_ONLINE): ProcessAppOnline(processInfoVec, processInfo, state, info, deviceBasicInfo); @@ -250,6 +226,8 @@ void DeviceManagerServiceListener::ProcessAppStateChange(const ProcessInfo &proc void DeviceManagerServiceListener::OnDeviceStateChange(const ProcessInfo &processInfo, const DmDeviceState &state, const DmDeviceInfo &info) { + LOGI("DM IDL DMSL::OnDeviceStateChange, pkgName: %{public}s, state: %{public}d", + processInfo.pkgName.c_str(), static_cast(state)); DmDeviceBasicInfo deviceBasicInfo; ConvertDeviceInfoToDeviceBasicInfo(processInfo.pkgName, info, deviceBasicInfo); if (processInfo.pkgName == std::string(DM_PKG_NAME)) { @@ -265,229 +243,262 @@ void DeviceManagerServiceListener::OnDeviceStateChange(const ProcessInfo &proces void DeviceManagerServiceListener::OnDeviceFound(const ProcessInfo &processInfo, uint16_t subscribeId, const DmDeviceInfo &info) { - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::OnDeviceFound, pkgName: %{public}s, subscribeId: %{public}d", + processInfo.pkgName.c_str(), subscribeId); DmDeviceInfo deviceInfo = info; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) ConvertUdidHashToAnoyAndSave(processInfo.pkgName, deviceInfo); #endif DmDeviceBasicInfo devBasicInfo; ConvertDeviceInfoToDeviceBasicInfo(processInfo.pkgName, deviceInfo, devBasicInfo); - pReq->SetDeviceBasicInfo(devBasicInfo); - pReq->SetPkgName(processInfo.pkgName); - pReq->SetSubscribeId(subscribeId); - pReq->SetDeviceInfo(deviceInfo); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_DEVICE_FOUND, pReq, pRsp); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(deviceInfo, dmDeviceInfoExt); + DmDeviceBasicInfoExt devBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(devBasicInfo, devBasicInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->ServerDeviceFound(processInfoExt.pkgName, subscribeId, dmDeviceInfoExt, + devBasicInfoExt, processInfoExt); } void DeviceManagerServiceListener::OnDiscoveryFailed(const ProcessInfo &processInfo, uint16_t subscribeId, int32_t failedReason) { - LOGI("OnDiscoveryFailed"); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetSubscribeId(subscribeId); - pReq->SetResult(failedReason); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_DISCOVER_FINISH, pReq, pRsp); + LOGI("DM IDL DMSL::OnDiscoveryFailed, pkgName: %{public}s, subscribeId: %{public}d, reason: %{public}d", + processInfo.pkgName.c_str(), subscribeId, failedReason); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->ServerDiscoverFinish(processInfoExt.pkgName, subscribeId, failedReason, + processInfoExt); } void DeviceManagerServiceListener::OnDiscoverySuccess(const ProcessInfo &processInfo, int32_t subscribeId) { - LOGI("OnDiscoverySuccess"); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetSubscribeId((uint16_t)subscribeId); - pReq->SetResult(DM_OK); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_DISCOVER_FINISH, pReq, pRsp); + LOGI("DM IDL DMSL::OnDiscoverySuccess, pkgName: %{public}s, subscribeId: %{public}d", + processInfo.pkgName.c_str(), subscribeId); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->ServerDiscoverFinish(processInfoExt.pkgName, (uint16_t)subscribeId, DM_OK, + processInfoExt); } void DeviceManagerServiceListener::OnPublishResult(const std::string &pkgName, int32_t publishId, int32_t publishResult) { - LOGI("OnPublishResult : %{public}d", publishResult); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(pkgName); - pReq->SetPublishId(publishId); - pReq->SetResult(publishResult); - ipcServerListener_.SendRequest(SERVER_PUBLISH_FINISH, pReq, pRsp); + LOGI("DM IDL DMSL::OnPublishResult : pkgName: %{public}s, publishId: %{public}d, publishResult: %{public}d", + pkgName.c_str(), publishResult, publishResult); + ProcessInfo processInfo; + processInfo.pkgName = pkgName; + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->ServerPublishFinish(pkgName, publishId, publishResult); } void DeviceManagerServiceListener::OnAuthResult(const ProcessInfo &processInfo, const std::string &deviceId, const std::string &token, int32_t status, int32_t reason) { - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::OnAuthResult, pkgName: %{public}s, deviceId: %{public}s, token: %{public}s, status: %{public}d," + "reason: %{public}d", processInfo.pkgName.c_str(), deviceId.c_str(), + GetAnonyString(token).c_str(), status, reason); if (status < STATUS_DM_AUTH_FINISH && status > STATUS_DM_AUTH_DEFAULT) { status = STATUS_DM_AUTH_DEFAULT; } - pReq->SetDeviceId(deviceId); + std::string deviceIdToUse = deviceId; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) std::string deviceIdTemp = ""; if (ConvertUdidHashToAnoyDeviceId(processInfo.pkgName, deviceId, deviceIdTemp) == DM_OK) { - pReq->SetDeviceId(deviceIdTemp); + deviceIdToUse = deviceIdTemp; } #endif - pReq->SetPkgName(processInfo.pkgName); - pReq->SetToken(token); - pReq->SetStatus(status); - pReq->SetReason(reason); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_AUTH_RESULT, pReq, pRsp); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->ServerAuthResult(processInfoExt.pkgName, deviceIdToUse, token, status, reason, + processInfoExt); } void DeviceManagerServiceListener::OnUiCall(const ProcessInfo &processInfo, std::string ¶mJson) { - LOGI("OnUiCall in"); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetJsonParam(paramJson); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_DEVICE_FA_NOTIFY, pReq, pRsp); + LOGI("DM IDL DMSL::OnUiCall in, pkgName: %{public}s, paramJson: %{public}s", + processInfo.pkgName.c_str(), paramJson.c_str()); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->ServerDeviceFaNotify(processInfoExt.pkgName, paramJson, processInfoExt); } void DeviceManagerServiceListener::OnCredentialResult(const ProcessInfo &processInfo, int32_t action, const std::string &resultInfo) { - LOGI("call OnCredentialResult for %{public}s, action %{public}d", processInfo.pkgName.c_str(), action); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetCredentialAction(action); - pReq->SetCredentialResult(resultInfo); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_CREDENTIAL_RESULT, pReq, pRsp); + LOGI("DM IDL DMSL::OnCredentialResult for %{public}s, action %{public}d, resultInfo %{public}s", + processInfo.pkgName.c_str(), action, resultInfo.c_str()); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->ServerCredentialResult(processInfoExt.pkgName, action, resultInfo, processInfoExt); } void DeviceManagerServiceListener::OnBindResult(const ProcessInfo &processInfo, const PeerTargetId &targetId, int32_t result, int32_t status, std::string content) { - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::OnBindResult pkgName %{public}s, result %{public}d, status %{public}d, content %{public}s.", + processInfo.pkgName.c_str(), result, status, content.c_str()); if (status < STATUS_DM_AUTH_FINISH && status > STATUS_DM_AUTH_DEFAULT) { status = STATUS_DM_AUTH_DEFAULT; } - PeerTargetId returnTargetId = targetId; + PeerTargetIdExt targetIdExt; + DmIpcUtils::ConvertToPeerTargetIdExt(targetId, targetIdExt); + PeerTargetIdExt returnTargetId = targetIdExt; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) std::string deviceIdTemp = ""; DmKVValue kvValue; - if (ConvertUdidHashToAnoyDeviceId(processInfo.pkgName, targetId.deviceId, deviceIdTemp) == DM_OK && + if (ConvertUdidHashToAnoyDeviceId(processInfo.pkgName, targetIdExt.deviceId, deviceIdTemp) == DM_OK && KVAdapterManager::GetInstance().Get(deviceIdTemp, kvValue) == DM_OK) { returnTargetId.deviceId = deviceIdTemp; } #endif - pReq->SetPkgName(processInfo.pkgName); - pReq->SetPeerTargetId(returnTargetId); - pReq->SetResult(result); - pReq->SetStatus(status); - pReq->SetContent(content); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(BIND_TARGET_RESULT, pReq, pRsp); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + deviceManagerIpc->BindTargetResult(processInfoExt.pkgName, returnTargetId, result, + status, content, processInfoExt); } void DeviceManagerServiceListener::OnUnbindResult(const ProcessInfo &processInfo, const PeerTargetId &targetId, int32_t result, std::string content) { - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - PeerTargetId returnTargetId = targetId; + LOGI("DM IDL DMSL::OnUnbindResult pkgName %{public}s, result %{public}d, content %{public}s.", + processInfo.pkgName.c_str(), result, content.c_str()); + PeerTargetIdExt targetIdExt; + DmIpcUtils::ConvertToPeerTargetIdExt(targetId, targetIdExt); + PeerTargetId returnTargetId = targetIdExt; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) std::string deviceIdTemp = ""; DmKVValue kvValue; - if (ConvertUdidHashToAnoyDeviceId(processInfo.pkgName, targetId.deviceId, deviceIdTemp) == DM_OK && + if (ConvertUdidHashToAnoyDeviceId(processInfo.pkgName, targetIdExt.deviceId, deviceIdTemp) == DM_OK && KVAdapterManager::GetInstance().Get(deviceIdTemp, kvValue) == DM_OK) { returnTargetId.deviceId = deviceIdTemp; } #endif - pReq->SetPkgName(processInfo.pkgName); - pReq->SetPeerTargetId(returnTargetId); - pReq->SetResult(result); - pReq->SetContent(content); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(UNBIND_TARGET_RESULT, pReq, pRsp); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->UnbindTargetResult(processInfoExt.pkgName, returnTargetId, result, content, + processInfoExt); } void DeviceManagerServiceListener::OnPinHolderCreate(const ProcessInfo &processInfo, const std::string &deviceId, DmPinType pinType, const std::string &payload) { - LOGI("OnPinHolderCreate : %{public}s", processInfo.pkgName.c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetDeviceId(deviceId); - pReq->SetPinType(pinType); - pReq->SetPayload(payload); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_CREATE_PIN_HOLDER, pReq, pRsp); + LOGI("DM IDL DMSL::OnPinHolderCreate : pkgName %{public}s, deviceId %{public}s, payload %{public}s", + processInfo.pkgName.c_str(), deviceId.c_str(), payload.c_str()); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->ServerCreatePinHolder(processInfoExt.pkgName, deviceId, pinType, payload, processInfoExt); } void DeviceManagerServiceListener::OnPinHolderDestroy(const ProcessInfo &processInfo, DmPinType pinType, const std::string &payload) { - LOGI("OnPinHolderDestroy : %{public}s", processInfo.pkgName.c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetPinType(pinType); - pReq->SetPayload(payload); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_DESTROY_PIN_HOLDER, pReq, pRsp); + LOGI("DM IDL DMSL::OnPinHolderDestroy : pkgName %{public}s, payload %{public}s", + processInfo.pkgName.c_str(), payload.c_str()); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->ServerDestroyPinHolder(processInfoExt.pkgName, pinType, payload, processInfoExt); } void DeviceManagerServiceListener::OnCreateResult(const ProcessInfo &processInfo, int32_t result) { - LOGI("OnCreateResult : %{public}d", result); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetResult(result); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_CREATE_PIN_HOLDER_RESULT, pReq, pRsp); + LOGI("DM IDL DMSL::OnCreateResult : pkgName %{public}s, result %{public}d", processInfo.pkgName.c_str(), result); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->ServerCreatePinHolderResult(processInfoExt.pkgName, result, processInfoExt); } void DeviceManagerServiceListener::OnDestroyResult(const ProcessInfo &processInfo, int32_t result) { - LOGI("OnDestroyResult : %{public}d", result); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetResult(result); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_DESTROY_PIN_HOLDER_RESULT, pReq, pRsp); + LOGI("DM IDL DMSL::OnDestroyResult : pkgName %{public}s, result %{public}d", processInfo.pkgName.c_str(), result); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->ServerDesTroyPinHolderResult(processInfoExt.pkgName, result, processInfoExt); } void DeviceManagerServiceListener::OnPinHolderEvent(const ProcessInfo &processInfo, DmPinHolderEvent event, int32_t result, const std::string &content) { - LOGI("OnPinHolderEvent pkgName: %{public}s, event: %{public}d, result: %{public}d", - processInfo.pkgName.c_str(), event, result); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - - pReq->SetPkgName(processInfo.pkgName); - pReq->SetPinHolderEvent(event); - pReq->SetResult(result); - pReq->SetContent(content); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(SERVER_ON_PIN_HOLDER_EVENT, pReq, pRsp); + LOGI("DM IDL DMSL::OnPinHolderEvent pkgName %{public}s, event %{public}d, result %{public}d, content %{public}s", + processInfo.pkgName.c_str(), event, result, content.c_str()); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->ServerOnPinHolderEvent(processInfoExt.pkgName, result, event, content, processInfoExt); } #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) int32_t DeviceManagerServiceListener::ConvertUdidHashToAnoyAndSave(const std::string &pkgName, DmDeviceInfo &deviceInfo) { + LOGI("DM IDL DMSL::ConvertUdidHashToAnoyAndSave, pkgName: %{public}s, deviceId: %{public}s", + pkgName.c_str(), GetAnonyString(deviceInfo.deviceId).c_str()); std::string appId = ""; if (AppManager::GetInstance().GetAppIdByPkgName(pkgName, appId) != DM_OK) { LOGD("GetAppIdByPkgName failed"); @@ -513,6 +524,8 @@ int32_t DeviceManagerServiceListener::ConvertUdidHashToAnoyAndSave(const std::st int32_t DeviceManagerServiceListener::ConvertUdidHashToAnoyDeviceId(const std::string &pkgName, const std::string &udidHash, std::string &anoyDeviceId) { + LOGI("DM IDL DMSL::ConvertUdidHashToAnoyDeviceId, pkgName: %{public}s, udidHash: %{public}s", + pkgName.c_str(), GetAnonyString(udidHash).c_str()); std::string appId = ""; if (AppManager::GetInstance().GetAppIdByPkgName(pkgName, appId) != DM_OK) { LOGD("GetAppIdByPkgName failed"); @@ -530,10 +543,9 @@ int32_t DeviceManagerServiceListener::ConvertUdidHashToAnoyDeviceId(const std::s void DeviceManagerServiceListener::OnDeviceTrustChange(const std::string &udid, const std::string &uuid, DmAuthForm authForm) { - LOGI("udid %{public}s, authForm %{public}d, uuid %{public}s.", GetAnonyString(udid).c_str(), - authForm, GetAnonyString(uuid).c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::OnDeviceTrustChange udid %{public}s, authForm %{public}d, uuid %{public}s.", + GetAnonyString(udid).c_str(), authForm, GetAnonyString(uuid).c_str()); + int32_t userId = -1; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) userId = MultipleUserConnector::GetFirstForegroundUserId(); @@ -541,41 +553,22 @@ void DeviceManagerServiceListener::OnDeviceTrustChange(const std::string &udid, std::vector processInfoVec = GetNotifyProcessInfoByUserId(userId, DmCommonNotifyEvent::REG_REMOTE_DEVICE_TRUST_CHANGE); for (const auto &item : processInfoVec) { - pReq->SetPkgName(item.pkgName); - pReq->SetUdid(udid); - pReq->SetUuid(uuid); - pReq->SetAuthForm(authForm); - pReq->SetProcessInfo(item); - ipcServerListener_.SendRequest(REMOTE_DEVICE_TRUST_CHANGE, pReq, pRsp); - } -} - -void DeviceManagerServiceListener::SetDeviceScreenInfo(std::shared_ptr pReq, - const ProcessInfo &processInfo, const DmDeviceInfo &deviceInfo) -{ - LOGI("In"); - pReq->SetPkgName(processInfo.pkgName); - pReq->SetProcessInfo(processInfo); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - std::string appId = ""; - if (AppManager::GetInstance().GetAppIdByPkgName(processInfo.pkgName, appId) != DM_OK) { - pReq->SetDeviceInfo(deviceInfo); - return; + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(item, processInfoExt); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(item); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", item.pkgName.c_str()); + return; + } + deviceManagerIpc->RemoteDeviceTrustChange(processInfoExt.pkgName, udid, authForm, uuid, + processInfoExt); } - DmDeviceInfo dmDeviceInfo = deviceInfo; - ConvertUdidHashToAnoyAndSave(processInfo.pkgName, dmDeviceInfo); - pReq->SetDeviceInfo(dmDeviceInfo); - return; -#endif - pReq->SetDeviceInfo(deviceInfo); } void DeviceManagerServiceListener::OnDeviceScreenStateChange(const ProcessInfo &processInfo, DmDeviceInfo &devInfo) { - LOGI("In, pkgName = %{public}s", processInfo.pkgName.c_str()); + LOGI("DM IDL DMSL::OnDeviceScreenStateChange In, pkgName = %{public}s", processInfo.pkgName.c_str()); if (processInfo.pkgName == std::string(DM_PKG_NAME)) { - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); int32_t userId = -1; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) userId = MultipleUserConnector::GetFirstForegroundUserId(); @@ -583,18 +576,36 @@ void DeviceManagerServiceListener::OnDeviceScreenStateChange(const ProcessInfo & std::vector processInfoVec = GetNotifyProcessInfoByUserId(userId, DmCommonNotifyEvent::REG_DEVICE_SCREEN_STATE); for (const auto &item : processInfoVec) { - SetDeviceScreenInfo(pReq, item, devInfo); - ipcServerListener_.SendRequest(SERVER_DEVICE_SCREEN_STATE_NOTIFY, pReq, pRsp); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(item); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", item.pkgName.c_str()); + return; + } + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(devInfo, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(item, processInfoExt); + DmDeviceBasicInfoExt emptyDeviceBasicInfoExt; + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, 0, dmDeviceInfoExt, + emptyDeviceBasicInfoExt, processInfoExt); } } else { - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); std::vector processInfoVec = GetWhiteListSAProcessInfo(DmCommonNotifyEvent::REG_DEVICE_SCREEN_STATE); processInfoVec.push_back(processInfo); for (const auto &item : processInfoVec) { - SetDeviceScreenInfo(pReq, item, devInfo); - ipcServerListener_.SendRequest(SERVER_DEVICE_SCREEN_STATE_NOTIFY, pReq, pRsp); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(item); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", item.pkgName.c_str()); + return; + } + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(devInfo, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(item, processInfoExt); + DmDeviceBasicInfoExt emptyDeviceBasicInfoExt; + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, 0, dmDeviceInfoExt, + emptyDeviceBasicInfoExt, processInfoExt); } } } @@ -617,7 +628,9 @@ void DeviceManagerServiceListener::RemoveOnlinePkgName(const DmDeviceInfo &info) void DeviceManagerServiceListener::OnCredentialAuthStatus(const ProcessInfo &processInfo, const std::string &deviceList, uint16_t deviceTypeId, int32_t errcode) { - LOGI("In, pkgName = %{public}s", processInfo.pkgName.c_str()); + LOGI("DM IDL DMSL::OnCredentialAuthStatus In, pkgName = %{public}s, deviceList = %{public}s," + "deviceTypeId = %{public}u, errcode = %{public}d", + processInfo.pkgName.c_str(), deviceList.c_str(), deviceTypeId, errcode); int32_t userId = -1; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) userId = MultipleUserConnector::GetFirstForegroundUserId(); @@ -625,14 +638,15 @@ void DeviceManagerServiceListener::OnCredentialAuthStatus(const ProcessInfo &pro std::vector processInfoVec = GetNotifyProcessInfoByUserId(userId, DmCommonNotifyEvent::REG_CREDENTIAL_AUTH_STATUS_NOTIFY); for (const auto &item : processInfoVec) { - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - pReq->SetDeviceList(deviceList); - pReq->SetDeviceTypeId(deviceTypeId); - pReq->SetErrCode(errcode); - pReq->SetPkgName(item.pkgName); - pReq->SetProcessInfo(item); - ipcServerListener_.SendRequest(SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY, pReq, pRsp); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(item); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", item.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(item, processInfoExt); + deviceManagerIpc->ServerCredentialAuthStatusNotify(processInfoExt.pkgName, deviceList, processInfoExt, + deviceTypeId, errcode); } } @@ -651,23 +665,23 @@ void DeviceManagerServiceListener::OnAppUnintall(const std::string &pkgName) void DeviceManagerServiceListener::OnSinkBindResult(const ProcessInfo &processInfo, const PeerTargetId &targetId, int32_t result, int32_t status, std::string content) { - LOGI("pkgName %{public}s, userId %{public}d.", processInfo.pkgName.c_str(), processInfo.userId); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::OnSinkBindResult pkgName %{public}s, userId %{public}d.", + processInfo.pkgName.c_str(), processInfo.userId); if (status < STATUS_DM_AUTH_FINISH && status > STATUS_DM_AUTH_DEFAULT) { status = STATUS_DM_AUTH_DEFAULT; } - PeerTargetId returnTargetId = targetId; + PeerTargetIdExt targetIdExt; + DmIpcUtils::ConvertToPeerTargetIdExt(targetId, targetIdExt); + PeerTargetId returnTargetId = targetIdExt; #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) std::string deviceIdTemp = ""; DmKVValue kvValue; - if (ConvertUdidHashToAnoyDeviceId(processInfo.pkgName, targetId.deviceId, deviceIdTemp) == DM_OK && + if (ConvertUdidHashToAnoyDeviceId(processInfo.pkgName, targetIdExt.deviceId, deviceIdTemp) == DM_OK && KVAdapterManager::GetInstance().Get(deviceIdTemp, kvValue) == DM_OK) { returnTargetId.deviceId = deviceIdTemp; } #endif - pReq->SetPkgName(processInfo.pkgName); - std::vector processInfos = ipcServerListener_.GetAllProcessInfo(); + std::vector processInfos = ipcServerStub_->GetAllProcessInfo(); ProcessInfo processInfoTemp; for (auto item : processInfos) { if (item.pkgName == processInfo.pkgName) { @@ -678,17 +692,21 @@ void DeviceManagerServiceListener::OnSinkBindResult(const ProcessInfo &processIn LOGI("not register listener"); return; } - pReq->SetProcessInfo(processInfoTemp); - pReq->SetPeerTargetId(returnTargetId); - pReq->SetResult(result); - pReq->SetStatus(status); - pReq->SetContent(content); - ipcServerListener_.SendRequest(SINK_BIND_TARGET_RESULT, pReq, pRsp); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfoTemp, processInfoExt); + deviceManagerIpc->SinkBindTargetResult(processInfoExt.pkgName, returnTargetId, result, status, content, + processInfoExt); } std::vector DeviceManagerServiceListener::GetWhiteListSAProcessInfo( DmCommonNotifyEvent dmCommonNotifyEvent) { + LOGI("DM IDL DMSL::GetWhiteListSAProcessInfo dmCommonNotifyEvent: %{public}d", dmCommonNotifyEvent); if (!IsDmCommonNotifyEventValid(dmCommonNotifyEvent)) { LOGE("Invalid dmCommonNotifyEvent: %{public}d.", dmCommonNotifyEvent); return {}; @@ -716,6 +734,8 @@ std::vector DeviceManagerServiceListener::GetWhiteListSAProcessInfo std::vector DeviceManagerServiceListener::GetNotifyProcessInfoByUserId(int32_t userId, DmCommonNotifyEvent dmCommonNotifyEvent) { + LOGI("DM IDL DMSL::GetNotifyProcessInfoByUserId userId: %{public}d, dmCommonNotifyEvent: %{public}d", userId, + dmCommonNotifyEvent); if (!IsDmCommonNotifyEventValid(dmCommonNotifyEvent)) { LOGE("Invalid dmCommonNotifyEvent: %{public}d.", dmCommonNotifyEvent); return {}; @@ -726,8 +746,8 @@ std::vector DeviceManagerServiceListener::GetNotifyProcessInfoByUse LOGE("callback not exist dmCommonNotifyEvent: %{public}d", dmCommonNotifyEvent); return {}; } - std::vector processInfos = ipcServerListener_.GetAllProcessInfo(); - std::set systemSA = ipcServerListener_.GetSystemSA(); + std::vector processInfos = ipcServerStub_->GetAllProcessInfo(); + std::set systemSA = ipcServerStub_->GetSystemSA(); std::vector processInfosTemp; for (auto item : processInfos) { if (systemSA.find(item.pkgName) != systemSA.end()) { @@ -748,7 +768,7 @@ std::vector DeviceManagerServiceListener::GetNotifyProcessInfoByUse ProcessInfo DeviceManagerServiceListener::DealBindProcessInfo(const ProcessInfo &processInfo) { - std::set systemSA = ipcServerListener_.GetSystemSA(); + std::set systemSA = ipcServerStub_->GetSystemSA(); if (systemSA.find(processInfo.pkgName) == systemSA.end()) { return processInfo; } @@ -761,10 +781,8 @@ void DeviceManagerServiceListener::ProcessDeviceOnline(const std::vector(state), - GetAnonyString(info.deviceId).c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::ProcessDeviceOnline userId %{public}d, state %{public}d, udidhash %{public}s.", + processInfo.userId, static_cast(state), GetAnonyString(info.deviceId).c_str()); for (const auto &it : procInfoVec) { std::string notifyPkgName = it.pkgName + "#" + std::to_string(it.userId) + "#" + std::string(info.deviceId); DmDeviceState notifyState = state; @@ -776,8 +794,19 @@ void DeviceManagerServiceListener::ProcessDeviceOnline(const std::vector deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(it); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", it.pkgName.c_str()); + return; + } + DmDeviceBasicInfoExt dmDeviceBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(deviceBasicInfo, dmDeviceBasicInfoExt); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(info, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(it, processInfoExt); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, notifyState, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -785,11 +814,9 @@ void DeviceManagerServiceListener::ProcessDeviceOffline(const std::vector(state), - GetAnonyString(info.deviceId).c_str()); + LOGI("DM IDL DMSL::ProcessDeviceOffline userId %{public}d, state %{public}d, udidhash %{public}s.", + processInfo.userId, static_cast(state), GetAnonyString(info.deviceId).c_str()); RemoveNotExistProcess(); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); for (const auto &it : procInfoVec) { { std::lock_guard autoLock(alreadyNotifyPkgNameLock_); @@ -806,8 +833,19 @@ void DeviceManagerServiceListener::ProcessDeviceOffline(const std::vector deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(it); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", it.pkgName.c_str()); + return; + } + DmDeviceBasicInfoExt dmDeviceBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(deviceBasicInfo, dmDeviceBasicInfoExt); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(info, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(it, processInfoExt); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } { std::lock_guard autoLock(alreadyNotifyPkgNameLock_); @@ -819,13 +857,22 @@ void DeviceManagerServiceListener::ProcessDeviceInfoChange(const std::vector(state), - GetAnonyString(info.deviceId).c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::ProcessDeviceInfoChange userId %{public}d, state %{public}d, udidhash %{public}s.", + processInfo.userId, static_cast(state), GetAnonyString(info.deviceId).c_str()); for (const auto &it : procInfoVec) { - SetDeviceInfo(pReq, it, state, info, deviceBasicInfo); - ipcServerListener_.SendRequest(SERVER_DEVICE_STATE_NOTIFY, pReq, pRsp); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(it); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", it.pkgName.c_str()); + return; + } + DmDeviceBasicInfoExt dmDeviceBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(deviceBasicInfo, dmDeviceBasicInfoExt); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(info, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(it, processInfoExt); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -833,10 +880,8 @@ void DeviceManagerServiceListener::ProcessAppOnline(const std::vector(state), - GetAnonyString(info.deviceId).c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); + LOGI("DM IDL DMSL::ProcessAppOnline userId %{public}d, state %{public}d, udidhash %{public}s.", + processInfo.userId, static_cast(state), GetAnonyString(info.deviceId).c_str()); for (const auto &it : procInfoVec) { std::string notifyPkgName = it.pkgName + "#" + std::to_string(it.userId) + "#" + std::string(info.deviceId); DmDeviceState notifyState = state; @@ -848,9 +893,20 @@ void DeviceManagerServiceListener::ProcessAppOnline(const std::vector deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(it); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", it.pkgName.c_str()); + return; + } LOGI("ProcessAppOnline notifyState = %{public}d", notifyState); - SetDeviceInfo(pReq, it, notifyState, info, deviceBasicInfo); - ipcServerListener_.SendRequest(SERVER_DEVICE_STATE_NOTIFY, pReq, pRsp); + DmDeviceBasicInfoExt dmDeviceBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(deviceBasicInfo, dmDeviceBasicInfoExt); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(info, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(it, processInfoExt); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -858,11 +914,9 @@ void DeviceManagerServiceListener::ProcessAppOffline(const std::vector(state), - GetAnonyString(info.deviceId).c_str()); + LOGI("DM IDL DMSL::ProcessAppOffline userId %{public}d, state %{public}d, udidhash %{public}s.", + processInfo.userId, static_cast(state), GetAnonyString(info.deviceId).c_str()); RemoveNotExistProcess(); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); if (!SoftbusCache::GetInstance().CheckIsOnline(std::string(info.deviceId))) { for (const auto &it : procInfoVec) { std::string notifyPkgName = it.pkgName + "#" + std::to_string(it.userId) + "#" + std::string(info.deviceId); @@ -874,8 +928,19 @@ void DeviceManagerServiceListener::ProcessAppOffline(const std::vector deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(it); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", it.pkgName.c_str()); + return; + } + DmDeviceBasicInfoExt dmDeviceBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(deviceBasicInfo, dmDeviceBasicInfoExt); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(info, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(it, processInfoExt); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } else { std::string notifyPkgName = processInfo.pkgName + "#" + std::to_string(processInfo.userId) + "#" + @@ -888,8 +953,19 @@ void DeviceManagerServiceListener::ProcessAppOffline(const std::vector deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + DmDeviceBasicInfoExt dmDeviceBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(deviceBasicInfo, dmDeviceBasicInfoExt); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(info, dmDeviceInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -909,6 +985,8 @@ void DeviceManagerServiceListener::OnProcessRemove(const ProcessInfo &processInf void DeviceManagerServiceListener::OnDevStateCallbackAdd(const ProcessInfo &processInfo, const std::vector &deviceList) { + LOGI("DM IDL DMSL::OnDevStateCallbackAdd pkgName %{public}s, userId %{public}d, deviceList size %{public}zu.", + processInfo.pkgName.c_str(), processInfo.userId, deviceList.size()); for (auto item : deviceList) { std::string notifyPkgName = processInfo.pkgName + "#" + std::to_string(processInfo.userId) + "#" + std::string(item.deviceId); @@ -919,12 +997,22 @@ void DeviceManagerServiceListener::OnDevStateCallbackAdd(const ProcessInfo &proc } alreadyOnlinePkgName_[notifyPkgName] = item; } + sptr deviceManagerIpc = + IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } DmDeviceBasicInfo deviceBasicInfo; - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); ConvertDeviceInfoToDeviceBasicInfo(processInfo.pkgName, item, deviceBasicInfo); - SetDeviceInfo(pReq, processInfo, DmDeviceState::DEVICE_STATE_ONLINE, item, deviceBasicInfo); - ipcServerListener_.SendRequest(SERVER_DEVICE_STATE_NOTIFY, pReq, pRsp); + DmDeviceInfoExt dmDeviceInfoExt; + DmIpcUtils::ConvertToDmDeviceInfoExt(item, dmDeviceInfoExt); + DmDeviceBasicInfoExt dmDeviceBasicInfoExt; + DmIpcUtils::ConvertToDmDeviceBasicInfoExt(deviceBasicInfo, dmDeviceBasicInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, DmDeviceState::DEVICE_STATE_ONLINE, + dmDeviceInfoExt, dmDeviceBasicInfoExt, processInfoExt); } } @@ -952,52 +1040,41 @@ void DeviceManagerServiceListener::RemoveNotExistProcess() void DeviceManagerServiceListener::OnGetDeviceProfileInfoListResult(const ProcessInfo &processInfo, const std::vector &deviceProfileInfos, int32_t code) { - LOGI("pkgName %{public}s.", processInfo.pkgName.c_str()); - std::shared_ptr pReq = - std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - pReq->SetPkgName(processInfo.pkgName); - pReq->SetDeviceProfileInfoList(deviceProfileInfos); -#if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) - std::string userDefinedDeviceName = DeviceNameManager::GetInstance().GetUserDefinedDeviceName(); - if (code == DM_OK && !userDefinedDeviceName.empty()) { - std::vector temVec = deviceProfileInfos; - for (auto &item : temVec) { - if (item.isLocalDevice) { - item.deviceName = userDefinedDeviceName; - break; - } - } - pReq->SetDeviceProfileInfoList(temVec); + LOGI("DM IDL DMSL::OnGetDeviceProfileInfoListResult pkgName %{public}s.", processInfo.pkgName.c_str()); + + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; } -#endif - pReq->SetResult(code); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(GET_DEVICE_PROFILE_INFO_LIST_RESULT, pReq, pRsp); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + std::vector deviceProfileInfosExt; + DmIpcUtils::ConvertToDmDeviceProfileInfoExt(deviceProfileInfos, deviceProfileInfosExt); + deviceManagerIpc->GetDeviceProfileInfoListResult(processInfoExt.pkgName, code, 0, + deviceProfileInfosExt, processInfoExt); } void DeviceManagerServiceListener::OnGetDeviceIconInfoResult(const ProcessInfo &processInfo, const DmDeviceIconInfo &dmDeviceIconInfo, int32_t code) { - LOGI("pkgName %{public}s.", processInfo.pkgName.c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - pReq->SetPkgName(processInfo.pkgName); - pReq->SetDmDeviceIconInfo(dmDeviceIconInfo); - pReq->SetResult(code); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(GET_DEVICE_ICON_INFO_RESULT, pReq, pRsp); + LOGI("DM IDL DMSL::OnGetDeviceIconInfoResult pkgName %{public}s.", processInfo.pkgName.c_str()); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + DmDeviceIconInfoExt deviceIconInfoExt; + DmIpcUtils::ConvertToDmDeviceIconInfoExt(dmDeviceIconInfo, deviceIconInfoExt); + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->GetDeviceIconInfoResult(processInfoExt.pkgName, code, deviceIconInfoExt, processInfoExt); } void DeviceManagerServiceListener::OnSetLocalDeviceNameResult(const ProcessInfo &processInfo, const std::string &deviceName, int32_t code) { - LOGI("pkgName %{public}s.", processInfo.pkgName.c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - pReq->SetPkgName(processInfo.pkgName); - pReq->SetResult(code); - pReq->SetProcessInfo(processInfo); + LOGI("DM IDL DMSL::OnSetLocalDeviceNameResult pkgName %{public}s.", processInfo.pkgName.c_str()); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) if (code == DM_OK) { DeviceNameManager::GetInstance().ModifyUserDefinedName(deviceName); @@ -1005,21 +1082,28 @@ void DeviceManagerServiceListener::OnSetLocalDeviceNameResult(const ProcessInfo #else (void) deviceName; #endif - ipcServerListener_.SendRequest(SET_LOCAL_DEVICE_NAME_RESULT, pReq, pRsp); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->SetLocalDeviceNameResult(processInfoExt.pkgName, code, processInfoExt); } void DeviceManagerServiceListener::OnSetRemoteDeviceNameResult(const ProcessInfo &processInfo, const std::string &deviceId, const std::string &deviceName, int32_t code) { - LOGI("pkgName %{public}s.", processInfo.pkgName.c_str()); - std::shared_ptr pReq = std::make_shared(); - std::shared_ptr pRsp = std::make_shared(); - pReq->SetPkgName(processInfo.pkgName); - pReq->SetDeviceId(deviceId); - pReq->SetResult(code); - pReq->SetProcessInfo(processInfo); - (void) deviceName; - ipcServerListener_.SendRequest(SET_REMOTE_DEVICE_NAME_RESULT, pReq, pRsp); + LOGI("DM IDL DMSL::OnSetRemoteDeviceNameResult pkgName %{public}s.", processInfo.pkgName.c_str()); + sptr deviceManagerIpc = IpcServerStub::GetInstance().GetDmListener(processInfo); + if (deviceManagerIpc == nullptr) { + LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); + return; + } + ProcessInfoExt processInfoExt; + DmIpcUtils::ConvertToProcessInfoExt(processInfo, processInfoExt); + deviceManagerIpc->SetRemoteDeviceNameResult(processInfoExt.pkgName, deviceId, code, processInfoExt); } void DeviceManagerServiceListener::SetExistPkgName(const std::set &pkgNameSet) diff --git a/services/service/src/ipc/standard/ipc_cmd_parser.cpp b/services/service/src/ipc/standard/ipc_cmd_parser.cpp index e8f908bca808e91b7bef061b7d87ed46e4c9e3c3..fc1c5fbf9832ae0921a28a607e8833c53d971e17 100644 --- a/services/service/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/service/src/ipc/standard/ipc_cmd_parser.cpp @@ -49,6 +49,8 @@ #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) #include "multiple_user_connector.h" #endif +#include "device_manager_ipc_proxy.h" +#include "idevice_manager_ipc.h" namespace OHOS { namespace DistributedHardware { const unsigned int XCOLLIE_TIMEOUT_S = 5; @@ -183,226 +185,6 @@ void DecodePeerTargetId(MessageParcel &parcel, PeerTargetId &targetId) targetId.wifiPort = parcel.ReadUint16(); } -ON_IPC_SET_REQUEST(SERVER_DEVICE_STATE_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - int32_t deviceState = pReq->GetDeviceState(); - DmDeviceInfo deviceInfo = pReq->GetDeviceInfo(); - DmDeviceBasicInfo deviceBasicInfo = pReq->GetDeviceBasicInfo(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(deviceState)) { - LOGE("write state failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodeDmDeviceInfo(deviceInfo, data)) { - LOGE("write dm device info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodeDmDeviceBasicInfo(deviceBasicInfo, data)) { - LOGE("write dm device basic info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_DEVICE_FOUND, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - uint16_t subscribeId = pReq->GetSubscribeId(); - DmDeviceInfo deviceInfo = pReq->GetDeviceInfo(); - DmDeviceBasicInfo devBasicInfo = pReq->GetDeviceBasicInfo(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt16((int16_t)subscribeId)) { - LOGE("write subscribeId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodeDmDeviceInfo(deviceInfo, data)) { - LOGE("write dm device info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodeDmDeviceBasicInfo(devBasicInfo, data)) { - LOGE("write dm device basic info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_DEVICE_DISCOVERY, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - uint16_t subscribeId = pReq->GetSubscribeId(); - DmDeviceBasicInfo deviceBasicInfo = pReq->GetDeviceBasicInfo(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt16((int16_t)subscribeId)) { - LOGE("write subscribeId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodeDmDeviceBasicInfo(deviceBasicInfo, data)) { - LOGE("write dm device basic info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DEVICE_DISCOVERY, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - uint16_t subscribeId = pReq->GetSubscribeId(); - int32_t result = pReq->GetResult(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt16((int16_t)subscribeId)) { - LOGE("write subscribeId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write result failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_PUBLISH_FINISH, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - int32_t publishId = pReq->GetPublishId(); - int32_t result = pReq->GetResult(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(publishId)) { - LOGE("write publishId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write result failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_PUBLISH_FINISH, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_AUTH_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - - std::string pkgName = pReq->GetPkgName(); - std::string deviceId = pReq->GetDeviceId(); - std::string token = pReq->GetPinToken(); - int32_t status = pReq->GetStatus(); - int32_t reason = pReq->GetReason(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(deviceId)) { - LOGE("write deviceId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(token)) { - LOGE("write token failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(status)) { - LOGE("write status failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(reason)) { - LOGE("write reason failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_AUTH_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - - std::string packagname = pReq->GetPkgName(); - std::string paramJson = pReq->GetJsonParam(); - if (!data.WriteString(packagname)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(paramJson)) { - LOGE("write paramJson failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(GET_TRUST_DEVICE_LIST, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -463,7 +245,10 @@ ON_IPC_CMD(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &data, MessageParcel CancelXcollieTimer(timerId); return ERR_DM_POINT_NULL; } - sptr callback(new IpcServerClientProxy(listener)); + LOGI("Listener successfully read from MessageParcel. pkgName: %{public}s, listener address: 0x%lx", + pkgName.c_str(), static_cast(reinterpret_cast(listener.GetRefPtr()))); + sptr callback(new DeviceManagerIpcProxy(listener)); + callback->ServerPublishFinish("abc", 2, 3); if (callback == nullptr) { LOGE("create ipc server client proxy failed."); CancelXcollieTimer(timerId); @@ -784,36 +569,6 @@ ON_IPC_CMD(NOTIFY_EVENT, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(SERVER_CREDENTIAL_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - int32_t action = pReq->GetCredentialAction(); - std::string credentialResult = pReq->GetCredentialResult(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(action)) { - LOGE("write action failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(credentialResult)) { - LOGE("write credentialResult failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_CREDENTIAL_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(GET_ENCRYPTED_UUID_BY_NETWOEKID, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -1068,121 +823,6 @@ ON_IPC_CMD(UNBIND_TARGET, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(BIND_TARGET_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - PeerTargetId targetId = pReq->GetPeerTargetId(); - int32_t result = pReq->GetResult(); - int32_t status = pReq->GetStatus(); - std::string content = pReq->GetContent(); - - if (!data.WriteString(pkgName)) { - LOGE("write bind pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodePeerTargetId(targetId, data)) { - LOGE("write bind peer target id failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write bind result code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(status)) { - LOGE("write bind result status failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(content)) { - LOGE("write bind result content failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(BIND_TARGET_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SINK_BIND_TARGET_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - PeerTargetId targetId = pReq->GetPeerTargetId(); - int32_t result = pReq->GetResult(); - int32_t status = pReq->GetStatus(); - std::string content = pReq->GetContent(); - - if (!data.WriteString(pkgName)) { - LOGE("write bind pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodePeerTargetId(targetId, data)) { - LOGE("write bind peer target id failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write bind result code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(status)) { - LOGE("write bind result status failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(content)) { - LOGE("write bind result content failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SINK_BIND_TARGET_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(UNBIND_TARGET_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - PeerTargetId targetId = pReq->GetPeerTargetId(); - int32_t result = pReq->GetResult(); - std::string content = pReq->GetContent(); - - if (!data.WriteString(pkgName)) { - LOGE("write unbind pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodePeerTargetId(targetId, data)) { - LOGE("write unbind peer target id failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write unbind result code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(content)) { - LOGE("write unbind result content failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(UNBIND_TARGET_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(REGISTER_PIN_HOLDER_CALLBACK, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -1224,121 +864,6 @@ ON_IPC_CMD(DESTROY_PIN_HOLDER, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(SERVER_CREATE_PIN_HOLDER, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - std::string deviceId = pReq->GetDeviceId(); - int32_t pinType = pReq->GetPinType(); - std::string payload = pReq->GetPayload(); - - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(deviceId)) { - LOGE("write deviceId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(pinType)) { - LOGE("write pinType failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(payload)) { - LOGE("write payload failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_CREATE_PIN_HOLDER, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_DESTROY_PIN_HOLDER, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - int32_t pinType = pReq->GetPinType(); - std::string payload = pReq->GetPayload(); - - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(pinType)) { - LOGE("write pinType failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(payload)) { - LOGE("write payload failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DESTROY_PIN_HOLDER, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_CREATE_PIN_HOLDER_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - int32_t result = pReq->GetResult(); - - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write result failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_CREATE_PIN_HOLDER_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_DESTROY_PIN_HOLDER_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - int32_t result = pReq->GetResult(); - - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write result failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DESTROY_PIN_HOLDER_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(DP_ACL_ADD, MessageParcel &data, MessageParcel &reply) { std::string udid = data.ReadString(); @@ -1365,41 +890,6 @@ ON_IPC_CMD(GET_SECURITY_LEVEL, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(SERVER_ON_PIN_HOLDER_EVENT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - int32_t pinHolderEvent = pReq->GetPinHolderEvent(); - int32_t result = pReq->GetResult(); - std::string content = pReq->GetContent(); - - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(result)) { - LOGE("write result failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(pinHolderEvent)) { - LOGE("write pinHolderEvent failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(content)) { - LOGE("write content failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_ON_PIN_HOLDER_EVENT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(IS_SAME_ACCOUNT, MessageParcel &data, MessageParcel &reply) { std::string netWorkId = data.ReadString(); @@ -1468,65 +958,6 @@ ON_IPC_CMD(STOP_AUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(REMOTE_DEVICE_TRUST_CHANGE, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - std::string udid = pReq->GetUdid(); - int32_t authForm = pReq->GetAuthForm(); - std::string uuid = pReq->GetUuid(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(udid)) { - LOGE("write udid failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(authForm)) { - LOGE("write authForm code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(uuid)) { - LOGE("write uuid code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(REMOTE_DEVICE_TRUST_CHANGE, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - -ON_IPC_SET_REQUEST(SERVER_DEVICE_SCREEN_STATE_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - DmDeviceInfo deviceInfo = pReq->GetDeviceInfo(); - - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!EncodeDmDeviceInfo(deviceInfo, data)) { - LOGE("write dm device info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVER_DEVICE_SCREEN_STATE_NOTIFY, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(GET_DEVICE_SCREEN_STATUS, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -1574,42 +1005,6 @@ ON_IPC_CMD(GET_ANONY_LOCAL_UDID, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = - std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - std::string deviceList = pReq->GetDeviceList(); - uint16_t deviceTypeId = pReq->GetDeviceTypeId(); - int32_t errCode = pReq->GetErrCode(); - - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteString(deviceList)) { - LOGE("write deviceList failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteUint16(deviceTypeId)) { - LOGE("write deviceTypeId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!data.WriteInt32(errCode)) { - LOGE("write errCode failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(SYNC_CALLBACK, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -1659,42 +1054,6 @@ ON_IPC_CMD(GET_DEVICE_PROFILE_INFO_LIST, MessageParcel &data, MessageParcel &rep return DM_OK; } -ON_IPC_SET_REQUEST(GET_DEVICE_PROFILE_INFO_LIST_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = - std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - int32_t result = pReq->GetResult(); - if (!data.WriteInt32(result)) { - LOGE("write result code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - std::vector deviceProfileInfos = pReq->GetDeviceProfileInfoList(); - if (!data.WriteInt32((int32_t)deviceProfileInfos.size())) { - LOGE("write device list size failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - for (const auto &devInfo : deviceProfileInfos) { - if (!IpcModelCodec::EncodeDmDeviceProfileInfo(devInfo, data)) { - LOGE("write dm device profile info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(GET_DEVICE_PROFILE_INFO_LIST_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(PUT_DEVICE_PROFILE_INFO_LIST, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -1728,35 +1087,6 @@ ON_IPC_CMD(GET_DEVICE_ICON_INFO, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(GET_DEVICE_ICON_INFO_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); - std::shared_ptr pReq = - std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - int32_t result = pReq->GetResult(); - if (!data.WriteInt32(result)) { - LOGE("write result code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - if (!IpcModelCodec::EncodeDmDeviceIconInfo(pReq->GetDmDeviceIconInfo(), data)) { - LOGE("write dm device icon info failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(GET_DEVICE_ICON_INFO_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - CHECK_NULL_RETURN(pBaseRsp, ERR_DM_FAILED); - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(GET_LOCAL_DISPLAY_DEVICE_NAME, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -1840,36 +1170,6 @@ ON_IPC_CMD(SET_LOCAL_DEVICE_NAME, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(SET_LOCAL_DEVICE_NAME_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - if (pBaseReq == nullptr) { - return ERR_DM_FAILED; - } - std::shared_ptr pReq = - std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - int32_t result = pReq->GetResult(); - if (!data.WriteInt32(result)) { - LOGE("write result code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SET_LOCAL_DEVICE_NAME_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - if (pBaseRsp == nullptr) { - LOGE("pBaseRsp is null"); - return ERR_DM_FAILED; - } - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(SET_REMOTE_DEVICE_NAME, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); @@ -1883,41 +1183,6 @@ ON_IPC_CMD(SET_REMOTE_DEVICE_NAME, MessageParcel &data, MessageParcel &reply) return DM_OK; } -ON_IPC_SET_REQUEST(SET_REMOTE_DEVICE_NAME_RESULT, std::shared_ptr pBaseReq, MessageParcel &data) -{ - if (pBaseReq == nullptr) { - return ERR_DM_FAILED; - } - std::shared_ptr pReq = - std::static_pointer_cast(pBaseReq); - std::string pkgName = pReq->GetPkgName(); - if (!data.WriteString(pkgName)) { - LOGE("write pkgName failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - std::string deviceId = pReq->GetDeviceId(); - if (!data.WriteString(deviceId)) { - LOGE("write deviceId failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - int32_t result = pReq->GetResult(); - if (!data.WriteInt32(result)) { - LOGE("write result code failed"); - return ERR_DM_IPC_WRITE_FAILED; - } - return DM_OK; -} - -ON_IPC_READ_RESPONSE(SET_REMOTE_DEVICE_NAME_RESULT, MessageParcel &reply, std::shared_ptr pBaseRsp) -{ - if (pBaseRsp == nullptr) { - LOGE("pBaseRsp is null"); - return ERR_DM_FAILED; - } - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} - ON_IPC_CMD(RESTORE_LOCAL_DEVICE_NAME, MessageParcel &data, MessageParcel &reply) { std::string pkgName = data.ReadString(); diff --git a/services/service/src/ipc/standard/ipc_server_listener.cpp b/services/service/src/ipc/standard/ipc_server_listener.cpp deleted file mode 100644 index b40ee0a405d49b3ee8a084a2eb4ea28a5e810c6e..0000000000000000000000000000000000000000 --- a/services/service/src/ipc/standard/ipc_server_listener.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ipc_server_listener.h" - -#include "device_manager_ipc_interface_code.h" -#include "dm_error_type.h" -#include "dm_log.h" -#include "ipc_server_stub.h" - -namespace OHOS { -namespace DistributedHardware { -int32_t IpcServerListener::SendRequest(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) -{ - if (rsp == nullptr || req == nullptr) { - return ERR_DM_INPUT_PARA_INVALID; - } - if (cmdCode < 0 || cmdCode >= IPC_MSG_BUTT) { - LOGE("IpcServerListener::SendRequest cmdCode param invalid!"); - return ERR_DM_UNSUPPORTED_IPC_COMMAND; - } - ProcessInfo processInfo = req->GetProcessInfo(); - if (processInfo.pkgName.empty()) { - LOGE("Invalid parameter, pkgName is empty."); - return ERR_DM_INPUT_PARA_INVALID; - } - sptr listener = IpcServerStub::GetInstance().GetDmListener(processInfo); - if (listener == nullptr) { - LOGE("cannot get listener for package:%{public}s.", processInfo.pkgName.c_str()); - return ERR_DM_POINT_NULL; - } - return listener->SendCmd(cmdCode, req, rsp); -} - -std::vector IpcServerListener::GetAllProcessInfo() -{ - return IpcServerStub::GetInstance().GetAllProcessInfo(); -} - -std::set IpcServerListener::GetSystemSA() -{ - return IpcServerStub::GetInstance().GetSystemSA(); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/service/src/ipc/standard/ipc_server_stub.cpp b/services/service/src/ipc/standard/ipc_server_stub.cpp index c85383af7292f05e11704bbdbc510063dd097d6b..8c88d6ef217708ae15b23283025e18bf9efcf2b0 100644 --- a/services/service/src/ipc/standard/ipc_server_stub.cpp +++ b/services/service/src/ipc/standard/ipc_server_stub.cpp @@ -282,7 +282,8 @@ ServiceRunningState IpcServerStub::QueryServiceState() const return state_; } -int32_t IpcServerStub::RegisterDeviceManagerListener(const ProcessInfo &processInfo, sptr listener) +int32_t IpcServerStub::RegisterDeviceManagerListener(const ProcessInfo &processInfo, + sptr listener) { if (processInfo.pkgName.empty() || listener == nullptr) { LOGE("RegisterDeviceManagerListener error: input parameter invalid."); @@ -321,6 +322,16 @@ int32_t IpcServerStub::RegisterDeviceManagerListener(const ProcessInfo &processI dmListener_[processInfo] = listener; appRecipient_[processInfo] = appRecipient; AddSystemSA(processInfo.pkgName); + // 打印 dmListener_ 的内容和地址 + LOGI("dmListener_ current size: %{public}zu", dmListener_.size()); + for (const auto &entry : dmListener_) { + const ProcessInfo &info = entry.first; + const sptr &broker = entry.second; + LOGI("dmListener_ element - pkgName: %{public}s, userId: %{public}d, listener address: 0x%lx", + info.pkgName.c_str(), + info.userId, + static_cast(reinterpret_cast(broker.GetRefPtr()))); +} LOGI("complete."); return DM_OK; } @@ -338,6 +349,14 @@ int32_t IpcServerStub::UnRegisterDeviceManagerListener(const ProcessInfo &proces LOGI("Listener not exists"); return DM_OK; } + // 打印当前 dmListener_ 的内容和地址 + LOGI("dmListener_ current size: %{public}zu", dmListener_.size()); + for (const auto &entry : dmListener_) { + LOGI("dmListener_ element - pkgName: %{public}s, userId: %{public}d, listener address: 0x%lx", + entry.first.pkgName.c_str(), + entry.first.userId, + static_cast(reinterpret_cast(entry.second.GetRefPtr()))); +} auto recipientIter = appRecipient_.find(processInfo); if (recipientIter == appRecipient_.end()) { LOGI("AppRecipient not exists"); @@ -364,13 +383,21 @@ std::vector IpcServerStub::GetAllProcessInfo() { std::vector processInfoVec; std::lock_guard autoLock(listenerLock_); + LOGI("dmListener_ current size: %{public}zu", dmListener_.size()); for (const auto &iter : dmListener_) { - processInfoVec.push_back(iter.first); + const ProcessInfo &info = iter.first; + const sptr &listener = iter.second; + // 打印元素内容和地址 + LOGI("dmListener_ element - pkgName: %{public}s, userId: %{public}d, listener address: 0x%lx", + info.pkgName.c_str(), + info.userId, + static_cast(reinterpret_cast(listener.GetRefPtr()))); + processInfoVec.push_back(info); } return processInfoVec; } -const sptr IpcServerStub::GetDmListener(ProcessInfo processInfo) const +const sptr IpcServerStub::GetDmListener(ProcessInfo processInfo) const { if (processInfo.pkgName.empty()) { LOGE("Invalid parameter, pkgName is empty."); @@ -379,8 +406,14 @@ const sptr IpcServerStub::GetDmListener(ProcessInfo processInfo std::lock_guard autoLock(listenerLock_); auto iter = dmListener_.find(processInfo); if (iter == dmListener_.end()) { + LOGI("dmListener_ does not contain pkgName: %{public}s", processInfo.pkgName.c_str()); return nullptr; } + // 打印元素内容和地址 + LOGI("dmListener_ element - pkgName: %{public}s, userId: %{public}d, listener address: 0x%lx", + iter->first.pkgName.c_str(), + iter->first.userId, + static_cast(reinterpret_cast(iter->second.GetRefPtr()))); return iter->second; } diff --git a/test/commonfuzztest/authenticatedevice_fuzzer/BUILD.gn b/test/commonfuzztest/authenticatedevice_fuzzer/BUILD.gn index 11daa7b6b34c829ef7fc318abc6e538c381be7b7..0b2ea9ed7968a222fed28243045bf97269380b1d 100644 --- a/test/commonfuzztest/authenticatedevice_fuzzer/BUILD.gn +++ b/test/commonfuzztest/authenticatedevice_fuzzer/BUILD.gn @@ -64,6 +64,7 @@ ohos_fuzztest("AuthenticateDeviceFuzzTest") { deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/commonfuzztest/authenticatedeviceservice_fuzzer/BUILD.gn b/test/commonfuzztest/authenticatedeviceservice_fuzzer/BUILD.gn index cab2d2cd65eebdef01255ee0801d34016abb3351..49dc2a55e1c4f644f8ce0033a316762f2380062b 100644 --- a/test/commonfuzztest/authenticatedeviceservice_fuzzer/BUILD.gn +++ b/test/commonfuzztest/authenticatedeviceservice_fuzzer/BUILD.gn @@ -59,6 +59,7 @@ ohos_fuzztest("AuthenticateDeviceServiceFuzzTest") { deps = [ "${devicemanager_path}/services/service:devicemanagerservicetest", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/BUILD.gn b/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/BUILD.gn index 91a31da58defc09e577b9606d58cc7b7d0bc0567..c483bac8b129d581e9d3aba129318b4e18603dc0 100644 --- a/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/BUILD.gn +++ b/test/commonfuzztest/authenticatedeviceserviceimpl_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("AuthenticateDeviceServiceImplFuzzTest") { "${devicemanager_path}/services/implementation:devicemanagerserviceimpl", "${devicemanager_path}/services/service:devicemanagerservicetest", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/commonfuzztest/dmcredentialimpl_fuzzer/BUILD.gn b/test/commonfuzztest/dmcredentialimpl_fuzzer/BUILD.gn index 05d532c4cb98d96033d7ebaaa145d8b21ecb399a..2c1c78887a8175b60c0bfaa4aa41e037c203d4f9 100644 --- a/test/commonfuzztest/dmcredentialimpl_fuzzer/BUILD.gn +++ b/test/commonfuzztest/dmcredentialimpl_fuzzer/BUILD.gn @@ -52,7 +52,10 @@ ohos_fuzztest("DMCredentialImplFuzzTest") { sources = [ "dm_credential_impl_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/commonfuzztest/generateencrypteduuid_fuzzer/BUILD.gn b/test/commonfuzztest/generateencrypteduuid_fuzzer/BUILD.gn index b6d56f31ee781fe79c44bd71183a715df969b8cc..c4d341d080365eaa0851de14e390a76dd50703b7 100644 --- a/test/commonfuzztest/generateencrypteduuid_fuzzer/BUILD.gn +++ b/test/commonfuzztest/generateencrypteduuid_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("GenerateEncryptedUuidFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/commonfuzztest/getdeviceinfo_fuzzer/BUILD.gn b/test/commonfuzztest/getdeviceinfo_fuzzer/BUILD.gn index c8cbead482d1639466f483420938ff4c07f44c54..e501c9e7370535db9739491595fdc3bfee9e07e7 100644 --- a/test/commonfuzztest/getdeviceinfo_fuzzer/BUILD.gn +++ b/test/commonfuzztest/getdeviceinfo_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("GetDeviceInfoFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/commonunittest/UTTest_dm_device_state_manager.cpp b/test/commonunittest/UTTest_dm_device_state_manager.cpp index 80aaf0bbf38f2d751c39ed2c7ce3387082572af4..b0d77a1be5eae0934c95ce9f937cb7e15d128869 100644 --- a/test/commonunittest/UTTest_dm_device_state_manager.cpp +++ b/test/commonunittest/UTTest_dm_device_state_manager.cpp @@ -80,31 +80,6 @@ HWTEST_F(DmDeviceStateManagerTest, DmDeviceStateManager_002, testing::ext::TestS EXPECT_EQ(p, nullptr); } -/** - * @tc.name: OnDbReady_001 - * @tc.desc: set info.deviceId to some para, and return it - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(DmDeviceStateManagerTest, OnDbReady_001, testing::ext::TestSize.Level0) -{ - std::string pkgName; - std::string deviceId; - DmDeviceInfo info; - strcpy_s(info.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); - dmDeviceStateManager->OnDbReady(pkgName, deviceId); - std::shared_ptr pReq = - std::static_pointer_cast(listener_->ipcServerListener_.req_); - DmDeviceInfo dminfo; - if (pReq == nullptr) { - strcpy_s(dminfo.deviceId, DM_MAX_DEVICE_ID_LEN, "123"); - } else { - dminfo = pReq->GetDeviceInfo(); - } - int result = strcmp(info.deviceId, dminfo.deviceId); - EXPECT_EQ(result, 0); -} - /** * @tc.name: RegisterOffLineTimer_001 * @tc.desc: call RegisterOffLineTimer diff --git a/test/interfacesfuzztest/devicemanagerimpl_fuzzer/BUILD.gn b/test/interfacesfuzztest/devicemanagerimpl_fuzzer/BUILD.gn index a7e9c70382236ee1d7ae696f97438bb8ea36608b..6e03a0d6837b274b429a1a9cc3387573454dfe0c 100755 --- a/test/interfacesfuzztest/devicemanagerimpl_fuzzer/BUILD.gn +++ b/test/interfacesfuzztest/devicemanagerimpl_fuzzer/BUILD.gn @@ -64,6 +64,7 @@ ohos_fuzztest("DeviceManagerImplFuzzTest") { deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/servicesfuzztest/BUILD.gn b/test/servicesfuzztest/BUILD.gn index e6a972d7f23f1b823e1fd87fa3308e49dc573888..4de1c9e8655998eb949995e18767ffc723382368 100644 --- a/test/servicesfuzztest/BUILD.gn +++ b/test/servicesfuzztest/BUILD.gn @@ -42,8 +42,6 @@ group("fuzztest") { "ipcclientmanager_fuzzer:fuzztest", "ipccmdregister_fuzzer:fuzztest", "ipcserverclientproxy_fuzzer:fuzztest", - "ipcserverlistener_fuzzer:fuzztest", - "ipcserverstub_fuzzer:fuzztest", "notifyevent_fuzzer:fuzztest", "registerdevicemanagerfacallback_fuzzer:fuzztest", "registerdevstatecallback_fuzzer:fuzztest", diff --git a/test/servicesfuzztest/authconfirm_fuzzer/BUILD.gn b/test/servicesfuzztest/authconfirm_fuzzer/BUILD.gn index 810c280fa413d44bfa645e6d74ccd78f7bb6bb3b..a4bbf9272c7071c28021ba9b27765f9977836172 100644 --- a/test/servicesfuzztest/authconfirm_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/authconfirm_fuzzer/BUILD.gn @@ -58,6 +58,7 @@ ohos_fuzztest("AuthConfirmFuzzTest") { "init:libbegetutil", "ipc:ipc_single", "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/test/servicesfuzztest/authmanager_fuzzer/BUILD.gn b/test/servicesfuzztest/authmanager_fuzzer/BUILD.gn index c2add4c2d3e2dec16c3e15b5de7c93fe3a0eac8a..848f35ba856355c0dca9a43ca47afee5b99fc20c 100644 --- a/test/servicesfuzztest/authmanager_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/authmanager_fuzzer/BUILD.gn @@ -58,6 +58,7 @@ ohos_fuzztest("AuthManagerFuzzTest") { "init:libbegetutil", "ipc:ipc_single", "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/test/servicesfuzztest/authmessageprocessor_fuzzer/BUILD.gn b/test/servicesfuzztest/authmessageprocessor_fuzzer/BUILD.gn index 03a5e37e89f666721cb7be213e389163c67875b4..f01482900a022181e7921505f54bfe9f9822da42 100644 --- a/test/servicesfuzztest/authmessageprocessor_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/authmessageprocessor_fuzzer/BUILD.gn @@ -58,6 +58,7 @@ ohos_fuzztest("AuthMessageProcessorFuzzTest") { "init:libbegetutil", "ipc:ipc_single", "kv_store:distributeddata_inner", + "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/test/servicesfuzztest/devicediscovery_fuzzer/BUILD.gn b/test/servicesfuzztest/devicediscovery_fuzzer/BUILD.gn index d25753b45ffe1f0b7d77d77c8f81367c531a27f3..f00f02026449c0d2d02570ddbc7f126359885ff8 100644 --- a/test/servicesfuzztest/devicediscovery_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/devicediscovery_fuzzer/BUILD.gn @@ -59,7 +59,10 @@ ohos_fuzztest("DeviceDiscoveryFuzzTest") { ] sources = [ "device_discovery_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/devicelist_fuzzer/BUILD.gn b/test/servicesfuzztest/devicelist_fuzzer/BUILD.gn index dabde34eb15d93fbedbc1b110d106a3849d186d3..6a0bb8b97b671631040e23c4e554dee811361a0a 100644 --- a/test/servicesfuzztest/devicelist_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/devicelist_fuzzer/BUILD.gn @@ -60,7 +60,10 @@ ohos_fuzztest("DeviceListFuzzTest") { ] sources = [ "device_list_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/devicelistrefresh_fuzzer/BUILD.gn b/test/servicesfuzztest/devicelistrefresh_fuzzer/BUILD.gn index e8f6491639ec04868ed0349a427112839b08ca74..4dc13b1b4091f4cac107547e79743a6103b89d4f 100644 --- a/test/servicesfuzztest/devicelistrefresh_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/devicelistrefresh_fuzzer/BUILD.gn @@ -59,7 +59,10 @@ ohos_fuzztest("DeviceListRefreshFuzzTest") { ] sources = [ "device_list_refresh_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/devicemanagernotify_fuzzer/BUILD.gn b/test/servicesfuzztest/devicemanagernotify_fuzzer/BUILD.gn index d0a50b7ff2c2df6cab1c950c27776a8881a11a98..a43c9116e933951751734b85cb0810061701671f 100644 --- a/test/servicesfuzztest/devicemanagernotify_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/devicemanagernotify_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("DeviceManagerNotifyFuzzTest") { deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/servicesfuzztest/devicemanagerservice_fuzzer/BUILD.gn b/test/servicesfuzztest/devicemanagerservice_fuzzer/BUILD.gn index 21041b11a8e10d60cb6d6176ba98092a71aa77c0..1fdceed9b0bd0a0842d291912199d02e54681e94 100644 --- a/test/servicesfuzztest/devicemanagerservice_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/devicemanagerservice_fuzzer/BUILD.gn @@ -60,6 +60,7 @@ ohos_fuzztest("DeviceManagerServiceFuzzTest") { deps = [ "${devicemanager_path}/services/service:devicemanagerservicetest", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/servicesfuzztest/devicepublish_fuzzer/BUILD.gn b/test/servicesfuzztest/devicepublish_fuzzer/BUILD.gn index 52a8b23f3a4d3d82a062eafabda45b0d44e6444c..e4e89f55b451a7b8701a59ef68ca92752127cc53 100644 --- a/test/servicesfuzztest/devicepublish_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/devicepublish_fuzzer/BUILD.gn @@ -63,6 +63,7 @@ ohos_fuzztest("DevicePublishFuzzTest") { deps = [ "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/BUILD.gn b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/BUILD.gn index 414caff5abfa17dc56bf5c8fb441f024548bd039..5df91ad091fd566f006095fd59d352c69a18e4fa 100644 --- a/test/servicesfuzztest/dmsoftbuslistener_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/dmsoftbuslistener_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("DmSoftbusListenerFuzzTest") { "${devicemanager_path}/services/service:devicemanagerservicetest", "${json_path}:devicemanagerjson", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/servicesfuzztest/getlocaldeviceinfo_fuzzer/BUILD.gn b/test/servicesfuzztest/getlocaldeviceinfo_fuzzer/BUILD.gn index f90940c283f0fa28cd3ec4c6fb31212d66eab56c..8dfb2dfbf6f93ac0a21069312abc82863e6872b8 100644 --- a/test/servicesfuzztest/getlocaldeviceinfo_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/getlocaldeviceinfo_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("GetLocalDeviceInfoFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/servicesfuzztest/gettrusteddevicelistservice_fuzzer/BUILD.gn b/test/servicesfuzztest/gettrusteddevicelistservice_fuzzer/BUILD.gn index 7c353daa95ce804e8b2107f7a9d9cf9c0bcd3a5c..7055a23a8eca02edf42fad6d82f8ee700b86885c 100644 --- a/test/servicesfuzztest/gettrusteddevicelistservice_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/gettrusteddevicelistservice_fuzzer/BUILD.gn @@ -60,6 +60,7 @@ ohos_fuzztest("GetTrustedDeviceListServiceFuzzTest") { deps = [ "${devicemanager_path}/services/service:devicemanagerservicetest", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/servicesfuzztest/getudidbynetworkid_fuzzer/BUILD.gn b/test/servicesfuzztest/getudidbynetworkid_fuzzer/BUILD.gn index 380474c9d2921318fc78c9c26df46436f8220988..9cd0789038ed33d35245a287257c0c8038f97d33 100644 --- a/test/servicesfuzztest/getudidbynetworkid_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/getudidbynetworkid_fuzzer/BUILD.gn @@ -58,7 +58,10 @@ ohos_fuzztest("GetUdidByNetworkIdFuzzTest") { ] sources = [ "get_udid_by_network_id_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/getuuidbynetworkid_fuzzer/BUILD.gn b/test/servicesfuzztest/getuuidbynetworkid_fuzzer/BUILD.gn index 6f32db722bf5d5f7dbc86ce505079dd3174bd188..47092baf36445bf628c04e95bbb3117cb6113949 100644 --- a/test/servicesfuzztest/getuuidbynetworkid_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/getuuidbynetworkid_fuzzer/BUILD.gn @@ -58,7 +58,10 @@ ohos_fuzztest("GetUuidByNetworkIdFuzzTest") { ] sources = [ "get_uuid_by_network_id_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/initdevicemanager_fuzzer/BUILD.gn b/test/servicesfuzztest/initdevicemanager_fuzzer/BUILD.gn index 800fcc952a3507416d31cc643c4dec292bc83007..bcc91e1fe9e2e5623364138ddc1bd6094d20fd55 100644 --- a/test/servicesfuzztest/initdevicemanager_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/initdevicemanager_fuzzer/BUILD.gn @@ -52,7 +52,10 @@ ohos_fuzztest("InitDeviceManagerFuzzTest") { sources = [ "init_device_manager_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/ipcclientmanager_fuzzer/BUILD.gn b/test/servicesfuzztest/ipcclientmanager_fuzzer/BUILD.gn index 04ab3d1024423451c829534a719a31bd4e7018c7..b14d02f6cb9d6492b5a1d151cee5a1c8c508b65f 100644 --- a/test/servicesfuzztest/ipcclientmanager_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/ipcclientmanager_fuzzer/BUILD.gn @@ -61,7 +61,10 @@ ohos_fuzztest("IpcClientManagerFuzzTest") { sources = [ "ipc_client_manager_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/ipccmdregister_fuzzer/BUILD.gn b/test/servicesfuzztest/ipccmdregister_fuzzer/BUILD.gn index 30ec4560599aebe452fa7e8b30b50c83e7e39da6..85a151a42302ec232b357cef0e78eec61ee2873c 100644 --- a/test/servicesfuzztest/ipccmdregister_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/ipccmdregister_fuzzer/BUILD.gn @@ -67,7 +67,10 @@ ohos_fuzztest("IpcCmdRegisterFuzzTest") { "LOG_DOMAIN=0xD004110", ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "c_utils:utils", diff --git a/test/servicesfuzztest/ipcserverstub_fuzzer/BUILD.gn b/test/servicesfuzztest/ipcserverstub_fuzzer/BUILD.gn index a021875d7d5d56c2d21c49abe99fc350f4e6e78e..29e6e4c4f692a2c3406c81402d01993020af7e92 100644 --- a/test/servicesfuzztest/ipcserverstub_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/ipcserverstub_fuzzer/BUILD.gn @@ -60,7 +60,10 @@ ohos_fuzztest("IpcServerStubFuzzTest") { sources = [ "ipc_server_stub_fuzzer.cpp" ] - deps = [ "${devicemanager_path}/services/service:devicemanagerservicetest" ] + deps = [ + "${devicemanager_path}/services/service:devicemanagerservicetest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", @@ -74,6 +77,7 @@ ohos_fuzztest("IpcServerStubFuzzTest") { "data_share:datashare_common", "data_share:datashare_consumer", "device_auth:deviceauth_sdk", + "ffrt:libffrt", "ipc:ipc_core", "ipc:ipc_single", "napi:ace_napi", diff --git a/test/servicesfuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp b/test/servicesfuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp index 1a75d5056d5d3646ec456a6daa445b3059a94823..2c05cdfbbd809f70d1635aa882fcfa631e4399ac 100644 --- a/test/servicesfuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp +++ b/test/servicesfuzztest/ipcserverstub_fuzzer/ipc_server_stub_fuzzer.cpp @@ -53,7 +53,6 @@ void IpcServerStubFuzzTest(const uint8_t* data, size_t size) IpcServerStub::GetInstance().Init(); IpcServerStub::GetInstance().OnRemoteRequest(code, data1, reply, option); - IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); IpcServerStub::GetInstance().GetDmListener(processInfo); IpcServerStub::GetInstance().SendCmd(code, req, rsp); IpcServerStub::GetInstance().GetAllProcessInfo(); diff --git a/test/servicesfuzztest/notifyevent_fuzzer/BUILD.gn b/test/servicesfuzztest/notifyevent_fuzzer/BUILD.gn index dfd1270d57c54b9dc0118f620ea02bd4d017590d..7daa2fc637308353517898d35a2218cc48b6c18e 100644 --- a/test/servicesfuzztest/notifyevent_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/notifyevent_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("NotifyEventFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/servicesfuzztest/registerdevicemanagerfacallback_fuzzer/BUILD.gn b/test/servicesfuzztest/registerdevicemanagerfacallback_fuzzer/BUILD.gn index 9db7b0d3d2848910b7d76832c2a722cf3c3cd319..0c8e244cd97508516b878eb02b7b4cc9cd4befec 100644 --- a/test/servicesfuzztest/registerdevicemanagerfacallback_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/registerdevicemanagerfacallback_fuzzer/BUILD.gn @@ -58,7 +58,10 @@ ohos_fuzztest("RegisterDeviceManagerFaCallbackFuzzTest") { sources = [ "register_device_manager_fa_callback_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/registerdevstatecallback_fuzzer/BUILD.gn b/test/servicesfuzztest/registerdevstatecallback_fuzzer/BUILD.gn index bef378127c31e339f37da25c4751447925a55858..2169e0f68939eca769d7d74cfe00281f3d56e6fc 100644 --- a/test/servicesfuzztest/registerdevstatecallback_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/registerdevstatecallback_fuzzer/BUILD.gn @@ -58,7 +58,10 @@ ohos_fuzztest("RegisterDevStateCallbackFuzzTest") { sources = [ "register_dev_state_callback_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/setuseroperation_fuzzer/BUILD.gn b/test/servicesfuzztest/setuseroperation_fuzzer/BUILD.gn index 6c09931f42e43a2b42a0568c498fe3ecce03f178..155fd93cfd6f4b9f05f1f43f705765ffe6475ed6 100644 --- a/test/servicesfuzztest/setuseroperation_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/setuseroperation_fuzzer/BUILD.gn @@ -58,7 +58,10 @@ ohos_fuzztest("SetUserOperationFuzzTest") { sources = [ "set_user_operation_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/shiftlnngeardeviceservice_fuzzer/BUILD.gn b/test/servicesfuzztest/shiftlnngeardeviceservice_fuzzer/BUILD.gn index a43f96e63a55531e3fb205e09ab9fccb7fc4857c..8ac368a24e0e38b6b23ca0b0a8cc1ccbcb5bf03c 100644 --- a/test/servicesfuzztest/shiftlnngeardeviceservice_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/shiftlnngeardeviceservice_fuzzer/BUILD.gn @@ -60,6 +60,7 @@ ohos_fuzztest("ShiftLNNGearDeviceServiceFuzzTest") { deps = [ "${devicemanager_path}/services/service:devicemanagerservicetest", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/servicesfuzztest/unauthenticatedevice_fuzzer/BUILD.gn b/test/servicesfuzztest/unauthenticatedevice_fuzzer/BUILD.gn index e84dc5c3da069cc7d763368acb287790d5e83628..b500a7a0558aa863beebd7a298a8992632979d84 100644 --- a/test/servicesfuzztest/unauthenticatedevice_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/unauthenticatedevice_fuzzer/BUILD.gn @@ -58,7 +58,10 @@ ohos_fuzztest("UnAuthenticateDeviceFuzzTest") { sources = [ "un_authenticate_device_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/servicesfuzztest/unregisterdevicemanagerfacallback_fuzzer/BUILD.gn b/test/servicesfuzztest/unregisterdevicemanagerfacallback_fuzzer/BUILD.gn index a2b11c1168336b5d16a5352c86b2093ab89189d6..aba66d6d42c029926aaf6cd7a32b2258093d3373 100644 --- a/test/servicesfuzztest/unregisterdevicemanagerfacallback_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/unregisterdevicemanagerfacallback_fuzzer/BUILD.gn @@ -58,7 +58,10 @@ ohos_fuzztest("UnRegisterDeviceManagerFaCallbackFuzzTest") { sources = [ "un_register_device_manager_fa_call_back_fuzzer.cpp" ] - deps = [ "${innerkits_path}/native_cpp:devicemanagersdk" ] + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] defines = [ "HI_LOG_ENABLE", diff --git a/test/softbusfuzztest/closedmradarhelperobj_fuzzer/BUILD.gn b/test/softbusfuzztest/closedmradarhelperobj_fuzzer/BUILD.gn index be65e803c71cc017401a696d1edd29caab62a0f4..87a241199b76d5616d0ea0b60d5697cdca5af4d2 100644 --- a/test/softbusfuzztest/closedmradarhelperobj_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/closedmradarhelperobj_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("CloseDmRadarHelperObjFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn b/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn index 872e0c8a2e6246e43ec7944faae911f92ad0c0ad..8ab843ec9b6c0b16cc425c27cba41c252719309b 100644 --- a/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn @@ -62,6 +62,7 @@ ohos_fuzztest("OnBytesReceivedFuzzTest") { "device_info_manager:distributed_device_profile_common", "device_info_manager:distributed_device_profile_sdk", "dsoftbus:softbus_client", + "ffrt:libffrt", "init:libbegetutil", "safwk:system_ability_fwk", ] diff --git a/test/softbusfuzztest/onparameterchgcallback_fuzzer/BUILD.gn b/test/softbusfuzztest/onparameterchgcallback_fuzzer/BUILD.gn index 7ba953e6c881dda203cea0e306c56a8ac23b056a..d135756db1c02c54a6fc3255052ab8564a5ee186 100644 --- a/test/softbusfuzztest/onparameterchgcallback_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onparameterchgcallback_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("OnParameterChgCallbackFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn index 420fe22764d20857ee06c49a31cbd8c2d43d3110..5bdc5be99c0c3d4a61959a87aafdbd7a855e523b 100644 --- a/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn @@ -43,6 +43,7 @@ ohos_fuzztest("OnSoftbusDeviceInfoChangedFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn index aa9cd8d97b35452d029e68379cdd3113aa461314..f11778186dbce8866edcdace78d2eaba091a6447 100644 --- a/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("OnSoftbusDeviceOfflineFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn index 83ffef54469c1a1a9b70e28c44fd8ba9260ef27b..1dde0ef6851302df692647c6ded8cc09fbd07873 100644 --- a/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("OnSoftbusDeviceOnlineFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn index fc2e6cd206a218d9f7622be4d4434bfc028cfe84..a87e64cf34377ad909ddf33f9426acd51284f792 100644 --- a/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn @@ -43,6 +43,7 @@ ohos_fuzztest("OnSoftbusListenerDeviceFoundFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn b/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn index c3066fa506e90d0e45bb12206983b5898580e37f..6b07754f74303832f4a7dda728107b1e357cbcd5 100644 --- a/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("PublishSoftbusLnnFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn b/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn index 2a4a650e9ec5459b9bafe91e6721f71723a78486..7a9de53d64a85010a87d4e48c94d16f4e09249c1 100644 --- a/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("RefreshSoftbusLnnFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/softbuslistener_fuzzer/BUILD.gn b/test/softbusfuzztest/softbuslistener_fuzzer/BUILD.gn index 56c9f5fac539b66bc84fc4972390d371c0ab3321..f60da9f88cb40e546ae7de7acf746f1a8215eaca 100644 --- a/test/softbusfuzztest/softbuslistener_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/softbuslistener_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("SoftbusListenerFuzzTest") { "${json_path}:devicemanagerjson", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn b/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn index 46986b2f80415ee98a9c38a12e0e094b50a6cae6..e1ea0c1a1a47fa453355347c038c37303e72f508 100644 --- a/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn @@ -45,6 +45,7 @@ ohos_fuzztest("SoftbusListenerGetLocalDeviceInfoFuzzTest") { "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/softbusfuzztest/softbussessionobject_fuzzer/BUILD.gn b/test/softbusfuzztest/softbussessionobject_fuzzer/BUILD.gn index 7f61cc1610435e9f11573f65cb16b8ad34d6dc35..0e8615677a9fe3aa0482af9e3b5e577f1711b9e6 100644 --- a/test/softbusfuzztest/softbussessionobject_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/softbussessionobject_fuzzer/BUILD.gn @@ -57,6 +57,7 @@ ohos_fuzztest("SoftbusSessionObjectFuzzTest") { "device_info_manager:distributed_device_profile_common", "device_info_manager:distributed_device_profile_sdk", "dsoftbus:softbus_client", + "ffrt:libffrt", "init:libbegetutil", "safwk:system_ability_fwk", ] diff --git a/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn b/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn index c844e2e0c4c9d455e33d0da29903cde9b6110cb9..9434d4f75ff90a7bdbc2cc366f92c0fc9ddeedf8 100644 --- a/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("StopRefreshSoftbusLnnFuzzTest") { "${innerkits_path}/native_cpp:devicemanagersdk", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 03fde27c619e7f57c492d4ff5f60a0fb6d29d879..fa34db2b224ea2fc77069ccd8014ca0028616b0b 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -37,12 +37,10 @@ group("unittest") { ":UTTest_device_manager_service", ":UTTest_device_manager_service_impl", ":UTTest_device_manager_service_impl_first", - ":UTTest_device_manager_service_listener", ":UTTest_device_manager_service_notify", ":UTTest_device_manager_service_three", ":UTTest_device_name_manager", ":UTTest_discovery_filter", - ":UTTest_discovery_manager", ":UTTest_dm_account_common_event", ":UTTest_dm_adapter_manager", ":UTTest_dm_anonymous", @@ -75,7 +73,6 @@ group("unittest") { ":UTTest_hichain_auth_connector", ":UTTest_hichain_connector", ":UTTest_hichain_listener", - ":UTTest_ipc_client_manager", ":UTTest_ipc_client_proxy", ":UTTest_ipc_client_server_proxy", ":UTTest_ipc_client_stub", @@ -83,9 +80,6 @@ group("unittest") { ":UTTest_ipc_cmd_parser_service", ":UTTest_ipc_cmd_register", ":UTTest_ipc_get_device_info_rsp", - ":UTTest_ipc_server_client_proxy", - ":UTTest_ipc_server_listener", - ":UTTest_ipc_server_stub", ":UTTest_json_object", ":UTTest_json_str_handle", ":UTTest_kv_adapter_manager", @@ -129,6 +123,7 @@ ohos_unittest("UTTest_pin_auth") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -156,6 +151,7 @@ ohos_unittest("UTTest_pin_auth_ui") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -173,7 +169,10 @@ ohos_unittest("UTTest_ipc_cmd_parser_client") { "UTTest_ipc_cmd_parser_client.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "device_auth:deviceauth_sdk", @@ -182,6 +181,7 @@ ohos_unittest("UTTest_ipc_cmd_parser_client") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] cflags = [ @@ -206,7 +206,10 @@ ohos_unittest("UTTest_ipc_cmd_parser_service") { "UTTest_ipc_cmd_parser_service.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "cJSON:cjson", @@ -215,8 +218,8 @@ ohos_unittest("UTTest_ipc_cmd_parser_service") { "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", "device_info_manager:distributed_device_profile_sdk", - "eventhandler:libeventhandler", "dsoftbus:softbus_client", + "eventhandler:libeventhandler", "ffrt:libffrt", "googletest:gmock", "hicollie:libhicollie", @@ -248,6 +251,7 @@ ohos_unittest("UTTest_ipc_cmd_register") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -337,6 +341,7 @@ ohos_unittest("UTTest_dm_pin_holder") { "googletest:gmock", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -353,6 +358,7 @@ ohos_unittest("UTTest_ipc_get_device_info_rsp") { external_deps = [ "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -372,6 +378,7 @@ ohos_unittest("UTTest_dm_common_event_manager") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -389,6 +396,7 @@ ohos_unittest("device_manager_impl_test") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -424,6 +432,7 @@ ohos_unittest("UTTest_dm_credential_manager") { "googletest:gmock", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -448,7 +457,10 @@ ohos_unittest("UTTest_device_manager_service") { "mock/softbus_listener_mock.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "access_token:libaccesstoken_sdk", @@ -465,6 +477,7 @@ ohos_unittest("UTTest_device_manager_service") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -492,6 +505,7 @@ ohos_unittest("UTTest_dm_softbus_cache") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -525,6 +539,7 @@ ohos_unittest("UTTest_device_manager_service_three") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -549,6 +564,7 @@ ohos_unittest("UTTest_device_manager_service_notify") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -571,6 +587,7 @@ ohos_unittest("UTTest_hichain_auth_connector") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -596,6 +613,7 @@ ohos_unittest("UTTest_hichain_connector") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -618,6 +636,7 @@ ohos_unittest("UTTest_mine_hichain_connector") { "dsoftbus:softbus_client", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -654,6 +673,7 @@ ohos_unittest("UTTest_mine_softbus_listener") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "openssl:libcrypto_shared", + "safwk:system_ability_fwk", ] } @@ -671,7 +691,10 @@ ohos_unittest("UTTest_softbus_connector") { "mock/softbus_center_mock.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "cJSON:cjson", @@ -686,6 +709,7 @@ ohos_unittest("UTTest_softbus_connector") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "os_account:libaccountkits", + "safwk:system_ability_fwk", ] } @@ -724,6 +748,7 @@ ohos_unittest("UTTest_softbus_listener") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -756,6 +781,7 @@ ohos_unittest("UTTest_softbus_listener_two") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -787,6 +813,7 @@ ohos_unittest("UTTest_softbus_publish") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -814,6 +841,7 @@ ohos_unittest("UTTest_softbus_session") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -831,6 +859,7 @@ ohos_unittest("UTTest_dm_adapter_manager") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -854,6 +883,7 @@ ohos_unittest("UTTest_dm_anonymous") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -874,6 +904,7 @@ ohos_unittest("UTTest_dm_timer") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -892,6 +923,7 @@ ohos_unittest("UTTest_dm_transport") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -909,6 +941,7 @@ ohos_unittest("UTTest_dm_transport_msg") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -925,6 +958,7 @@ ohos_unittest("UTTest_dm_service_load") { external_deps = [ "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -943,6 +977,7 @@ ohos_unittest("UTTest_ipc_client_manager") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -960,6 +995,7 @@ ohos_unittest("UTTest_ipc_client_proxy") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -981,6 +1017,7 @@ ohos_unittest("UTTest_ipc_client_stub") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -995,7 +1032,10 @@ ohos_unittest("UTTest_ipc_server_client_proxy") { "UTTest_ipc_server_client_proxy.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "cJSON:cjson", @@ -1072,7 +1112,10 @@ ohos_unittest("UTTest_device_manager_impl") { "mock/device_manager_notify_mock.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "access_token:libaccesstoken_sdk", @@ -1086,6 +1129,7 @@ ohos_unittest("UTTest_device_manager_impl") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] cflags = [ @@ -1105,7 +1149,10 @@ ohos_unittest("UTTest_dm_import_auth_code") { sources = [ "UTTest_dm_import_auth_code.cpp" ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "access_token:libaccesstoken_sdk", @@ -1117,6 +1164,7 @@ ohos_unittest("UTTest_dm_import_auth_code") { "googletest:gmock", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -1141,6 +1189,7 @@ ohos_unittest("UTTest_multiple_user_connector") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -1170,6 +1219,7 @@ ohos_unittest("UTTest_permission_manager") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -1222,13 +1272,17 @@ ohos_unittest("UTTest_device_manager_notify") { "UTTest_device_manager_notify_two.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "device_auth:deviceauth_sdk", "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1246,6 +1300,7 @@ ohos_unittest("UTTest_ipc_client_server_proxy") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1271,6 +1326,7 @@ ohos_unittest("UTTest_dm_device_state_manager") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1300,6 +1356,7 @@ ohos_unittest("UTTest_dm_device_state_manager_two") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1320,6 +1377,7 @@ ohos_unittest("UTTest_dm_dfx") { "googletest:gmock", "hilog:libhilog", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1352,6 +1410,7 @@ ohos_unittest("UTTest_device_manager_service_impl") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -1382,6 +1441,7 @@ ohos_unittest("UTTest_device_manager_service_impl_first") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -1408,9 +1468,11 @@ ohos_unittest("UTTest_device_manager_service_listener") { "device_info_manager:distributed_device_profile_sdk", "dsoftbus:softbus_client", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1436,6 +1498,7 @@ ohos_unittest("UTTest_auth_message_processor") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1447,7 +1510,10 @@ ohos_unittest("UTTest_auth_response_state") { sources = [ "UTTest_auth_response_state.cpp" ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "device_auth:deviceauth_sdk", @@ -1457,6 +1523,7 @@ ohos_unittest("UTTest_auth_response_state") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1478,6 +1545,7 @@ ohos_unittest("UTTest_auth_request_state") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1495,6 +1563,7 @@ ohos_unittest("ipc_client_manager_test") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1529,6 +1598,7 @@ ohos_unittest("UTTest_dm_auth_manager_first") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] cflags = [ @@ -1571,6 +1641,7 @@ ohos_unittest("UTTest_dm_auth_manager_second") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1595,6 +1666,7 @@ ohos_unittest("UTTest_dm_auth_manager_third") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] cflags = [ @@ -1629,6 +1701,7 @@ ohos_unittest("UTTest_dm_radar_helper_test") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1654,6 +1727,7 @@ ohos_unittest("UTTest_discovery_filter") { "device_info_manager:distributed_device_profile_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1681,6 +1755,7 @@ ohos_unittest("UTTest_discovery_manager") { "googletest:gmock", "hilog:libhilog", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1712,6 +1787,7 @@ ohos_unittest("UTTest_dm_deviceprofile_connector") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1741,6 +1817,7 @@ ohos_unittest("UTTest_dm_deviceprofile_connector_second") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1765,6 +1842,7 @@ ohos_unittest("UTTest_dm_distributed_hardware_load") { "googletest:gmock", "hilog:libhilog", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1788,6 +1866,7 @@ ohos_unittest("UTTest_dm_comm_tool") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1806,6 +1885,7 @@ ohos_unittest("UTTest_dm_crypto") { external_deps = [ "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1823,7 +1903,10 @@ ohos_unittest("UTTest_dm_account_common_event") { deps = [ ":device_manager_test_common" ] - external_deps = [ "hilog:libhilog" ] + external_deps = [ + "hilog:libhilog", + "safwk:system_ability_fwk", + ] } ## UnitTest UTTest_dm_account_common_event }}} @@ -1844,6 +1927,7 @@ ohos_unittest("UTTest_dm_publish_common_event") { "bluetooth:btframework", "hilog:libhilog", "wifi:wifi_sdk", + "safwk:system_ability_fwk", ] } @@ -1865,6 +1949,7 @@ ohos_unittest("UTTest_dm_screen_common_event") { "bluetooth:btframework", "hilog:libhilog", "wifi:wifi_sdk", + "safwk:system_ability_fwk", ] } @@ -1885,6 +1970,7 @@ ohos_unittest("UTTest_relationship_sync_mgr") { "cJSON:cjson", "ffrt:libffrt", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1901,7 +1987,10 @@ ohos_unittest("UTTest_hichain_listener") { deps = [ ":device_manager_test_common" ] - external_deps = [ "hilog:libhilog" ] + external_deps = [ + "hilog:libhilog", + "safwk:system_ability_fwk", + ] } ## UnitTest UTTest_hichain_listener }}} @@ -1935,6 +2024,7 @@ ohos_unittest("UTTest_dp_inited_callback") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1961,6 +2051,7 @@ ohos_unittest("UTTest_kv_adapter_manager") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1995,6 +2086,7 @@ ohos_unittest("UTTest_app_manager") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -2013,7 +2105,10 @@ ohos_unittest("UTTest_crypto_mgr") { deps = [ ":device_manager_test_common" ] - external_deps = [ "hilog:libhilog" ] + external_deps = [ + "hilog:libhilog", + "safwk:system_ability_fwk", + ] } ## UnitTest UTTest_crypto_mgr }}} @@ -2045,6 +2140,7 @@ ohos_unittest("UTTest_device_name_manager") { "hilog:libhilog", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "safwk:system_ability_fwk", ] } @@ -2075,6 +2171,7 @@ ohos_unittest("UTTest_advertise_manager") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2092,6 +2189,7 @@ ohos_unittest("UTTest_mini_tools_kit") { "ffrt:libffrt", "googletest:gmock", "googletest:gmock_main", + "safwk:system_ability_fwk", ] } @@ -2110,6 +2208,7 @@ ohos_unittest("UTTest_json_object") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2139,6 +2238,7 @@ ohos_unittest("UTTest_auth_pin_auth_state") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2166,6 +2266,7 @@ ohos_unittest("UTTest_dm_auth_message_processor") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2197,6 +2298,7 @@ ohos_unittest("UTTest_auth_credential_state") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2228,6 +2330,7 @@ ohos_unittest("UTTest_auth_acl") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2262,6 +2365,7 @@ ohos_unittest("UTTest_auth_negotiate") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2293,6 +2397,7 @@ ohos_unittest("UTTest_auth_manager") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2322,6 +2427,7 @@ ohos_unittest("UTTest_auth_confirm") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } diff --git a/test/unittest/UTTest_device_manager_service_listener.cpp b/test/unittest/UTTest_device_manager_service_listener.cpp index 84d1bc6ff9172f4668697f297214e4d284a7b684..2a05732e8879672afb1c6856658fabe5ab0ab785 100644 --- a/test/unittest/UTTest_device_manager_service_listener.cpp +++ b/test/unittest/UTTest_device_manager_service_listener.cpp @@ -692,19 +692,6 @@ HWTEST_F(DeviceManagerServiceListenerTest, OnDeviceTrustChange_001, testing::ext EXPECT_EQ(listener_->alreadyOnlinePkgName_.empty(), false); } -HWTEST_F(DeviceManagerServiceListenerTest, SetDeviceScreenInfo_001, testing::ext::TestSize.Level1) -{ - std::shared_ptr listener_ = std::make_shared(); - std::shared_ptr pReq = std::make_shared(); - ProcessInfo processInfo; - DmDeviceInfo deviceInfo; - processInfo.pkgName = "pkgName"; - EXPECT_CALL(*appManagerMock_, GetAppIdByPkgName(_, _)).Times(::testing::AtLeast(2)).WillOnce(Return(DM_OK)); - EXPECT_CALL(*cryptoMock_, ConvertUdidHashToAnoyAndSave(_, _, _)).WillOnce(Return(DM_OK)); - listener_->SetDeviceScreenInfo(pReq, processInfo, deviceInfo); - EXPECT_EQ(listener_->alreadyOnlinePkgName_.empty(), false); -} - HWTEST_F(DeviceManagerServiceListenerTest, RemoveOnlinePkgName_001, testing::ext::TestSize.Level1) { std::shared_ptr listener_ = std::make_shared(); diff --git a/test/unittest/UTTest_ipc_server_client_proxy.cpp b/test/unittest/UTTest_ipc_server_client_proxy.cpp index f37d754c0a3594112360fc20e97847d5dc44dee6..ed53eec051211da9a3d8a1ec52f38f7e341109d4 100644 --- a/test/unittest/UTTest_ipc_server_client_proxy.cpp +++ b/test/unittest/UTTest_ipc_server_client_proxy.cpp @@ -75,178 +75,6 @@ HWTEST_F(IpcServerClientProxyTest, SendCmd_001, testing::ext::TestSize.Level0) // 4. check ret is DEVICEMANAGER_NULLPTR ASSERT_EQ(ret, ERR_DM_POINT_NULL); } - -/** - * @tc.name: SendCmd_002 - * @tc.desc: 1. set cmdCode not null - * set pkgName not null - * set action not null - * 2. set remoteObject not nullptr - * set req not null - * set rsp not null - * 3. call IpcServerClientProxy SendCmd with parameter - * 4. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerClientProxyTest, SendCmd_002, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode not null - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - // set pkgName not null - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - // set action not null - int deviceState = 1; - DmDeviceInfo deviceInfo; - // 2. set remoteObject not nullptr - sptr remoteObject = sptr(new IpcClientStub()); - IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, remoteObject); - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - // set req not null - req->SetPkgName(pkgName); - // set rsp not null - req->SetDeviceState(deviceState); - req->SetDeviceInfo(deviceInfo); - // 3. call IpcServerClientProxy SendCmd with parameter - int ret = 0; - std::shared_ptr ipcServerListener = std::make_shared(); - ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not ERR_DM_FAILED - ASSERT_NE(ret, ERR_DM_FAILED); -} - -/** - * @tc.name: SendCmd_003 - * @tc.desc: 1. set cmdCode not null - * set pkgName not null - * set action not null - * 2. set remoteObject not nullptr - * set req not null - * set rsp not null - * 3. call IpcServerClientProxy SendCmd with parameter - * 4. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerClientProxyTest, SendCmd_003, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode not null - int32_t cmdCode = SERVER_DEVICE_FOUND; - // set pkgName not null - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - // set action not null - uint16_t subscribeId = 1; - DmDeviceInfo dmDeviceInfo; - // 2. set remoteObject not nullptr - sptr remoteObject = sptr(new IpcClientStub()); - IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, remoteObject); - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - // set req not null - req->SetPkgName(pkgName); - // set rsp not null - req->SetSubscribeId(subscribeId); - req->SetDeviceInfo(dmDeviceInfo); - // 3. call IpcServerClientProxy SendCmd with parameter - int ret = 0; - std::shared_ptr ipcServerListener = std::make_shared(); - ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not ERR_DM_FAILED - ASSERT_NE(ret, ERR_DM_FAILED); -} - -/** - * @tc.name: SendCmd_004 - * @tc.desc: 1. set cmdCode not null - * set pkgName not null - * set action not null - * 2. set remoteObject not nullptr - * set req not null - * set rsp not null - * 3. call IpcServerClientProxy SendCmd with parameter - * 4. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerClientProxyTest, SendCmd_004, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode not null - int32_t cmdCode = SERVER_DISCOVER_FINISH; - // set pkgName not null - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - // set action not null - uint16_t subscribeId = 1; - int32_t result = 1; - // 2. set remoteObject not nullptr - sptr remoteObject = sptr(new IpcClientStub()); - IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, remoteObject); - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - // set req not null - req->SetPkgName(pkgName); - // set rsp not null - req->SetSubscribeId(subscribeId); - req->SetResult(result); - // 3. call IpcServerClientProxy SendCmd with parameter - int ret = 0; - std::shared_ptr ipcServerListener = std::make_shared(); - ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not ERR_DM_FAILED - ASSERT_NE(ret, ERR_DM_FAILED); -} - -/** - * @tc.name: SendCmd_005 - * @tc.desc: 1. set cmdCode not null - * set pkgName not null - * set action not null - * 2. set remoteObject not nullptr - * set req not null - * set rsp not null - * 3. call IpcServerClientProxy SendCmd with parameter - * 4. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: I5N1K3 - */ -HWTEST_F(IpcServerClientProxyTest, SendCmd_005, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode not null - int32_t cmdCode = SERVER_PUBLISH_FINISH; - // set pkgName not null - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - // set action not null - int32_t publishId = 1; - int32_t result = 1; - // 2. set remoteObject not nullptr - sptr remoteObject = sptr(new IpcClientStub()); - IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, remoteObject); - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - // set req not null - req->SetPkgName(pkgName); - // set rsp not null - req->SetPublishId(publishId); - req->SetResult(result); - // 3. call IpcServerClientProxy SendCmd with parameter - int ret = 0; - std::shared_ptr ipcServerListener = std::make_shared(); - ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 4. check ret is not ERR_DM_FAILED - ASSERT_NE(ret, ERR_DM_FAILED); -} } // namespace } // namespace DistributedHardware } // namespace OHOS diff --git a/test/unittest/UTTest_ipc_server_stub.cpp b/test/unittest/UTTest_ipc_server_stub.cpp index 67f91bd307d257e4801efb489f0035e909361e68..a98bbb59940ed183dd085e609aae0d5375302625 100644 --- a/test/unittest/UTTest_ipc_server_stub.cpp +++ b/test/unittest/UTTest_ipc_server_stub.cpp @@ -217,125 +217,6 @@ HWTEST_F(IpcServerStubTest, QueryServiceState_001, testing::ext::TestSize.Level0 ASSERT_EQ(state, ServiceRunningState::STATE_NOT_START); } -/** - * @tc.name: RegisterDeviceManagerListener_001 - * @tc.desc: 1. Call IpcServerStub RegisterDeviceManagerListener - * 2. check IpcServerStub.state is ServiceRunningState::STATE_RUNNING - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_001, testing::ext::TestSize.Level0) -{ - std::string pkgName = ""; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - sptr listener = nullptr; - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - ASSERT_EQ(ret, ERR_DM_POINT_NULL); -} - -/** - * @tc.name: RegisterDeviceManagerListener_002 - * @tc.desc: 1. Call IpcServerStub RegisterDeviceManagerListener - * 2. check IpcServerStub.state is ServiceRunningState::STATE_RUNNING - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_002, testing::ext::TestSize.Level0) -{ - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - sptr listener = sptr(new IpcClientStub()); - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: RegisterDeviceManagerListener_003 - * @tc.desc: 1. Call IpcServerStub RegisterDeviceManagerListener - * 2. check IpcServerStub.state is ServiceRunningState::STATE_RUNNING - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_003, testing::ext::TestSize.Level0) -{ - std::string pkgName = ""; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - sptr listener = sptr(new IpcClientStub()); - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - ASSERT_EQ(ret, ERR_DM_POINT_NULL); -} - -/** - * @tc.name: RegisterDeviceManagerListener_004 - * @tc.desc: 1. Set PkgName is com.ohos.test - * 2. Call IpcServerStub RegisterDeviceManagerListener with param - * 3. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_004, testing::ext::TestSize.Level0) -{ - // 1. Set PkgName is com.ohos.test - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: RegisterDeviceManagerListener_005 - * @tc.desc: 1. Set PkgName is com.ohos.test - * 2. Call IpcServerStub RegisterDeviceManagerListener with param - * 3. check ret is DM_OK - * 4. Call IpcServerStub RegisterDeviceManagerListener with same pkgName another listener - * 5. check result is DM_OK - * 6. earse pkgName for appRecipient_ - * 7. check result is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, RegisterDeviceManagerListener_005, testing::ext::TestSize.Level0) -{ - // 1. Set PkgName is com.ohos.test - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - int result = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); - sptr listener2 = sptr(new IpcClientStub()); - // 4. Call IpcServerStub RegisterDeviceManagerListener with same pkgName another listener - result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener2); - // 5. check result is DM_OK - ASSERT_EQ(result, DM_OK); - sptr listener3 = sptr(new IpcClientStub()); - // 6. earse pkgName for appRecipient_ - IpcServerStub::GetInstance().appRecipient_.erase(processInfo); - result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener3); - // 7. check result is DM_OK - ASSERT_EQ(result, DM_OK); -} - /** * @tc.name: UnRegisterDeviceManagerListener_001 * @tc.desc: 1. Call IpcServerStub UnRegisterDeviceManagerListener @@ -351,36 +232,6 @@ HWTEST_F(IpcServerStubTest, UnRegisterDeviceManagerListener_001, testing::ext::T ASSERT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); } -/** - * @tc.name: UnRegisterDeviceManagerListener_002 - * @tc.desc: 1. Set PkgName is com.ohos.test - * 2. Call IpcServerStub RegisterDeviceManagerListener with param - * 3. check ret is DM_OK - * 4. Call IpcServerStub UnRegisterDeviceManagerListener - * 5. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, UnRegisterDeviceManagerListener_002, testing::ext::TestSize.Level0) -{ - // 1. Set PkgName is com.ohos.test - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); - int result = 0; - // 4. Call IpcServerStub UnRegisterDeviceManagerListener - result = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(processInfo); - // 5. check ret is DM_OK - ASSERT_EQ(result, DM_OK); -} - /** * @tc.name: UnRegisterDeviceManagerListener_003 * @tc.desc: 1. Set pkgName is com.ohos.test @@ -403,204 +254,6 @@ HWTEST_F(IpcServerStubTest, UnRegisterDeviceManagerListener_003, testing::ext::T ASSERT_EQ(ret, DM_OK); } -/** - * @tc.name: UnRegisterDeviceManagerListener_004 - * @tc.desc: 1. Set PkgName is com.ohos.test - * 2. Call IpcServerStub RegisterDeviceManagerListener with param - * 3. check ret is DM_OK - * 4. Call IpcServerStub UnRegisterDeviceManagerListener - * 5. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, UnRegisterDeviceManagerListener_004, testing::ext::TestSize.Level0) -{ - // 1. Set PkgName is com.ohos.test - std::string pkgName = "com.ohos.test1"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); - int result = 0; - // 4. Call IpcServerStub UnRegisterDeviceManagerListener - result = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(processInfo); - // 5. check ret is DM_OK - ASSERT_EQ(result, DM_OK); - sptr dmListener = IpcServerStub::GetInstance().dmListener_[processInfo]; - ASSERT_EQ(dmListener, nullptr); -} - -/** - * @tc.name: UnRegisterDeviceManagerListener_005 - * @tc.desc: 1. Set PkgName is com.ohos.test - * 2. Call IpcServerStub RegisterDeviceManagerListener with param - * 3. check ret is DM_OK - * 4. Call IpcServerStub UnRegisterDeviceManagerListener - * 5. check ret is DM_OK - * 6. Call IpcServerStub UnRegisterDeviceManagerListener - * 7. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, UnRegisterDeviceManagerListener_005, testing::ext::TestSize.Level0) -{ - // 1. Set PkgName is com.ohos.test - std::string pkgName = "com.ohos.test2"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - processInfo.userId = 100; - int ret = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - ret = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); - int result = 0; - // 4. Call IpcServerStub UnRegisterDeviceManagerListener - std::string testPkgName = "com.test"; - result = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(processInfo); - // 5. check ret is DM_OK - ASSERT_EQ(result, DM_OK); - IpcServerStub::GetInstance().appRecipient_.erase(processInfo); - // 6. Call IpcServerStub UnRegisterDeviceManagerListener - result = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(processInfo); - // 7. check ret is DM_OK - ASSERT_EQ(result, DM_OK); -} - -/** - * @tc.name: GetDmListener_001 - * @tc.desc: 1. Set pkgName is com.ohos.test - * 2. Call IpcServerStub GetDmListener - * 3. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, GetDmListener_001, testing::ext::TestSize.Level0) -{ - // 1. Set pkgName is com.ohos.test - ProcessInfo processInfo; - processInfo.pkgName = "com.ohos.test"; - sptr ret = nullptr; - // 2. Call IpcServerStub UnRegisterDeviceManagerListener - ret = IpcServerStub::GetInstance().GetDmListener(processInfo); - // 3. check ret is DM_OK - ASSERT_EQ(ret, nullptr); -} - -/** - * @tc.name: GetDmListener_002 - * @tc.desc: 1. Set pkgName is com.ohos.test - * 2. Call IpcServerStub GetDmListener - * 3. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, GetDmListener_002, testing::ext::TestSize.Level0) -{ - // 1. Set pkgName is com.ohos.test - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - int result = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is DM_OK - ASSERT_EQ(result, DM_OK); - sptr ret = nullptr; - // 2. Call IpcServerStub UnRegisterDeviceManagerListener - ret = IpcServerStub::GetInstance().GetDmListener(processInfo); - // 3. check ret is DM_OK - ASSERT_NE(ret, nullptr); -} - -/** - * @tc.name: GetDmListener_003 - * @tc.desc: 1. Set pkgName is com.ohos.test - * 2. Call IpcServerStub GetDmListener - * 3. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, GetDmListener_003, testing::ext::TestSize.Level0) -{ - // 1. Set pkgName is com.ohos.test - std::string pkgName = "com.ohos.test"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - int result = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is DM_OK - ASSERT_EQ(result, DM_OK); - sptr ret = nullptr; - // 2. Call IpcServerStub UnRegisterDeviceManagerListener - ret = IpcServerStub::GetInstance().GetDmListener(processInfo); - // 3. check ret is DM_OK - ASSERT_NE(ret, nullptr); -} - -/** - * @tc.name: GetDmListener_004 - * @tc.desc: 1. Set pkgName is com.ohos.test - * 2. Call IpcServerStub GetDmListener - * 3. check ret is ERR_DM_POINT_NULL - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, GetDmListener_004, testing::ext::TestSize.Level0) -{ - // 1. Set pkgName is null - std::string pkgName = ""; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - int result = 0; - sptr listener = sptr(new IpcClientStub()); - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is ERR_DM_POINT_NULL - ASSERT_EQ(result, ERR_DM_POINT_NULL); - sptr ret = nullptr; - // 2. Call IpcServerStub UnRegisterDeviceManagerListener - ret = IpcServerStub::GetInstance().GetDmListener(processInfo); - // 3. check ret is nullptr - ASSERT_EQ(ret, nullptr); -} - -/** - * @tc.name: GetDmListener_005 - * @tc.desc: 1. Set pkgName is com.ohos.test - * 2. Call IpcServerStub GetDmListener - * 3. check ret is ERR_DM_POINT_NULL - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, GetDmListener_005, testing::ext::TestSize.Level0) -{ - // 1. Set pkgName is null - std::string pkgName = "com.test.ohos"; - ProcessInfo processInfo; - processInfo.pkgName = pkgName; - int result = 0; - sptr listener = nullptr; - // 2. Call IpcServerStub RegisterDeviceManagerListener with param - result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(processInfo, listener); - // 3. check ret is ERR_DM_POINT_NULL - ASSERT_EQ(result, ERR_DM_POINT_NULL); - sptr ret = nullptr; - // 2. Call IpcServerStub UnRegisterDeviceManagerListener - ret = IpcServerStub::GetInstance().GetDmListener(processInfo); - // 3. check ret is nullptr - ASSERT_EQ(ret, nullptr); -} - /** * @tc.name: OnRemoveSystemAbility_001 * @tc.type: FUNC diff --git a/utils/BUILD.gn b/utils/BUILD.gn index c4d1ba8fe5106a23dc36a67e65a175e117e5a6a1..e49f13a4da141fa3e0c405d7dc5458d01230b0ba 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -128,8 +128,12 @@ if (defined(ohos_lite)) { sources = [ "${common_path}/src/dm_anonymous.cpp", + "${common_path}/src/dm_constants.cpp", + "${innerkits_path}/native_cpp/src/dm_device_info.cpp", + "${innerkits_path}/native_cpp/src/dm_device_profile_info.cpp", "src/appInfo/standard/app_manager.cpp", "src/crypto/dm_crypto.cpp", + "src/dm_ipc_utils.cpp", "src/dm_random.cpp", "src/jsonstr_handle/dm_jsonstr_handle.cpp", "src/kvadapter/dm_kv_info.cpp", diff --git a/services/service/include/ipc/standard/ipc_server_listener.h b/utils/include/dm_ipc_utils.h similarity index 30% rename from services/service/include/ipc/standard/ipc_server_listener.h rename to utils/include/dm_ipc_utils.h index fd6731f6e2b4adbab07b28899960b1113d87df7d..e42dcb42dc6558c5bd873988f41c6e649acfaeb5 100644 --- a/services/service/include/ipc/standard/ipc_server_listener.h +++ b/utils/include/dm_ipc_utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -12,37 +12,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OHOS_DM_IPC_UTILS_H +#define OHOS_DM_IPC_UTILS_H -#ifndef OHOS_DM_IPC_SERVER_LISTENER_H -#define OHOS_DM_IPC_SERVER_LISTENER_H - -#include -#include "ipc_req.h" -#include "ipc_rsp.h" +#include +#include +#include "dm_device_info.h" +#include "dm_device_profile_info.h" namespace OHOS { namespace DistributedHardware { -class IpcServerListener { -public: - IpcServerListener() = default; - virtual ~IpcServerListener() = default; +class DmIpcUtils { public: - /** - * @tc.name: IpcServerListener::SendRequest - * @tc.desc: Send Request of the Ipc Server Listener - * @tc.type: FUNC - */ - int32_t SendRequest(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp); + static void ConvertToProcessInfoExt(const ProcessInfo &base, ProcessInfoExt &ext); + static void ConvertToDmDeviceIconInfoExt(const DmDeviceIconInfo &base, DmDeviceIconInfoExt &ext); + static void ConvertToDmDeviceProfileInfoExt(const std::vector &baseVector, + const std::vector &extVector); + static void ConvertToPeerTargetIdExt(const PeerTargetId &base, PeerTargetIdExt &ext); + static void ConvertToDmDeviceInfoExt(const DmDeviceInfo &base, DmDeviceInfoExt &ext); + static void ConvertToDmDeviceBasicInfoExt(const DmDeviceBasicInfo &base, DmDeviceBasicInfoExt &ext); - /** - * @tc.name: IpcServerListener::GetAllProcessInfo - * @tc.desc: Get All PkgName from stub - * @tc.type: FUNC - */ - std::vector GetAllProcessInfo(); - std::set GetSystemSA(); + static ProcessInfo ConvertToProcessInfo(ProcessInfoExt &ext); + static DmDeviceIconInfo ConvertToDmDeviceIconInfo(const DmDeviceIconInfoExt &ext); + static void ConvertToDmDeviceProfileInfo(const std::vector &baseVector, + const std::vector &extVector); + static PeerTargetId ConvertToPeerTargetId(const PeerTargetIdExt &ext); + static DmDeviceInfo ConvertToDmDeviceInfo(const DmDeviceInfoExt &ext); + static DmDeviceBasicInfo ConvertToDmDeviceBasicInfo(const DmDeviceBasicInfoExt &ext); }; + } // namespace DistributedHardware } // namespace OHOS -#endif // OHOS_DM_IPC_SERVER_LISTENER_H +#endif // OHOS_DM_IPC_UTILS_H \ No newline at end of file diff --git a/utils/src/dm_ipc_utils.cpp b/utils/src/dm_ipc_utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5f3b9411242412140253039cbc92283242291027 --- /dev/null +++ b/utils/src/dm_ipc_utils.cpp @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2025 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 +#include +#include "dm_ipc_utils.h" + +namespace OHOS { +namespace DistributedHardware { + +void DmIpcUtils::ConvertToProcessInfoExt(const ProcessInfo& base, ProcessInfoExt& ext) +{ + ext.userId = base.userId; + ext.pkgName = base.pkgName; +} + +ProcessInfo DmIpcUtils::ConvertToProcessInfo(ProcessInfoExt& ext) +{ + ProcessInfo base; + base.userId = ext.userId; + base.pkgName = ext.pkgName; + return base; +} + +void DmIpcUtils::ConvertToDmDeviceIconInfoExt(const DmDeviceIconInfo& base, DmDeviceIconInfoExt& ext) +{ + ext.productId = base.productId; + ext.subProductId = base.subProductId; + ext.internalModel = base.internalModel; + ext.imageType = base.imageType; + ext.specName = base.specName; + ext.wiseVersion = base.wiseVersion; + ext.version = base.version; + ext.url = base.url; + ext.icon = base.icon; +} + +DmDeviceIconInfo DmIpcUtils::ConvertToDmDeviceIconInfo(const DmDeviceIconInfoExt& ext) +{ + DmDeviceIconInfo base; + base.productId = ext.productId; + base.subProductId = ext.subProductId; + base.internalModel = ext.internalModel; + base.imageType = ext.imageType; + base.specName = ext.specName; + base.wiseVersion = ext.wiseVersion; + base.version = ext.version; + base.url = ext.url; + base.icon = ext.icon; + return base; +} + +void DmIpcUtils::ConvertToDmDeviceProfileInfoExt(const std::vector &baseVector, + const std::vector &extVector) +{ + std::vector tempVector; + tempVector.reserve(baseVector.size()); + for (const auto& base : baseVector) { + DmDeviceProfileInfoExt ext; + ext.deviceId = base.deviceId; + ext.deviceSn = base.deviceSn; + ext.mac = base.mac; + ext.model = base.model; + ext.internalModel = base.internalModel; + ext.deviceType = base.deviceType; + ext.manufacturer = base.manufacturer; + ext.deviceName = base.deviceName; + ext.productName = base.productName; + ext.productId = base.productId; + ext.subProductId = base.subProductId; + ext.sdkVersion = base.sdkVersion; + ext.bleMac = base.bleMac; + ext.brMac = base.brMac; + ext.sleMac = base.sleMac; + ext.firmwareVersion = base.firmwareVersion; + ext.hardwareVersion = base.hardwareVersion; + ext.softwareVersion = base.softwareVersion; + ext.protocolType = base.protocolType; + ext.setupType = base.setupType; + ext.wiseDeviceId = base.wiseDeviceId; + ext.wiseUserId = base.wiseUserId; + ext.registerTime = base.registerTime; + ext.modifyTime = base.modifyTime; + ext.shareTime = base.shareTime; + ext.isLocalDevice = base.isLocalDevice; + ext.services = base.services; + tempVector.push_back(ext); + } +} + +void DmIpcUtils::ConvertToDmDeviceProfileInfo(const std::vector &baseVector, + const std::vector &extVector) +{ + std::vector tempVector; + tempVector.reserve(extVector.size()); + for (const auto& ext : extVector) { + DmDeviceProfileInfo base; + base.deviceId = ext.deviceId; + base.deviceSn = ext.deviceSn; + base.mac = ext.mac; + base.model = ext.model; + base.internalModel = ext.internalModel; + base.deviceType = ext.deviceType; + base.manufacturer = ext.manufacturer; + base.deviceName = ext.deviceName; + base.productName = ext.productName; + base.productId = ext.productId; + base.subProductId = ext.subProductId; + base.sdkVersion = ext.sdkVersion; + base.bleMac = ext.bleMac; + base.brMac = ext.brMac; + base.sleMac = ext.sleMac; + base.firmwareVersion = ext.firmwareVersion; + base.hardwareVersion = ext.hardwareVersion; + base.softwareVersion = ext.softwareVersion; + base.protocolType = ext.protocolType; + base.setupType = ext.setupType; + base.wiseDeviceId = ext.wiseDeviceId; + base.wiseUserId = ext.wiseUserId; + base.registerTime = ext.registerTime; + base.modifyTime = ext.modifyTime; + base.shareTime = ext.shareTime; + base.isLocalDevice = ext.isLocalDevice; + base.services = ext.services; + tempVector.push_back(base); + } +} + +void DmIpcUtils::ConvertToPeerTargetIdExt(const PeerTargetId& base, PeerTargetIdExt& ext) +{ + ext.deviceId = base.deviceId; + ext.brMac = base.brMac; + ext.bleMac = base.bleMac; + ext.wifiIp = base.wifiIp; + ext.wifiPort = base.wifiPort; +} + +PeerTargetId DmIpcUtils::ConvertToPeerTargetId(const PeerTargetIdExt& ext) +{ + PeerTargetId base; + base.deviceId = ext.deviceId; + base.brMac = ext.brMac; + base.bleMac = ext.bleMac; + base.wifiIp = ext.wifiIp; + base.wifiPort = ext.wifiPort; + return base; +} + +void DmIpcUtils::ConvertToDmDeviceInfoExt(const DmDeviceInfo& base, DmDeviceInfoExt& ext) +{ + memcpy_s(ext.deviceId, DM_MAX_DEVICE_ID_LEN, base.deviceId, DM_MAX_DEVICE_ID_LEN); + memcpy_s(ext.deviceName, DM_MAX_DEVICE_ID_LEN, base.deviceName, DM_MAX_DEVICE_NAME_LEN); + ext.deviceTypeId = base.deviceTypeId; + memcpy_s(ext.networkId, DM_MAX_DEVICE_ID_LEN, base.networkId, DM_MAX_DEVICE_ID_LEN); + ext.range = base.range; + ext.networkType = base.networkType; + ext.authForm = base.authForm; + ext.extraData = base.extraData; +} + +DmDeviceInfo DmIpcUtils::ConvertToDmDeviceInfo(const DmDeviceInfoExt& ext) +{ + DmDeviceInfo base; + memcpy_s(base.deviceId, DM_MAX_DEVICE_ID_LEN, ext.deviceId, DM_MAX_DEVICE_ID_LEN); + memcpy_s(base.deviceName, DM_MAX_DEVICE_ID_LEN, ext.deviceName, DM_MAX_DEVICE_NAME_LEN); + base.deviceTypeId = ext.deviceTypeId; + memcpy_s(base.networkId, DM_MAX_DEVICE_ID_LEN, ext.networkId, DM_MAX_DEVICE_ID_LEN); + base.range = ext.range; + base.networkType = ext.networkType; + base.authForm = ext.authForm; + base.extraData = ext.extraData; + return base; +} + +void DmIpcUtils::ConvertToDmDeviceBasicInfoExt(const DmDeviceBasicInfo& base, DmDeviceBasicInfoExt& ext) +{ + memcpy_s(ext.deviceId, DM_MAX_DEVICE_ID_LEN, base.deviceId, DM_MAX_DEVICE_ID_LEN); + memcpy_s(ext.deviceName, DM_MAX_DEVICE_ID_LEN, base.deviceName, DM_MAX_DEVICE_NAME_LEN); + ext.deviceTypeId = base.deviceTypeId; + memcpy_s(ext.networkId, DM_MAX_DEVICE_ID_LEN, base.networkId, DM_MAX_DEVICE_ID_LEN); + ext.extraData = base.extraData; +} + +DmDeviceBasicInfo DmIpcUtils::ConvertToDmDeviceBasicInfo(const DmDeviceBasicInfoExt& ext) +{ + DmDeviceBasicInfo base; + memcpy_s(base.deviceId, DM_MAX_DEVICE_ID_LEN, ext.deviceId, DM_MAX_DEVICE_ID_LEN); + memcpy_s(base.deviceName, DM_MAX_DEVICE_ID_LEN, ext.deviceName, DM_MAX_DEVICE_NAME_LEN); + base.deviceTypeId = ext.deviceTypeId; + memcpy_s(base.networkId, DM_MAX_DEVICE_ID_LEN, ext.networkId, DM_MAX_DEVICE_ID_LEN); + base.extraData = ext.extraData; + return base; +} +} +} \ No newline at end of file