diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 2068a5585b19c581039241a6e5110ae529ed7035..94559b28b923893d6626ae124c859a28be921dc9 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,46 @@ 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 = { + cfi = true + cfi_cross_dso = true + debug = false + boundary_sanitize = true + integer_overflow = true + ubsan = 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 +215,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 +223,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 +237,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..d7567649ba846191eb68293c5fda8ef9f90b460e --- /dev/null +++ b/interfaces/inner_kits/native_cpp/include/notify/device_manager_notify_service.h @@ -0,0 +1,197 @@ +/* + * 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, + 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..4e0486a94305aea2b5e1fa40005b1558fd75fd10 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,143 @@ 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)); + bRet = (bRet && parcel.WriteString(extraData)); + 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; + } + deviceBasicInfoExt->extraData = parcel.ReadString(); + 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..2a5042fabcee6f93e411b4d58255c15be353e677 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 @@ -452,123 +452,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 +626,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 +1090,6 @@ ON_IPC_READ_RESPONSE(UNBIND_TARGET, MessageParcel &reply, std::shared_ptr pBaseReq, MessageParcel &data) { CHECK_NULL_RETURN(pBaseReq, ERR_DM_FAILED); @@ -1371,49 +1216,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 +1259,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 +1335,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 +1403,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 +1491,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 +1514,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 +1721,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 +1756,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..57ee84b7ab2492307444e8ef9c1a2a1efdd98817 --- /dev/null +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify_service.cpp @@ -0,0 +1,405 @@ +/* + * 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, + const std::vector &deviceProfileInfosExt, + const ProcessInfoExt &processInfoExt) +{ + LOGI("DM IDL DMNS::GetDeviceProfileInfoListResult pkgName %{public}s.", processInfoExt.pkgName.c_str()); + std::vector deviceProfileInfos = + dmIpcUtils_->ConvertToDmDeviceProfileInfo(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..c8d0ba1235377e9fe1986ba40bb8fb9d1624579c --- /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] 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 216835016a96327f3e1961ba1e80cab2facb1e72..83af3065e080e75ac1c8cf74d1c38f95c15084f4 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, @@ -97,15 +98,11 @@ public: private: void ConvertDeviceInfoToDeviceBasicInfo(const std::string &pkgName, const DmDeviceInfo &info, DmDeviceBasicInfo &deviceBasicInfo); - void SetDeviceInfo(std::shared_ptr pReq, const ProcessInfo &processInfo, - const DmDeviceState &state, const DmDeviceInfo &deviceInfo, const DmDeviceBasicInfo &deviceBasicInfo); int32_t FillUdidAndUuidToDeviceInfo(const std::string &pkgName, DmDeviceInfo &dmDeviceInfo); void ProcessDeviceStateChange(const ProcessInfo &processInfo, const DmDeviceState &state, const DmDeviceInfo &info, const DmDeviceBasicInfo &deviceBasicInfo); void ProcessAppStateChange(const ProcessInfo &processInfo, const DmDeviceState &state, const DmDeviceInfo &info, const DmDeviceBasicInfo &deviceBasicInfo); - void SetDeviceScreenInfo(std::shared_ptr pReq, const ProcessInfo &processInfo, - const DmDeviceInfo &deviceInfo); void RemoveOnlinePkgName(const DmDeviceInfo &info); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) DM_EXPORT int32_t ConvertUdidHashToAnoyAndSave(const std::string &pkgName, @@ -129,13 +126,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_listener.h b/services/service/include/ipc/standard/ipc_server_listener.h deleted file mode 100644 index fd6731f6e2b4adbab07b28899960b1113d87df7d..0000000000000000000000000000000000000000 --- a/services/service/include/ipc/standard/ipc_server_listener.h +++ /dev/null @@ -1,48 +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. - */ - -#ifndef OHOS_DM_IPC_SERVER_LISTENER_H -#define OHOS_DM_IPC_SERVER_LISTENER_H - -#include -#include "ipc_req.h" -#include "ipc_rsp.h" - -namespace OHOS { -namespace DistributedHardware { -class IpcServerListener { -public: - IpcServerListener() = default; - virtual ~IpcServerListener() = default; - -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); - - /** - * @tc.name: IpcServerListener::GetAllProcessInfo - * @tc.desc: Get All PkgName from stub - * @tc.type: FUNC - */ - std::vector GetAllProcessInfo(); - std::set GetSystemSA(); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DM_IPC_SERVER_LISTENER_H 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 bc47a6a81fc2c3d3908b7aa811a1d160a185c12a..260f123400776e6ce960a0135b03af7e693b16ef 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" @@ -51,7 +52,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_; @@ -61,6 +63,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()); @@ -123,41 +131,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) { @@ -193,6 +166,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; @@ -227,11 +202,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); @@ -251,6 +227,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)) { @@ -266,229 +244,245 @@ 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); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(deviceInfo); + auto devBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(devBasicInfo); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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()); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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()); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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; + auto targetIdExt = DmIpcUtils::ConvertToPeerTargetIdExtWrapper(targetId); + 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); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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()); + auto targetIdExt = DmIpcUtils::ConvertToPeerTargetIdExtWrapper(targetId); + 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->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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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"); @@ -514,6 +508,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"); @@ -531,10 +527,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(); @@ -542,41 +537,21 @@ 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; + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(item); + 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(); @@ -584,18 +559,30 @@ 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; + } + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(devInfo); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(item); + deviceManagerIpc->ServerDeviceScreenStateNotify(processInfoExt.pkgName, dmDeviceInfoExt, + 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; + } + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(devInfo); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(item); + deviceManagerIpc->ServerDeviceScreenStateNotify(processInfoExt.pkgName, dmDeviceInfoExt, + processInfoExt); } } } @@ -618,7 +605,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(); @@ -626,14 +615,14 @@ 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(item); + deviceManagerIpc->ServerCredentialAuthStatusNotify(processInfoExt.pkgName, deviceList, processInfoExt, + deviceTypeId, errcode); } } @@ -652,23 +641,22 @@ 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; + auto targetIdExt = DmIpcUtils::ConvertToPeerTargetIdExtWrapper(targetId); + 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); - std::vector processInfos = ipcServerListener_.GetAllProcessInfo(); + std::vector processInfos = ipcServerStub_->GetAllProcessInfo(); ProcessInfo processInfoTemp; for (auto item : processInfos) { if (item.pkgName == processInfo.pkgName) { @@ -679,17 +667,20 @@ 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfoTemp); + 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 {}; @@ -717,6 +708,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 {}; @@ -727,8 +720,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()) { @@ -749,7 +742,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; } @@ -762,10 +755,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; @@ -777,8 +768,16 @@ 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; + } + auto dmDeviceBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(deviceBasicInfo); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(info); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(it); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, notifyState, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -786,11 +785,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_); @@ -807,8 +804,16 @@ 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; + } + auto dmDeviceBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(deviceBasicInfo); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(info); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(it); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } { std::lock_guard autoLock(alreadyNotifyPkgNameLock_); @@ -820,13 +825,19 @@ 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; + } + auto dmDeviceBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(deviceBasicInfo); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(info); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(it); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -834,10 +845,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; @@ -849,9 +858,17 @@ 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); + auto dmDeviceBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(deviceBasicInfo); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(info); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(it); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -859,11 +876,10 @@ 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); @@ -875,8 +891,16 @@ 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; + } + auto dmDeviceBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(deviceBasicInfo); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(info); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(it); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } else { std::string notifyPkgName = processInfo.pkgName + "#" + std::to_string(processInfo.userId) + "#" + @@ -889,8 +913,16 @@ 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; + } + auto dmDeviceBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(deviceBasicInfo); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(info); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, state, dmDeviceInfoExt, + dmDeviceBasicInfoExt, processInfoExt); } } @@ -910,6 +942,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); @@ -920,12 +954,18 @@ 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); + auto dmDeviceInfoExt = DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(item); + auto dmDeviceBasicInfoExt = DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(deviceBasicInfo); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + deviceManagerIpc->ServerDeviceStateNotify(processInfoExt.pkgName, DmDeviceState::DEVICE_STATE_ONLINE, + dmDeviceInfoExt, dmDeviceBasicInfoExt, processInfoExt); } } @@ -953,12 +993,15 @@ 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); + 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + auto deviceProfileInfosExt = DmIpcUtils::ConvertToDmDeviceProfileInfoExtWrapper(deviceProfileInfos); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) std::string userDefinedDeviceName = DeviceNameManager::GetInstance().GetUserDefinedDeviceName(); if (code == DM_OK && !userDefinedDeviceName.empty()) { @@ -969,36 +1012,31 @@ void DeviceManagerServiceListener::OnGetDeviceProfileInfoListResult(const Proces break; } } - pReq->SetDeviceProfileInfoList(temVec); + auto deviceProfileInfosExt = DmIpcUtils::ConvertToDmDeviceProfileInfoExtWrapper(deviceProfileInfos); } #endif - pReq->SetResult(code); - pReq->SetProcessInfo(processInfo); - ipcServerListener_.SendRequest(GET_DEVICE_PROFILE_INFO_LIST_RESULT, pReq, pRsp); + deviceManagerIpc->GetDeviceProfileInfoListResult(processInfoExt.pkgName, code, + 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; + } + auto deviceIconInfoExt = DmIpcUtils::ConvertToDmDeviceIconInfoExtWrapper(dmDeviceIconInfo); + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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); @@ -1006,21 +1044,26 @@ 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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; + } + auto processInfoExt = DmIpcUtils::ConvertToProcessInfoExtWrapper(processInfo); + 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..99d28631fa38616bf6e6e0e3ac9348c8693d9aed 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,9 @@ 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)); if (callback == nullptr) { LOGE("create ipc server client proxy failed."); CancelXcollieTimer(timerId); @@ -784,36 +568,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 +822,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 +863,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 +889,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 +957,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 +1004,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 +1053,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 +1086,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 +1169,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 +1182,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 a971dd983848abdd1948a9a7f4b2eb46528979a0..2aa3a173d661ccd2f47b85e4c907dbf85724af58 100644 --- a/services/service/src/ipc/standard/ipc_server_stub.cpp +++ b/services/service/src/ipc/standard/ipc_server_stub.cpp @@ -295,7 +295,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."); @@ -383,7 +384,7 @@ std::vector IpcServerStub::GetAllProcessInfo() 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."); diff --git a/test/commonfuzztest/authacl_fuzzer/BUILD.gn b/test/commonfuzztest/authacl_fuzzer/BUILD.gn index 6800b459d3b2c731b2f82380c8e4cb6794888e23..b417b6e502130e467194c4cafe6b7529cfbf4f94 100644 --- a/test/commonfuzztest/authacl_fuzzer/BUILD.gn +++ b/test/commonfuzztest/authacl_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("AuthAclFuzzTest") { "${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/commonfuzztest/authcredential_fuzzer/BUILD.gn b/test/commonfuzztest/authcredential_fuzzer/BUILD.gn index 95b5069e4f0c78ddbbcb2657e40271225c833b1d..369b4616dda7b4ef9393d0a3d267df8b67d360b5 100644 --- a/test/commonfuzztest/authcredential_fuzzer/BUILD.gn +++ b/test/commonfuzztest/authcredential_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("AuthCredentialFuzzTest") { "${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/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/dmauthmanager_fuzzer/BUILD.gn b/test/commonfuzztest/dmauthmanager_fuzzer/BUILD.gn index 1d394b8ad08031b12cdae65d7a128a8067ab2620..35c9303cc6759dab037758b5ffdc85a9bfe4e250 100644 --- a/test/commonfuzztest/dmauthmanager_fuzzer/BUILD.gn +++ b/test/commonfuzztest/dmauthmanager_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("DmAuthManagerFuzzTest") { "${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/commonfuzztest/dmauthmanagerv2_fuzzer/BUILD.gn b/test/commonfuzztest/dmauthmanagerv2_fuzzer/BUILD.gn index fb2de39cab0aa6a70aefea49cc690e3e5d00b8f4..a831ec97ffe54659f8418eb01010209346005aa7 100644 --- a/test/commonfuzztest/dmauthmanagerv2_fuzzer/BUILD.gn +++ b/test/commonfuzztest/dmauthmanagerv2_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("DmAuthManagerV2FuzzTest") { "${services_path}:devicemanagerservice", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutils", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ 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/dmfreezeprocess_fuzzer/BUILD.gn b/test/commonfuzztest/dmfreezeprocess_fuzzer/BUILD.gn index 01ef24d272ca6803d48870076ae9785cf7196113..35a801dc1b00c6462c7437976a00d697512f9e0f 100644 --- a/test/commonfuzztest/dmfreezeprocess_fuzzer/BUILD.gn +++ b/test/commonfuzztest/dmfreezeprocess_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("DmFreezeProcessFuzzTest") { "${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/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn b/test/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn index 1ce9887cd4b0e4ace91da4fa32475a623b8540a2..3fc6b59068a3c9f5d3555ebddef900983f874868 100644 --- a/test/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn +++ b/test/commonfuzztest/dmnegotiateprocess_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("DmNegotiateProcessFuzzTest") { "${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/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/commonfuzztest/ondatareceived_fuzzer/BUILD.gn b/test/commonfuzztest/ondatareceived_fuzzer/BUILD.gn index dd80157794d06d5c381710448d812a825de7e44f..377d25ce0f5158f9e6c0d03f8673600951158500 100644 --- a/test/commonfuzztest/ondatareceived_fuzzer/BUILD.gn +++ b/test/commonfuzztest/ondatareceived_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("OnDataReceivedFuzzTest") { "${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/commonfuzztest/ondatareceivedv2_fuzzer/BUILD.gn b/test/commonfuzztest/ondatareceivedv2_fuzzer/BUILD.gn index b81e1b47298dfc17c2d5288fd1d947d192304f19..8b01474d955f36a3f2c6134ca7a23f8061cd6b25 100644 --- a/test/commonfuzztest/ondatareceivedv2_fuzzer/BUILD.gn +++ b/test/commonfuzztest/ondatareceivedv2_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("OnDataReceivedV2FuzzTest") { "${services_path}:devicemanagerservice", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutils", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ diff --git a/test/commonfuzztest/onerror_fuzzer/BUILD.gn b/test/commonfuzztest/onerror_fuzzer/BUILD.gn index 9d9d2801dca8be36635b71501fe25472f0f6f4bb..bafffdeb031fd80d9ba11e65edb1d8fb27190ad2 100644 --- a/test/commonfuzztest/onerror_fuzzer/BUILD.gn +++ b/test/commonfuzztest/onerror_fuzzer/BUILD.gn @@ -47,6 +47,7 @@ ohos_fuzztest("OnErrorFuzzTest") { "${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/commonfuzztest/onfinish_fuzzer/BUILD.gn b/test/commonfuzztest/onfinish_fuzzer/BUILD.gn index 3881335e7ec7603209f9d3df225a0bfac04a99fc..244c9b89c80a78a6858d6d15895309e0471df258 100644 --- a/test/commonfuzztest/onfinish_fuzzer/BUILD.gn +++ b/test/commonfuzztest/onfinish_fuzzer/BUILD.gn @@ -47,6 +47,7 @@ ohos_fuzztest("OnFinishFuzzTest") { "${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/commonfuzztest/onrequest_fuzzer/BUILD.gn b/test/commonfuzztest/onrequest_fuzzer/BUILD.gn index 34a301d7aee7e05919d7e95f7b072e3580581445..c58b04daac4f7265d3998c9b70c9c48d37844917 100644 --- a/test/commonfuzztest/onrequest_fuzzer/BUILD.gn +++ b/test/commonfuzztest/onrequest_fuzzer/BUILD.gn @@ -48,6 +48,7 @@ ohos_fuzztest("OnRequestFuzzTest") { "${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/commonfuzztest/pinauth_fuzzer/BUILD.gn b/test/commonfuzztest/pinauth_fuzzer/BUILD.gn index f8ad7083e43ef54d023c3130781729ff1d6b5590..1fcae814b0651ae988883cabd3b66fe4549adf1a 100644 --- a/test/commonfuzztest/pinauth_fuzzer/BUILD.gn +++ b/test/commonfuzztest/pinauth_fuzzer/BUILD.gn @@ -68,6 +68,7 @@ ohos_fuzztest("PinAuthFuzzTest") { "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn b/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn index c24e87558f6367d5ebbbef8f4e7c2186e85bf5c1..733b36eb23a43b81b8c2a030d9e86ed58b42aa20 100644 --- a/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn +++ b/test/commonfuzztest/pinauthui_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("PinAuthUiFuzzTest") { "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] defines = [ diff --git a/test/commonfuzztest/pinholder_fuzzer/BUILD.gn b/test/commonfuzztest/pinholder_fuzzer/BUILD.gn index c673b1edcd1b2c3452c73ea9dcc7cade5a785a17..d0947247c3aa000a7ecb9f7cdf95dbc06290f76c 100644 --- a/test/commonfuzztest/pinholder_fuzzer/BUILD.gn +++ b/test/commonfuzztest/pinholder_fuzzer/BUILD.gn @@ -69,6 +69,7 @@ ohos_fuzztest("PinHolderFuzzTest") { "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutilstest", + "${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..d0687570cad926bc22fbbf640eb9a02e435787ac 100644 --- a/test/servicesfuzztest/authconfirm_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/authconfirm_fuzzer/BUILD.gn @@ -45,6 +45,7 @@ ohos_fuzztest("AuthConfirmFuzzTest") { "${json_path}:devicemanagerjson", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ @@ -58,6 +59,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..3a552d88acf1f02c3e3bfbebe57b76cbb3268c36 100644 --- a/test/servicesfuzztest/authmanager_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/authmanager_fuzzer/BUILD.gn @@ -45,6 +45,7 @@ ohos_fuzztest("AuthManagerFuzzTest") { "${json_path}:devicemanagerjson", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ @@ -58,6 +59,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..a51fe6ead8f58a66b3fc1cf61f749963a1b03d6e 100644 --- a/test/servicesfuzztest/authmessageprocessor_fuzzer/BUILD.gn +++ b/test/servicesfuzztest/authmessageprocessor_fuzzer/BUILD.gn @@ -45,6 +45,7 @@ ohos_fuzztest("AuthMessageProcessorFuzzTest") { "${json_path}:devicemanagerjson", "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ @@ -58,6 +59,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/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..cc972847e8a12a47375c0de335588ba9f3dfa845 100644 --- a/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onbytesreceived_fuzzer/BUILD.gn @@ -55,6 +55,7 @@ ohos_fuzztest("OnBytesReceivedFuzzTest") { "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ @@ -62,6 +63,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..998e4c174f17985dd775d833be35286dc7ea1405 100644 --- a/test/softbusfuzztest/softbussessionobject_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/softbussessionobject_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("SoftbusSessionObjectFuzzTest") { "${services_path}:devicemanagerservicetest", "${servicesimpl_path}:devicemanagerserviceimpl", "${utils_path}:devicemanagerutilstest", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", ] external_deps = [ @@ -57,6 +58,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..5b7c2cb944c6d9784bbea080d3c17e055c897a1d 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -37,7 +37,6 @@ 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", @@ -83,8 +82,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", @@ -117,7 +114,10 @@ ohos_unittest("UTTest_pin_auth") { sources = [ "${devicemanager_path}/test/commonunittest/UTTest_pin_auth.cpp" ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "data_share:datashare_common", @@ -129,6 +129,7 @@ ohos_unittest("UTTest_pin_auth") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -146,7 +147,10 @@ ohos_unittest("UTTest_pin_auth_ui") { sources = [ "${devicemanager_path}/test/commonunittest/UTTest_pin_auth_ui.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", @@ -156,6 +160,7 @@ ohos_unittest("UTTest_pin_auth_ui") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -182,6 +187,7 @@ ohos_unittest("UTTest_ipc_cmd_parser_client") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] cflags = [ @@ -215,8 +221,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 +254,7 @@ ohos_unittest("UTTest_ipc_cmd_register") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -337,6 +344,7 @@ ohos_unittest("UTTest_dm_pin_holder") { "googletest:gmock", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -353,6 +361,7 @@ ohos_unittest("UTTest_ipc_get_device_info_rsp") { external_deps = [ "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -372,6 +381,7 @@ ohos_unittest("UTTest_dm_common_event_manager") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -389,6 +399,7 @@ ohos_unittest("device_manager_impl_test") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -411,7 +422,10 @@ ohos_unittest("UTTest_dm_credential_manager") { sources = [ "${devicemanager_path}/test/commonunittest/UTTest_dm_credential_manager.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", @@ -424,6 +438,7 @@ ohos_unittest("UTTest_dm_credential_manager") { "googletest:gmock", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -448,7 +463,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 +483,7 @@ ohos_unittest("UTTest_device_manager_service") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -476,7 +495,10 @@ ohos_unittest("UTTest_dm_softbus_cache") { sources = [ "UTTest_dm_softbus_cache.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", @@ -492,6 +514,7 @@ ohos_unittest("UTTest_dm_softbus_cache") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -509,7 +532,10 @@ ohos_unittest("UTTest_device_manager_service_three") { "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", @@ -525,6 +551,7 @@ ohos_unittest("UTTest_device_manager_service_three") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -549,6 +576,7 @@ ohos_unittest("UTTest_device_manager_service_notify") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -571,6 +599,7 @@ ohos_unittest("UTTest_hichain_auth_connector") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -596,6 +625,7 @@ ohos_unittest("UTTest_hichain_connector") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -618,6 +648,7 @@ ohos_unittest("UTTest_mine_hichain_connector") { "dsoftbus:softbus_client", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -654,6 +685,7 @@ ohos_unittest("UTTest_mine_softbus_listener") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "openssl:libcrypto_shared", + "safwk:system_ability_fwk", ] } @@ -686,6 +718,7 @@ ohos_unittest("UTTest_softbus_connector") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "os_account:libaccountkits", + "safwk:system_ability_fwk", ] } @@ -724,6 +757,7 @@ ohos_unittest("UTTest_softbus_listener") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -756,6 +790,7 @@ ohos_unittest("UTTest_softbus_listener_two") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -775,7 +810,10 @@ ohos_unittest("UTTest_softbus_publish") { "${devicemanager_path}/test/unittest/mock/parameter.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", @@ -787,6 +825,7 @@ ohos_unittest("UTTest_softbus_publish") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -802,7 +841,10 @@ ohos_unittest("UTTest_softbus_session") { "${devicemanager_path}/test/softbusunittest/UTTest_softbus_session.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", @@ -814,6 +856,7 @@ ohos_unittest("UTTest_softbus_session") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -831,6 +874,7 @@ ohos_unittest("UTTest_dm_adapter_manager") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -854,6 +898,7 @@ ohos_unittest("UTTest_dm_anonymous") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -874,6 +919,7 @@ ohos_unittest("UTTest_dm_timer") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -892,6 +938,7 @@ ohos_unittest("UTTest_dm_transport") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -909,6 +956,7 @@ ohos_unittest("UTTest_dm_transport_msg") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -925,6 +973,7 @@ ohos_unittest("UTTest_dm_service_load") { external_deps = [ "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -943,6 +992,7 @@ ohos_unittest("UTTest_ipc_client_manager") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -960,6 +1010,7 @@ ohos_unittest("UTTest_ipc_client_proxy") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -981,6 +1032,7 @@ ohos_unittest("UTTest_ipc_client_stub") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -995,7 +1047,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", @@ -1086,6 +1141,7 @@ ohos_unittest("UTTest_device_manager_impl") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] cflags = [ @@ -1105,7 +1161,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 +1176,7 @@ ohos_unittest("UTTest_dm_import_auth_code") { "googletest:gmock", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -1141,6 +1201,7 @@ ohos_unittest("UTTest_multiple_user_connector") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -1170,6 +1231,7 @@ ohos_unittest("UTTest_permission_manager") { "googletest:gmock_main", "hilog:libhilog", "selinux_adapter:librestorecon", + "safwk:system_ability_fwk", ] } @@ -1229,6 +1291,7 @@ ohos_unittest("UTTest_device_manager_notify") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1246,6 +1309,7 @@ ohos_unittest("UTTest_ipc_client_server_proxy") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1259,7 +1323,10 @@ ohos_unittest("UTTest_dm_device_state_manager") { sources = [ "${devicemanager_path}/test/commonunittest/UTTest_dm_device_state_manager.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", @@ -1271,6 +1338,7 @@ ohos_unittest("UTTest_dm_device_state_manager") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1288,7 +1356,10 @@ ohos_unittest("UTTest_dm_device_state_manager_two") { "mock/softbus_connector_mock.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", @@ -1300,6 +1371,7 @@ ohos_unittest("UTTest_dm_device_state_manager_two") { "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1320,6 +1392,7 @@ ohos_unittest("UTTest_dm_dfx") { "googletest:gmock", "hilog:libhilog", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1338,7 +1411,10 @@ ohos_unittest("UTTest_device_manager_service_impl") { "mock/softbus_connector_mock.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", @@ -1352,6 +1428,7 @@ ohos_unittest("UTTest_device_manager_service_impl") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -1368,7 +1445,10 @@ ohos_unittest("UTTest_device_manager_service_impl_first") { "mock/multiple_user_connector_mock.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", @@ -1382,6 +1462,7 @@ ohos_unittest("UTTest_device_manager_service_impl_first") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -1400,7 +1481,10 @@ ohos_unittest("UTTest_device_manager_service_listener") { "mock/kv_adapter_manager_mock.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", @@ -1408,9 +1492,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 +1522,7 @@ ohos_unittest("UTTest_auth_message_processor") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1447,7 +1534,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 +1547,7 @@ ohos_unittest("UTTest_auth_response_state") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1468,7 +1559,10 @@ ohos_unittest("UTTest_auth_request_state") { sources = [ "UTTest_auth_request_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", @@ -1478,6 +1572,7 @@ ohos_unittest("UTTest_auth_request_state") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1495,6 +1590,7 @@ ohos_unittest("ipc_client_manager_test") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1529,6 +1625,7 @@ ohos_unittest("UTTest_dm_auth_manager_first") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] cflags = [ @@ -1571,6 +1668,7 @@ ohos_unittest("UTTest_dm_auth_manager_second") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1595,6 +1693,7 @@ ohos_unittest("UTTest_dm_auth_manager_third") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] cflags = [ @@ -1629,6 +1728,7 @@ ohos_unittest("UTTest_dm_radar_helper_test") { "device_auth:deviceauth_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1654,6 +1754,7 @@ ohos_unittest("UTTest_discovery_filter") { "device_info_manager:distributed_device_profile_sdk", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1669,7 +1770,10 @@ ohos_unittest("UTTest_discovery_manager") { "${devicemanager_path}/test/commonunittest/UTTest_discovery_manager.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", @@ -1681,6 +1785,7 @@ ohos_unittest("UTTest_discovery_manager") { "googletest:gmock", "hilog:libhilog", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1703,7 +1808,10 @@ ohos_unittest("UTTest_dm_deviceprofile_connector") { "${devicemanager_path}/test/unittest/mock/multiple_user_connector_mock.cpp", ] - deps = [ ":device_manager_test_common" ] + deps = [ + ":device_manager_test_common", + "${devicemanager_path}/interfaces/inner_kits/native_cpp:device_manager_ipc", + ] external_deps = [ "device_info_manager:distributed_device_profile_common", @@ -1712,6 +1820,7 @@ ohos_unittest("UTTest_dm_deviceprofile_connector") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1741,6 +1850,7 @@ ohos_unittest("UTTest_dm_deviceprofile_connector_second") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1765,6 +1875,7 @@ ohos_unittest("UTTest_dm_distributed_hardware_load") { "googletest:gmock", "hilog:libhilog", "hitrace:hitrace_meter", + "safwk:system_ability_fwk", ] } @@ -1788,6 +1899,7 @@ ohos_unittest("UTTest_dm_comm_tool") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1806,6 +1918,7 @@ ohos_unittest("UTTest_dm_crypto") { external_deps = [ "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1823,7 +1936,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 +1960,7 @@ ohos_unittest("UTTest_dm_publish_common_event") { "bluetooth:btframework", "hilog:libhilog", "wifi:wifi_sdk", + "safwk:system_ability_fwk", ] } @@ -1865,6 +1982,7 @@ ohos_unittest("UTTest_dm_screen_common_event") { "bluetooth:btframework", "hilog:libhilog", "wifi:wifi_sdk", + "safwk:system_ability_fwk", ] } @@ -1885,6 +2003,7 @@ ohos_unittest("UTTest_relationship_sync_mgr") { "cJSON:cjson", "ffrt:libffrt", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1901,7 +2020,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 +2057,7 @@ ohos_unittest("UTTest_dp_inited_callback") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1961,6 +2084,7 @@ ohos_unittest("UTTest_kv_adapter_manager") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -1995,6 +2119,7 @@ ohos_unittest("UTTest_app_manager") { "hilog:libhilog", "os_account:libaccountkits", "os_account:os_account_innerkits", + "safwk:system_ability_fwk", ] } @@ -2013,7 +2138,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 +2173,7 @@ ohos_unittest("UTTest_device_name_manager") { "hilog:libhilog", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "safwk:system_ability_fwk", ] } @@ -2075,6 +2204,7 @@ ohos_unittest("UTTest_advertise_manager") { "ffrt:libffrt", "googletest:gmock", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2092,6 +2222,7 @@ ohos_unittest("UTTest_mini_tools_kit") { "ffrt:libffrt", "googletest:gmock", "googletest:gmock_main", + "safwk:system_ability_fwk", ] } @@ -2110,6 +2241,7 @@ ohos_unittest("UTTest_json_object") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2128,7 +2260,10 @@ ohos_unittest("UTTest_auth_pin_auth_state") { "${devicemanager_path}/test/unittest/mock/hichain_auth_connector_mock.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", @@ -2139,6 +2274,7 @@ ohos_unittest("UTTest_auth_pin_auth_state") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2166,6 +2302,7 @@ ohos_unittest("UTTest_dm_auth_message_processor") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2186,7 +2323,10 @@ ohos_unittest("UTTest_auth_credential_state") { "${devicemanager_path}/test/unittest/mock/softbus_session_mock.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", @@ -2197,6 +2337,7 @@ ohos_unittest("UTTest_auth_credential_state") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2217,7 +2358,10 @@ ohos_unittest("UTTest_auth_acl") { "${devicemanager_path}/test/unittest/mock/softbus_session_mock.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", @@ -2228,6 +2372,7 @@ ohos_unittest("UTTest_auth_acl") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2248,7 +2393,10 @@ ohos_unittest("UTTest_auth_negotiate") { "${devicemanager_path}/test/unittest/mock/distributed_device_profile_client_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", @@ -2262,6 +2410,7 @@ ohos_unittest("UTTest_auth_negotiate") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2279,7 +2428,10 @@ ohos_unittest("UTTest_auth_manager") { "${devicemanager_path}/test/unittest/mock/distributed_device_profile_client_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", @@ -2293,6 +2445,7 @@ ohos_unittest("UTTest_auth_manager") { "googletest:gmock", "googletest:gmock_main", "hilog:libhilog", + "safwk:system_ability_fwk", ] } @@ -2311,7 +2464,10 @@ ohos_unittest("UTTest_auth_confirm") { "${devicemanager_path}/test/unittest/mock/hichain_auth_connector_mock.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", @@ -2322,6 +2478,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 ff761bb5399e6cb47271deaaf5f4f7e0d605c6eb..1303a873b301611391f39c31c4aab7ca4e1825a0 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_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index 24d55d29e826e812c80faf9f35727a0b528820a0..f5e1efe24c467b90adac6b1437633d1ee86b5c3b 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -119,31 +119,6 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0) ASSERT_NE(ret, ERR_DM_FAILED); } -/** - * @tc.name: Init_001 - * @tc.desc: 1. new a listener - * 2. set a pkgName not null - * 3. add listener and pkgName in dmListener_ Map - * 4. call Init with pkgName - * 5. check ret is not ERR_DM_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, Init_001, testing::ext::TestSize.Level0) -{ - // 1. new a listener - sptr listener = sptr(new IpcClientStub()); - // 2. set a pkgName not null - std::string pkgName = "com.ohos.test"; - std::shared_ptr instance = std::make_shared(); - // 3. add listener and pkgName in dmListener_ Map - instance->dmListener_[pkgName] = listener; - // 4. call Init with pkgName - int32_t ret = instance->Init(pkgName); - // 5. check ret is not ERR_DM_FAILED - ASSERT_NE(ret, ERR_DM_FAILED); -} - /** * @tc.name: Init_002 * @tc.desc: 1. set pkcName not null @@ -270,134 +245,6 @@ HWTEST_F(IpcClientManagerTest, UnInit1, testing::ext::TestSize.Level0) ASSERT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); } -/** - * @tc.name: UnInit_002 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call UnInit with pkgName - * 6. check ret is ERR_DM_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, UnInit_002, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); - // 3. set IpcClientManager dmInterface_ not null - std::shared_ptr instance = std::make_shared(); - instance->dmInterface_ = mockInstance; - // 4. set IpcClientManager dmListener_ not null - sptr listener = sptr(new IpcClientStub()); - instance->dmListener_[pkgName] = listener; - // 5. call UnInit with pkgName - int32_t ret = instance->UnInit(pkgName); - // 6. check ret is ERR_DM_FAILED - ASSERT_EQ(ret, ERR_DM_FAILED); -} - -/** - * @tc.name: UnInit_003 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_OK - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call UnInit with pkgName - * 6. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, UnInit_003, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return DM_OK - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_OK)); - // 3. set IpcClientManager dmInterface_ not null - std::shared_ptr instance = std::make_shared(); - instance->dmInterface_ = mockInstance; - // 4. set IpcClientManager dmListener_ not null - sptr listener = sptr(new IpcClientStub()); - instance->dmListener_[pkgName] = listener; - // 5. call UnInit with pkgName - int32_t ret = instance->UnInit(pkgName); - // 6. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: UnInit_004 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_INIT_FAILED - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call UnInit with pkgName - * 6. check ret is ERR_DM_INIT_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, UnInit_004, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_INIT_FAILED - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); - // 3. set IpcClientManager dmInterface_ not null - std::shared_ptr instance = std::make_shared(); - instance->dmInterface_ = mockInstance; - // 4. set IpcClientManager dmListener_ not null - sptr listener = sptr(new IpcClientStub()); - instance->dmListener_[pkgName] = listener; - // 5. call UnInit with pkgName - int32_t ret = instance->UnInit(pkgName); - // 6. check ret is ERR_DM_INIT_FAILED - ASSERT_EQ(ret, ERR_DM_INIT_FAILED); -} - -/** - * @tc.name: UnInit_005 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC_SEND_REQUEST_FAILED - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call UnInit with pkgName - * 6. check ret is ERR_DM_IPC_SEND_REQUEST_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, UnInit_005, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC_SEND_REQUEST_FAILED - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(ERR_DM_IPC_SEND_REQUEST_FAILED)); - // 3. set IpcClientManager dmInterface_ not null - std::shared_ptr instance = std::make_shared(); - instance->dmInterface_ = mockInstance; - // 4. set IpcClientManager dmListener_ not null - sptr listener = sptr(new IpcClientStub()); - instance->dmListener_[pkgName] = listener; - // 5. call UnInit with pkgName - int32_t ret = instance->UnInit(pkgName); - // 6. check ret is ERR_DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST_FAILED); -} - /** * @tc.name: SendRequest_001 * @tc.desc: 1. set pkgName null @@ -423,146 +270,6 @@ HWTEST_F(IpcClientManagerTest, SendRequest_001, testing::ext::TestSize.Level0) ASSERT_EQ(ret, ERR_DM_INIT_FAILED); } -/** - * @tc.name: SendRequest_002 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call SendRequest with parameter - * 6. check ret is ERR_DM_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, SendRequest_002, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_FAILED - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(ERR_DM_FAILED)); - std::shared_ptr instance = std::make_shared(); - // 3. set IpcClientManager dmInterface_ not null - instance->dmInterface_ = mockInstance; - sptr listener = sptr(new IpcClientStub()); - // 4. set IpcClientManager dmListener_ not null - instance->dmListener_[pkgName] = listener; - // 5. call SendRequest with parameter - int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is ERR_DM_FAILED - ASSERT_EQ(ret, ERR_DM_FAILED); -} - -/** - * @tc.name: SendRequest_003 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return DM_OK - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call SendRequest with parameter - * 6. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, SendRequest_003, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return DM_OK - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(DM_OK)); - std::shared_ptr instance = std::make_shared(); - // 3. set IpcClientManager dmInterface_ not null - instance->dmInterface_ = mockInstance; - sptr listener = sptr(new IpcClientStub()); - // 4. set IpcClientManager dmListener_ not null - instance->dmListener_[pkgName] = listener; - // 5. call SendRequest with parameter - int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: SendRequest_004 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_INIT_FAILED - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call SendRequest with parameter - * 6. check ret is ERR_DM_INIT_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, SendRequest_004, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_INIT_FAILED - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(ERR_DM_INIT_FAILED)); - std::shared_ptr instance = std::make_shared(); - // 3. set IpcClientManager dmInterface_ not null - instance->dmInterface_ = mockInstance; - sptr listener = sptr(new IpcClientStub()); - // 4. set IpcClientManager dmListener_ not null - instance->dmListener_[pkgName] = listener; - // 5. call SendRequest with parameter - int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is ERR_DM_INIT_FAILED - ASSERT_EQ(ret, ERR_DM_INIT_FAILED); -} - -/** - * @tc.name: SendRequest_005 - * @tc.desc: 1. set pkgName not null - * 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC_SEND_REQUEST_FAILED - * 3. set IpcClientManager dmInterface_ not null - * 4. set IpcClientManager dmListener_ not null - * 5. call SendRequest with parameter - * 6. check ret is ERR_DM_IPC_SEND_REQUEST_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientManagerTest, SendRequest_005, testing::ext::TestSize.Level0) -{ - // 1. set pkgName not null - std::string pkgName = "com.ohos.test"; - std::shared_ptr req = std::make_shared(); - std::shared_ptr rsp = std::make_shared(); - req->SetPkgName(pkgName); - // 2. Mock IpcClientServerProxy SendCmd return ERR_DM_IPC_SEND_REQUEST_FAILED - sptr remoteObject = nullptr; - auto mockInstance = new MockIpcClientManager(remoteObject); - EXPECT_CALL(*mockInstance, SendCmd(testing::_, testing::_, testing::_)) - .Times(1).WillOnce(testing::Return(ERR_DM_IPC_SEND_REQUEST_FAILED)); - std::shared_ptr instance = std::make_shared(); - // 3. set IpcClientManager dmInterface_ not null - instance->dmInterface_ = mockInstance; - sptr listener = sptr(new IpcClientStub()); - // 4. set IpcClientManager dmListener_ not null - instance->dmListener_[pkgName] = listener; - // 5. call SendRequest with parameter - int ret = instance->SendRequest(0, req, rsp); - // 6. check ret is ERR_DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, ERR_DM_IPC_SEND_REQUEST_FAILED); -} - /** * @tc.name: SendRequest_006 * @tc.type: FUNC diff --git a/test/unittest/UTTest_ipc_client_stub.cpp b/test/unittest/UTTest_ipc_client_stub.cpp index 07492955556e7d090df2e1fb7a522473cf16fabd..fa8433b68f4373548f3413366aa79e2e994fecf2 100644 --- a/test/unittest/UTTest_ipc_client_stub.cpp +++ b/test/unittest/UTTest_ipc_client_stub.cpp @@ -93,34 +93,6 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_001, testing::ext::TestSize.Level0) ASSERT_EQ(result, ERR_DM_FAILED); } -/** - * @tc.name: OnRemoteRequest_002 - * @tc.desc: 1. set MessageOption not null - * set MessageParcel not null - * set MessageParcel not null - * 2. set set code is SERVER_DEVICE_FA_NOTIFY - * 3. call IpcClientStub OnRemoteRequest with parameter - * 4. check result is ERR_DM_IPC_READ_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) -{ - // 1. set MessageOption not null - MessageOption option; - // set MessageParcel not null - MessageParcel data; - // set MessageParcel not null - MessageParcel reply; - // 2. set set code is SERVER_DEVICE_FA_NOTIFY - int code = SERVER_DEVICE_FA_NOTIFY; - sptr instance(new IpcClientStub()); - // 3. call IpcClientStub OnRemoteRequest with parameter - int ret = instance->OnRemoteRequest(code, data, reply, option); - // 4. check result is ERR_DM_IPC_READ_FAILED - ASSERT_EQ(ret, ERR_DM_IPC_READ_FAILED); -} - /** * @tc.name: OnRemoteRequest_003 * @tc.type: FUNC @@ -140,31 +112,6 @@ HWTEST_F(IpcClientStubTest, OnRemoteRequest_003, testing::ext::TestSize.Level0) ASSERT_EQ(ret, DM_OK); } -/** - * @tc.name: SendCmd_001 - * @tc.desc: 1. set set code is SERVER_DEVICE_FA_NOTIFY - * set req is nullptr - * set rsp is nullptr - * 2. call IpcClientStub SendCmd with parameter - * 3. check result is ERR_DM_IPC_SEND_REQUEST_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcClientStubTest, SendCmd_001, testing::ext::TestSize.Level0) -{ - // 1. set set code is SERVER_DEVICE_FA_NOTIFY - int cmdCode = SERVER_DEVICE_FA_NOTIFY; - // set req is nullptr - std::shared_ptr req = nullptr; - // set rsp is nullptr - std::shared_ptr rsp = nullptr; - sptr instance(new IpcClientStub()); - // 2. call IpcClientStub SendCmd with parameter - int ret = instance->SendCmd(cmdCode, req, rsp); - // 3. check result is ERR_DM_IPC_SEND_REQUEST_FAILED - ASSERT_EQ(ret, DM_OK); -} - /** * @tc.name: SendCmd_002 * @tc.type: FUNC diff --git a/test/unittest/UTTest_ipc_cmd_parser_client.cpp b/test/unittest/UTTest_ipc_cmd_parser_client.cpp index 58f9bd3eddc2a92ae28567b8ac8f3848b1fe3f2b..cac107e600fd9e9802ab4cf0f896f24061d2cf02 100644 --- a/test/unittest/UTTest_ipc_cmd_parser_client.cpp +++ b/test/unittest/UTTest_ipc_cmd_parser_client.cpp @@ -710,233 +710,6 @@ HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_034, testing::ext::TestSize.L ASSERT_EQ(DM_OK, ret); } -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_001, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_DISCOVERY; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - int16_t subscribeId = 100; - std::string deviceId = "xxx"; - data.WriteString(pkgName); - data.WriteInt16(subscribeId); - DmDeviceBasicInfo basicInfo; - data.WriteRawData(&basicInfo, sizeof(DmDeviceBasicInfo)); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_002, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = BIND_TARGET_RESULT; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - PeerTargetId targetId; - int32_t result = 1; - int32_t status = 1; - std::string content = "XX"; - data.WriteString(pkgName); - EncodePeerTargetId(targetId, data); - data.WriteInt32(result); - data.WriteInt32(status); - data.WriteString(content); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_003, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = UNBIND_TARGET_RESULT; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - PeerTargetId targetId; - int32_t result = 1; - std::string content = "XX"; - data.WriteString(pkgName); - EncodePeerTargetId(targetId, data); - data.WriteInt32(result); - data.WriteString(content); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_004, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - std::string deviceId = "xxx"; - int32_t pinType = 1; - std::string payload = "xx"; - data.WriteString(pkgName); - data.WriteString(deviceId); - data.WriteInt32(pinType); - data.WriteString(payload); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_005, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - int32_t pinType = 1; - std::string payload = "xx"; - data.WriteString(pkgName); - data.WriteInt32(pinType); - data.WriteString(payload); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_006, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - int32_t result = 1; - data.WriteString(pkgName); - data.WriteInt32(result); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_007, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - int32_t result = 1; - data.WriteString(pkgName); - data.WriteInt32(result); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_008, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_ON_PIN_HOLDER_EVENT; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - int32_t result = 1; - std::string content = "xxx"; - int32_t pinHolderEvent = 1; - data.WriteString(pkgName); - data.WriteInt32(result); - data.WriteInt32(pinHolderEvent); - data.WriteString(content); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_009, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = REMOTE_DEVICE_TRUST_CHANGE; - int32_t ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - MessageParcel data; - MessageParcel reply; - std::string pkgName = "ohos.dm.test"; - std::string deviceId = "xxx"; - int32_t authForm = 1; - data.WriteString(pkgName); - data.WriteString(deviceId); - data.WriteInt32(authForm); - OnIpcCmdFunc ptr = GetIpcCmdFunc(cmdCode); - if (ptr) { - ret = ptr(data, reply); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_010, testing::ext::TestSize.Level0) -{ - auto ptr = GetIpcCmdFunc(SERVER_DEVICE_STATE_NOTIFY); - ASSERT_TRUE(ptr != nullptr); - - MessageParcel reply; - MessageParcel data1; - data1.WriteString("com.ohos.test"); - data1.WriteInt32(DEVICE_INFO_READY); - size_t deviceSize = sizeof(DmDeviceInfo); - data1.WriteRawData(nullptr, deviceSize); - EXPECT_EQ(ptr(data1, reply), DM_OK); - - MessageParcel data2; - data2.WriteString("com.ohos.test"); - data2.WriteInt32(DEVICE_STATE_UNKNOWN); - EXPECT_EQ(ptr(data2, reply), DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_011, testing::ext::TestSize.Level0) -{ - auto ptr = GetIpcCmdFunc(SERVER_DEVICE_SCREEN_STATE_NOTIFY); - ASSERT_TRUE(ptr != nullptr); - - MessageParcel reply; - MessageParcel data; - EXPECT_EQ(ptr(data, reply), DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_012, testing::ext::TestSize.Level0) -{ - auto ptr = GetIpcCmdFunc(SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY); - ASSERT_TRUE(ptr != nullptr); - - MessageParcel reply; - MessageParcel data; - EXPECT_EQ(ptr(data, reply), DM_OK); -} - -HWTEST_F(IpcCmdParserClientTest, OnIpcCmdFunc_013, testing::ext::TestSize.Level0) -{ - auto ptr = GetIpcCmdFunc(SINK_BIND_TARGET_RESULT); - ASSERT_TRUE(ptr != nullptr); - - MessageParcel reply; - MessageParcel data; - EXPECT_EQ(ptr(data, reply), DM_OK); -} - HWTEST_F(IpcCmdParserClientTest, SetIpcRequestFunc_016, testing::ext::TestSize.Level0) { auto ptr = GetIpcRequestFunc(SERVER_GET_DMFA_INFO); diff --git a/test/unittest/UTTest_ipc_cmd_parser_service.cpp b/test/unittest/UTTest_ipc_cmd_parser_service.cpp index bdc61c11e5890333ed4de9bdca88d67065cb7adb..02fdfd8aca47f727467943204ebc50739d5d7be3 100644 --- a/test/unittest/UTTest_ipc_cmd_parser_service.cpp +++ b/test/unittest/UTTest_ipc_cmd_parser_service.cpp @@ -148,331 +148,6 @@ bool EncodePeerTargetId(const PeerTargetId &targetId, MessageParcel &parcel) return bRet; } -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_001, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_001, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_002, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_002, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FOUND; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_003, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FOUND; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_004, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FOUND; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_003, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_DISCOVERY; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_005, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_DISCOVERY; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_006, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_DISCOVERY; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_004, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DISCOVER_FINISH; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_007, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DISCOVER_FINISH; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_008, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DISCOVER_FINISH; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_005, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_PUBLISH_FINISH; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_009, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_PUBLISH_FINISH; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_010, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_PUBLISH_FINISH; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_006, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_AUTH_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_011, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_AUTH_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_012, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_AUTH_RESULT; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_007, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_013, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_014, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_008, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREDENTIAL_RESULT; - MessageParcel data; - std::shared_ptr req = nullptr; - int ret = ERR_DM_FAILED; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, ERR_DM_FAILED); - - req = std::make_shared(); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_015, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREDENTIAL_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_016, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREDENTIAL_RESULT; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_009, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = BIND_TARGET_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_017, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = BIND_TARGET_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_018, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = BIND_TARGET_RESULT; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_010, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = UNBIND_TARGET_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestIpcRequestFuncReqNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_019, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = UNBIND_TARGET_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_020, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = UNBIND_TARGET_RESULT; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_011, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER; - MessageParcel data; - std::shared_ptr req = nullptr; - int ret = ERR_DM_FAILED; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, ERR_DM_FAILED); - - req = std::make_shared(); - std::string pkgName = "com.ohos.test"; - req->SetPkgName(pkgName); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_021, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_022, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_012, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER; - MessageParcel data; - std::shared_ptr req = nullptr; - int ret = ERR_DM_FAILED; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, ERR_DM_FAILED); - - req = std::make_shared(); - std::string pkgName = "com.ohos.test"; - req->SetPkgName(pkgName); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_023, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_024, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_013, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT; - MessageParcel data; - std::shared_ptr req = nullptr; - int ret = ERR_DM_FAILED; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, ERR_DM_FAILED); - - req = std::make_shared(); - std::string pkgName = "com.ohos.test"; - req->SetPkgName(pkgName); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_025, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_026, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREATE_PIN_HOLDER_RESULT; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_014, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT; - MessageParcel data; - std::shared_ptr req = nullptr; - int ret = ERR_DM_FAILED; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, ERR_DM_FAILED); - - req = std::make_shared(); - std::string pkgName = "com.ohos.test"; - req->SetPkgName(pkgName); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_027, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_028, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DESTROY_PIN_HOLDER_RESULT; - ASSERT_EQ(TestReadResponseRspNotNull(cmdCode), DM_OK); -} - HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_001, testing::ext::TestSize.Level0) { int32_t cmdCode = BIND_DEVICE; @@ -1406,136 +1081,6 @@ HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_063, testing::ext::TestSize.Level EXPECT_EQ(cmdptr(data, reply), DM_OK); } -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_016, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_DISCOVERY; - MessageParcel data; - std::shared_ptr pReq = std::make_shared(); - std::string pkgName = "com.ohos.test"; - uint16_t subscribeId = 100; - DmDeviceBasicInfo deviceBasicInfo; - pReq->SetPkgName(pkgName); - pReq->SetSubscribeId(subscribeId); - pReq->SetDeviceBasicInfo(deviceBasicInfo); - int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(pReq, data); - } - ASSERT_EQ(DM_OK, ret); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_017, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_AUTH_RESULT; - MessageParcel data; - std::shared_ptr pReq = std::make_shared(); - std::string pkgName = "com.ohos.test"; - std::string deviceId = "112233445"; - std::string token = "134354656"; - int32_t status = 1; - int32_t reason = 1; - pReq->SetPkgName(pkgName); - pReq->SetDeviceId(deviceId); - pReq->SetToken(token); - pReq->SetStatus(status); - pReq->SetReason(reason); - int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(pReq, data); - } - ASSERT_EQ(DM_OK, ret); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_018, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY; - MessageParcel data; - std::shared_ptr pReq = std::make_shared(); - std::string pkgName = "com.ohos.test"; - std::string paramJson = "{}"; - pReq->SetPkgName(pkgName); - pReq->SetJsonParam(paramJson); - int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(pReq, data); - } - ASSERT_EQ(DM_OK, ret); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_019, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = BIND_TARGET_RESULT; - MessageParcel data; - std::shared_ptr pReq = std::make_shared(); - std::string pkgName = "com.ohos.test"; - PeerTargetId targetId; - int32_t result = 1; - int32_t status = 1; - std::string content = ""; - pReq->SetPkgName(pkgName); - pReq->SetPeerTargetId(targetId); - pReq->SetResult(result); - pReq->SetStatus(status); - pReq->SetContent(content); - int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(pReq, data); - } - ASSERT_EQ(DM_OK, ret); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_020, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = UNBIND_TARGET_RESULT; - MessageParcel data; - std::shared_ptr pReq = std::make_shared(); - std::string pkgName = "com.ohos.test"; - PeerTargetId targetId; - int32_t result = 1; - std::string content = ""; - pReq->SetPkgName(pkgName); - pReq->SetPeerTargetId(targetId); - pReq->SetResult(result); - pReq->SetContent(content); - int ret = ERR_DM_UNSUPPORTED_IPC_COMMAND; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(pReq, data); - } - ASSERT_EQ(DM_OK, ret); -} - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_021, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_ON_PIN_HOLDER_EVENT; - MessageParcel data; - std::shared_ptr req = nullptr; - int ret = ERR_DM_FAILED; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, ERR_DM_FAILED); - - req = std::make_shared(); - std::string pkgName = "com.ohos.test"; - req->SetPkgName(pkgName); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_029, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_ON_PIN_HOLDER_EVENT; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} - HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_055, testing::ext::TestSize.Level0) { int32_t cmdCode = CHECK_ACCESS_CONTROL; @@ -1562,39 +1107,6 @@ HWTEST_F(IpcCmdParserServiceTest, OnIpcCmdFunc_055, testing::ext::TestSize.Level } ASSERT_EQ(ret, DM_OK); } - -HWTEST_F(IpcCmdParserServiceTest, SetIpcRequestFunc_022, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY; - MessageParcel data; - std::shared_ptr req = nullptr; - int ret = ERR_DM_FAILED; - SetIpcRequestFunc ptr = GetIpcRequestFunc(cmdCode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, ERR_DM_FAILED); - - req = std::make_shared(); - std::string pkgName = "com.ohos.test"; - std::string deviceList = "test"; - uint16_t deviceTypeId = 0x00; - int32_t errcode = -1; - req->SetPkgName(pkgName); - req->SetDeviceList(deviceList); - req->SetDeviceTypeId(deviceTypeId); - req->SetErrCode(errcode); - if (ptr) { - ret = ptr(req, data); - } - ASSERT_EQ(ret, DM_OK); -} - -HWTEST_F(IpcCmdParserServiceTest, ReadResponseFunc_030, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVICE_CREDENTIAL_AUTH_STATUS_NOTIFY; - ASSERT_EQ(ERR_DM_FAILED, TestReadResponseRspNull(cmdCode)); -} } // namespace } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/UTTest_ipc_cmd_register.cpp b/test/unittest/UTTest_ipc_cmd_register.cpp index 912b90eeb69a50eed0aa11fa9725b5864299a7e9..fec2a1685ede9202fdd6391a23cc2e0d08fb0301 100644 --- a/test/unittest/UTTest_ipc_cmd_register.cpp +++ b/test/unittest/UTTest_ipc_cmd_register.cpp @@ -768,158 +768,6 @@ HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_001, testing::ext::TestSize.Level0) ASSERT_EQ(ret, ERR_DM_UNSUPPORTED_IPC_COMMAND); } -/** - * @tc.name: OnIpcCmd_002 - * @tc.desc: 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - * 2. data.WriteString(pkgname) - * data.WriteInt32(DEVICE_STATE_ONLINE) - * data.WriteRawData(&dmDeviceInfo, deviceSize) - * 3. call IpcCmdRegister OnIpcCmd with parameter - * 4. check ret is DM_OK - * check result is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_002, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - MessageParcel reply; - MessageParcel data; - // 2. data.WriteString(pkgname) - data.WriteString("com.ohos.test"); - // data.WriteInt32(DEVICE_STATE_ONLINE) - data.WriteInt32(DEVICE_STATE_ONLINE); - DmDeviceInfo dmDeviceInfo; - size_t deviceSize = sizeof(DmDeviceInfo); - // data.WriteRawData(&dmDeviceInfo, deviceSize) - data.WriteRawData(&dmDeviceInfo, deviceSize); - // 3. call IpcCmdRegister OnIpcCmd with parameter - int ret = 0; - ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - // check ret is DEVICEMANAGER_IPC_NOT_REGISTER_FUNC - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_003 - * @tc.desc: 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - * 2. data.WriteString(pkgname) - * data.WriteInt32(DEVICE_STATE_ONLINE) - * data.WriteRawData(nullptr, deviceSize) - * 3. call IpcCmdRegister OnIpcCmd with parameter - * 4. check ret is DEVICEMANAGER_OK - * check result is DEVICE_STATE_ONLINE - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_003, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - MessageParcel reply; - MessageParcel data; - // 2. data.WriteString(pkgname) - data.WriteString("com.ohos.test"); - // data.WriteInt32(DEVICE_STATE_ONLINE) - data.WriteInt32(DEVICE_STATE_ONLINE); - // data.WriteRawData(nullptr, deviceSize) - size_t deviceSize = sizeof(DmDeviceInfo); - data.WriteRawData(nullptr, deviceSize); - // 3. call IpcCmdRegister OnIpcCmd with parameter - int ret = 0; - int32_t result = 0; - ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - result = reply.ReadInt32(); - // 4. check result is DEVICE_STATE_ONLINE - ASSERT_EQ(result, DEVICE_STATE_ONLINE); - // check ret is DM_OK - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_004 - * @tc.desc: 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - * 2. data.WriteString(pkgname) - * data.WriteInt32(DEVICE_STATE_OFFLINE) - * data.WriteRawData(nullptr, deviceSize) - * 3. call IpcCmdRegister OnIpcCmd with parameter - * 4. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_004, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - MessageParcel reply; - MessageParcel data; - // 2. data.WriteString(pkgname) - data.WriteString("com.ohos.test"); - // data.WriteInt32(DEVICE_STATE_OFFLINE) - data.WriteInt32(DEVICE_STATE_OFFLINE); - size_t deviceSize = sizeof(DmDeviceInfo); - // data.WriteRawData(nullptr, deviceSize) - data.WriteRawData(nullptr, deviceSize); - // 3. call IpcCmdRegister OnIpcCmd with parameter - int ret = 0; - ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - // check ret is DM_OK - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_005 - * @tc.desc: 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - * 2. data.WriteString(pkgname) - * data.WriteInt32(DEVICE_INFO_CHANGED) - * data.WriteRawData(nullptr, deviceSize) - * 3. call IpcCmdRegister OnIpcCmd with parameter - * 4. check ret is DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_005, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode SERVER_DEVICE_STATE_NOTIFY - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - MessageParcel reply; - MessageParcel data; - // 2. data.WriteString(pkgname) - data.WriteString("com.ohos.test"); - // data.WriteInt32(DEVICE_INFO_CHANGED) - data.WriteInt32(DEVICE_INFO_CHANGED); - size_t deviceSize = sizeof(DmDeviceInfo); - // data.WriteRawData(nullptr, deviceSize) - data.WriteRawData(nullptr, deviceSize); - // 3. call IpcCmdRegister OnIpcCmd with parameter - int ret = 0; - ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - // 4.check ret is DM_OK - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_006 - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_006, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FOUND; - MessageParcel reply; - MessageParcel data; - uint16_t subscribeId = 1; - DmDeviceInfo deviceInfo; - data.WriteString("com.ohos.test"); - data.WriteInt16(subscribeId); - size_t deviceSize = sizeof(DmDeviceInfo); - data.WriteRawData(&deviceInfo, deviceSize); - int ret = 0; - ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - ASSERT_EQ(ret, DM_OK); -} - /** * @tc.name: OnIpcCmd_007 * @tc.type: FUNC @@ -946,105 +794,6 @@ HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_008, testing::ext::TestSize.Level0) ASSERT_EQ(ret, ERR_DM_UNSUPPORTED_IPC_COMMAND); } -/** - * @tc.name: OnIpcCmd_009 - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_009, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DISCOVER_FINISH; - MessageParcel reply; - MessageParcel data; - uint16_t subscribeId = 1; - int32_t failedReason = 0; - data.WriteString("com.ohos.test"); - data.WriteInt16(subscribeId); - data.WriteInt32(failedReason); - int ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_010 - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_010, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_PUBLISH_FINISH; - MessageParcel reply; - MessageParcel data; - int32_t publishId = 1; - int32_t publishResult = 0; - data.WriteString("com.ohos.test"); - data.WriteInt32(publishId); - data.WriteInt32(publishResult); - int ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_011 - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_011, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_AUTH_RESULT; - MessageParcel reply; - MessageParcel data; - std::string pkgName = "ohos.test"; - std::string deviceId = "123"; - std::string token = "123456"; - int32_t status = 1; - int32_t reason = 0; - data.WriteString(pkgName); - data.WriteString(deviceId); - data.WriteString(token); - data.WriteInt32(status); - data.WriteInt32(reason); - int ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_013 - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_013, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_DEVICE_FA_NOTIFY; - MessageParcel reply; - MessageParcel data; - std::string pkgName = "ohos.test"; - std::string paramJson = "123"; - data.WriteString(pkgName); - data.WriteString(paramJson); - int ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - ASSERT_EQ(ret, DM_OK); -} - -/** - * @tc.name: OnIpcCmd_014 - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcCmdRegisterTest, OnIpcCmd_014, testing::ext::TestSize.Level0) -{ - int32_t cmdCode = SERVER_CREDENTIAL_RESULT; - MessageParcel reply; - MessageParcel data; - std::string pkgName = "ohos.test"; - std::string credentialResult = "123"; - int32_t action = 0; - data.WriteString(pkgName); - data.WriteInt32(action); - data.WriteString(credentialResult); - int ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); - ASSERT_EQ(ret, DM_OK); -} } // namespace } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file 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_listener.cpp b/test/unittest/UTTest_ipc_server_listener.cpp index dfe72c781c2818aa6e08f9929b8e59700dd3957b..6513e0025275a1d1983045c71eb1e25d341553e0 100644 --- a/test/unittest/UTTest_ipc_server_listener.cpp +++ b/test/unittest/UTTest_ipc_server_listener.cpp @@ -82,35 +82,6 @@ HWTEST_F(IpcServerListenerTest, SendRequest_001, testing::ext::TestSize.Level0) ASSERT_NE(ret, DM_OK); } -/** - * @tc.name: SendRequest_002 - * @tc.desc: 1. set cmdCode not null - * set pkgName null - * 2. set req not null - * set rsp not null - * 3. call IpcServerListener SendRequest - * 4. check ret is ERR_DM_IPC_RESPOND_FAILED - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerListenerTest, SendRequest_002, testing::ext::TestSize.Level0) -{ - // 1. set cmdCode not null - int32_t cmdCode = SERVER_DEVICE_STATE_NOTIFY; - // set pkgName not null - std::string pkgName; - // set req not null - std::shared_ptr req = std::make_shared(); - // set rsp not null - std::shared_ptr rsp = std::make_shared(); - req->SetPkgName(pkgName); - // 2. call IpcServerListener SendRequest - std::shared_ptr ipcServerListener = std::make_shared(); - int ret = ipcServerListener->SendRequest(cmdCode, req, rsp); - // 3. check ret is not ERR_DM_IPC_RESPOND_FAILED - ASSERT_NE(ret, ERR_DM_IPC_RESPOND_FAILED); -} - /** * @tc.name: SendRequest_003 * @tc.desc: 1. set cmdCode not null diff --git a/test/unittest/UTTest_ipc_server_stub.cpp b/test/unittest/UTTest_ipc_server_stub.cpp index adc33ab53c1bb534285886645528d21208a98aec..c2f2db174474fd5d8372838a73c634bee8fe7f55 100644 --- a/test/unittest/UTTest_ipc_server_stub.cpp +++ b/test/unittest/UTTest_ipc_server_stub.cpp @@ -141,28 +141,6 @@ HWTEST_F(IpcServerStubTest, OnRemoteRequest_001, testing::ext::TestSize.Level0) ASSERT_NE(ret, DM_OK); } -/** - * @tc.name: OnRemoteRequest_002 - * @tc.desc: 1. Set Code = 999 - * 2. Call IpcServerStub OnRemoteRequest with param - * 3. check ret not DM_OK - * @tc.type: FUNC - * @tc.require: AR000GHSJK - */ -HWTEST_F(IpcServerStubTest, OnRemoteRequest_002, testing::ext::TestSize.Level0) -{ - // 1. Set Code is SERVER_DEVICE_STATE_NOTIFY - uint32_t code = SERVER_DEVICE_STATE_NOTIFY; - MessageParcel data; - MessageParcel reply; - MessageOption option; - int ret = 0; - // 2. Call IpcServerStub OnRemoteRequest with param - ret = IpcServerStub::GetInstance().OnRemoteRequest(code, data, reply, option); - // 3. check ret not DM_OK - ASSERT_NE(ret, DM_OK); -} - /** * @tc.name: SendCmd_001 * @tc.desc: 1. Call IpcServerStub SendCmd @@ -217,125 +195,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 +210,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 +232,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..de0885971f9f593e604586eb99090bca37266c13 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -128,8 +128,11 @@ if (defined(ohos_lite)) { sources = [ "${common_path}/src/dm_anonymous.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", @@ -207,10 +210,13 @@ if (defined(ohos_lite)) { ] sources = [ + "${innerkits_path}/native_cpp/src/dm_device_info.cpp", + "${innerkits_path}/native_cpp/src/dm_device_profile_info.cpp", "${common_path}/src/dm_anonymous.cpp", "src/appInfo/standard/app_manager.cpp", "src/crypto/dm_crypto.cpp", "src/dm_random.cpp", + "src/dm_ipc_utils.cpp", "src/kvadapter/dm_kv_info.cpp", "src/kvadapter/kv_adapter.cpp", "src/kvadapter/kv_adapter_manager.cpp", diff --git a/utils/include/dm_ipc_utils.h b/utils/include/dm_ipc_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..8b366d0b44e8751ba37ccc0667434b9d8d1dd863 --- /dev/null +++ b/utils/include/dm_ipc_utils.h @@ -0,0 +1,55 @@ +/* + * 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 OHOS_DM_IPC_UTILS_H +#define OHOS_DM_IPC_UTILS_H + +#include +#include + +#include "dm_device_info.h" +#include "dm_device_profile_info.h" +namespace OHOS { +namespace DistributedHardware { + +class DmIpcUtils { +public: + static void ConvertToProcessInfoExt(const ProcessInfo &base, ProcessInfoExt &ext); + static void ConvertToDmDeviceIconInfoExt(const DmDeviceIconInfo &base, DmDeviceIconInfoExt &ext); + static std::vector ConvertToDmDeviceProfileInfoExt( + const std::vector &baseVector); + static void ConvertToPeerTargetIdExt(const PeerTargetId &base, PeerTargetIdExt &ext); + static void ConvertToDmDeviceInfoExt(const DmDeviceInfo &base, DmDeviceInfoExt &ext); + static void ConvertToDmDeviceBasicInfoExt(const DmDeviceBasicInfo &base, DmDeviceBasicInfoExt &ext); + + static ProcessInfo ConvertToProcessInfo(ProcessInfoExt &ext); + static DmDeviceIconInfo ConvertToDmDeviceIconInfo(const DmDeviceIconInfoExt &ext); + static std::vector ConvertToDmDeviceProfileInfo( + const std::vector &extVector); + static PeerTargetId ConvertToPeerTargetId(const PeerTargetIdExt &ext); + static DmDeviceInfo ConvertToDmDeviceInfo(const DmDeviceInfoExt &ext); + static DmDeviceBasicInfo ConvertToDmDeviceBasicInfo(const DmDeviceBasicInfoExt &ext); + + static ProcessInfoExt ConvertToProcessInfoExtWrapper(const ProcessInfo &base); + static DmDeviceIconInfoExt ConvertToDmDeviceIconInfoExtWrapper(const DmDeviceIconInfo &base); + static std::vector + ConvertToDmDeviceProfileInfoExtWrapper(const std::vector &baseVector); + static PeerTargetIdExt ConvertToPeerTargetIdExtWrapper(const PeerTargetId &base); + static DmDeviceInfoExt ConvertToDmDeviceInfoExtWrapper(const DmDeviceInfo& base); + static DmDeviceBasicInfoExt ConvertToDmDeviceBasicInfoExtWrapper(const DmDeviceBasicInfo &base); +}; + +} // namespace DistributedHardware +} // namespace OHOS +#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..fb1fdcbd9ffbc6fb16931c6977011e23f4284787 --- /dev/null +++ b/utils/src/dm_ipc_utils.cpp @@ -0,0 +1,252 @@ +/* + * 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; +} + +std::vector DmIpcUtils::ConvertToDmDeviceProfileInfoExt( + const std::vector &baseVector) +{ + 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); + } + return tempVector; +} + +std::vector DmIpcUtils::ConvertToDmDeviceProfileInfo( + 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); + } + return tempVector; +} + +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_NAME_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_NAME_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_NAME_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_NAME_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; +} + +ProcessInfoExt DmIpcUtils::ConvertToProcessInfoExtWrapper(const ProcessInfo &base) +{ + ProcessInfoExt ext; + DmIpcUtils::ConvertToProcessInfoExt(base, ext); + return ext; +} + +DmDeviceIconInfoExt DmIpcUtils::ConvertToDmDeviceIconInfoExtWrapper(const DmDeviceIconInfo &base) +{ + DmDeviceIconInfoExt ext; + DmIpcUtils::ConvertToDmDeviceIconInfoExt(base, ext); + return ext; +} + +std::vector DmIpcUtils::ConvertToDmDeviceProfileInfoExtWrapper( + const std::vector &baseVector) +{ + std::vector extVector; + extVector.reserve(baseVector.size()); + extVector = DmIpcUtils::ConvertToDmDeviceProfileInfoExt(baseVector); + return extVector; +} + +PeerTargetIdExt DmIpcUtils::ConvertToPeerTargetIdExtWrapper(const PeerTargetId &base) +{ + PeerTargetIdExt ext; + DmIpcUtils::ConvertToPeerTargetIdExt(base, ext); + return ext; +} + +DmDeviceInfoExt DmIpcUtils::ConvertToDmDeviceInfoExtWrapper(const DmDeviceInfo& base) +{ + DmDeviceInfoExt ext; + DmIpcUtils::ConvertToDmDeviceInfoExt(base, ext); + return ext; +} + +DmDeviceBasicInfoExt DmIpcUtils::ConvertToDmDeviceBasicInfoExtWrapper(const DmDeviceBasicInfo &base) +{ + DmDeviceBasicInfoExt ext; + ConvertToDmDeviceBasicInfoExt(base, ext); + return ext; +} +} +} \ No newline at end of file