From 834d796895554a0d358b31f5e728d805071d319d Mon Sep 17 00:00:00 2001 From: BrainL Date: Wed, 4 Jun 2025 15:42:25 +0800 Subject: [PATCH 1/9] dp idl Signed-off-by: BrainL Change-Id: I9658e75ce72f83949c54c6e8687e0de80d3bf91d --- bundle.json | 4 +- common/BUILD.gn | 6 +- .../interfaces/access_control_profile.h | 14 +- common/include/interfaces/accessee.h | 3 + common/include/interfaces/accesser.h | 3 + .../interfaces/characteristic_profile.h | 13 +- common/include/interfaces/device_icon_info.h | 14 +- .../device_icon_info_filter_options.h | 13 +- common/include/interfaces/device_profile.h | 13 +- .../device_profile_filter_options.h | 14 +- common/include/interfaces/dp_subscribe_info.h | 10 +- .../interfaces/dp_subscribe_info_extension.h | 66 + common/include/interfaces/dp_sync_options.h | 13 +- .../interfaces/i_distributed_device_profile.h | 110 -- .../include/interfaces/local_service_info.h | 14 +- common/include/interfaces/product_info.h | 14 +- .../include/interfaces/service_info_profile.h | 14 +- .../interfaces/service_info_unique_key.h | 14 +- common/include/interfaces/service_profile.h | 15 +- .../include/interfaces/trust_device_profile.h | 14 +- .../include/interfaces/trusted_device_info.h | 14 +- common/include/utils/ipc_utils.h | 1 + .../src/interfaces/access_control_profile.cpp | 57 + common/src/interfaces/accessee.cpp | 42 + common/src/interfaces/accesser.cpp | 42 + .../src/interfaces/characteristic_profile.cpp | 37 + common/src/interfaces/device_icon_info.cpp | 74 ++ .../device_icon_info_filter_options.cpp | 52 + common/src/interfaces/device_profile.cpp | 93 ++ .../device_profile_filter_options.cpp | 94 ++ .../interfaces/dp_inited_callback_proxy.cpp | 2 +- common/src/interfaces/dp_subscribe_info.cpp | 1 - .../dp_subscribe_info_extension.cpp | 128 ++ common/src/interfaces/dp_sync_options.cpp | 43 + common/src/interfaces/local_service_info.cpp | 45 +- .../pincode_invalid_callback_proxy.cpp | 2 +- common/src/interfaces/product_info.cpp | 36 +- .../profile_change_listener_proxy.cpp | 2 +- .../src/interfaces/service_info_profile.cpp | 83 +- .../interfaces/service_info_unique_key.cpp | 37 +- common/src/interfaces/service_profile.cpp | 35 + .../src/interfaces/trust_device_profile.cpp | 39 + common/src/interfaces/trusted_device_info.cpp | 39 + common/src/utils/ipc_utils.cpp | 1 + interfaces/innerkits/core/BUILD.gn | 58 +- .../core/IDistributedDeviceProfile.idl | 92 ++ .../distributed_device_profile_client.h | 4 +- .../distributed_device_profile_proxy.h | 107 -- .../src/distributed_device_profile_client.cpp | 10 +- .../src/distributed_device_profile_proxy.cpp | 789 ------------ .../fuzztest/dumplocalprofile_fuzzer/BUILD.gn | 0 .../fuzztest/getdeviceprofile_fuzzer/BUILD.gn | 0 .../fuzztest/putdeviceprofile_fuzzer/BUILD.gn | 0 .../putdeviceprofileinner_fuzzer/BUILD.gn | 0 .../BUILD.gn | 0 .../syncdeviceprofileinner_fuzzer/BUILD.gn | 0 radar/test/unittest/BUILD.gn | 1 + services/core/BUILD.gn | 8 +- .../include/common/dp_services_constants.h | 2 +- .../distributed_device_profile_service_new.h | 24 +- .../distributed_device_profile_stub_new.h | 102 -- .../subscribe_profile_manager.h | 13 +- ...distributed_device_profile_service_new.cpp | 26 +- .../distributed_device_profile_stub_new.cpp | 1057 --------------- .../subscribe_profile_manager.cpp | 41 +- services/core/test/BUILD.gn | 15 - .../new_device_profile_fuzzer.cpp | 1 - ...stributed_device_profile_stub_new_test.cpp | 1132 ----------------- 68 files changed, 1393 insertions(+), 3469 deletions(-) create mode 100644 common/include/interfaces/dp_subscribe_info_extension.h delete mode 100644 common/include/interfaces/i_distributed_device_profile.h create mode 100644 common/src/interfaces/dp_subscribe_info_extension.cpp create mode 100644 interfaces/innerkits/core/IDistributedDeviceProfile.idl delete mode 100644 interfaces/innerkits/core/include/distributed_device_profile_proxy.h delete mode 100644 interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp mode change 100755 => 100644 old/services/core/test/fuzztest/dumplocalprofile_fuzzer/BUILD.gn mode change 100755 => 100644 old/services/core/test/fuzztest/getdeviceprofile_fuzzer/BUILD.gn mode change 100755 => 100644 old/services/core/test/fuzztest/putdeviceprofile_fuzzer/BUILD.gn mode change 100755 => 100644 old/services/core/test/fuzztest/putdeviceprofileinner_fuzzer/BUILD.gn mode change 100755 => 100644 old/services/core/test/fuzztest/subscribeprofileeventinner_fuzzer/BUILD.gn mode change 100755 => 100644 old/services/core/test/fuzztest/syncdeviceprofileinner_fuzzer/BUILD.gn delete mode 100644 services/core/include/distributed_device_profile_stub_new.h delete mode 100644 services/core/src/distributed_device_profile_stub_new.cpp delete mode 100644 services/core/test/unittest/distributed_device_profile_stub_new_test.cpp diff --git a/bundle.json b/bundle.json index 4f5ee067..68d073ec 100644 --- a/bundle.json +++ b/bundle.json @@ -72,8 +72,7 @@ "name": "//foundation/deviceprofile/device_info_manager/interfaces/innerkits/core:distributed_device_profile_sdk", "header": { "header_files": [ - "distributed_device_profile_client.h", - "distributed_device_profile_proxy.h" + "distributed_device_profile_client.h" ], "header_base": "//foundation/deviceprofile/device_info_manager/interfaces/innerkits/core/include/" } @@ -89,7 +88,6 @@ "device_profile.h", "dp_subscribe_info.h", "dp_sync_options.h", - "i_distributed_device_profile.h", "i_profile_change_listener.h", "i_sync_completed_callback.h", "profile_change_listener_proxy.h", diff --git a/common/BUILD.gn b/common/BUILD.gn index 52a0d330..d4f03880 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -61,6 +61,7 @@ ohos_shared_library("distributed_device_profile_common") { "src/interfaces/dp_inited_callback_proxy.cpp", "src/interfaces/dp_inited_callback_stub.cpp", "src/interfaces/dp_subscribe_info.cpp", + "src/interfaces/dp_subscribe_info_extension.cpp", "src/interfaces/dp_sync_options.cpp", "src/interfaces/i_profile_change_listener.cpp", "src/interfaces/local_service_info.cpp", @@ -85,7 +86,10 @@ ohos_shared_library("distributed_device_profile_common") { deps = [] - public_configs = [ ":distributed_device_profile_common_config" ] + public_configs = [ + ":distributed_device_profile_common_config", + "${device_profile_innerkits}:distributed_device_profile_interfaces_ipc_config", + ] external_deps = [ "access_token:libaccesstoken_sdk", diff --git a/common/include/interfaces/access_control_profile.h b/common/include/interfaces/access_control_profile.h index 4edb3da5..ef8feee2 100644 --- a/common/include/interfaces/access_control_profile.h +++ b/common/include/interfaces/access_control_profile.h @@ -21,11 +21,11 @@ #include "accesser.h" #include "accessee.h" #include "distributed_device_profile_enums.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class AccessControlProfile : public DpParcel { +class AccessControlProfile : public Parcelable { public: AccessControlProfile(); ~AccessControlProfile() = default; @@ -63,9 +63,13 @@ public: void SetDeviceIdHash(const std::string& deviceIdHash); std::string GetExtraData() const; void SetExtraData(const std::string& extraData); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const ; + bool UnMarshalling(MessageParcel& parcel) ; + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static AccessControlProfile *Unmarshalling(Parcel &parcel); private: int64_t accessControlId_; diff --git a/common/include/interfaces/accessee.h b/common/include/interfaces/accessee.h index 4bbac0bd..70c018b4 100644 --- a/common/include/interfaces/accessee.h +++ b/common/include/interfaces/accessee.h @@ -20,6 +20,7 @@ #include #include "distributed_device_profile_enums.h" #include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { @@ -65,6 +66,8 @@ public: bool UnMarshalling(MessageParcel& parcel) override; std::string dump() const override; + bool Marshalling(Parcel& parcel) const; + bool UnMarshalling(Parcel& parcel); private: int64_t accesseeId_; std::string accesseeDeviceId_; diff --git a/common/include/interfaces/accesser.h b/common/include/interfaces/accesser.h index b565e43c..78fcf6c3 100644 --- a/common/include/interfaces/accesser.h +++ b/common/include/interfaces/accesser.h @@ -20,6 +20,7 @@ #include #include "distributed_device_profile_enums.h" #include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { @@ -64,6 +65,8 @@ public: bool UnMarshalling(MessageParcel& parcel) override; std::string dump() const override; + bool Marshalling(Parcel& parcel) const; + bool UnMarshalling(Parcel& parcel); private: int64_t accesserId_; std::string accesserDeviceId_; diff --git a/common/include/interfaces/characteristic_profile.h b/common/include/interfaces/characteristic_profile.h index 57523ba0..af4e6d99 100644 --- a/common/include/interfaces/characteristic_profile.h +++ b/common/include/interfaces/characteristic_profile.h @@ -19,11 +19,11 @@ #include #include #include "distributed_device_profile_constants.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class CharacteristicProfile : public DpParcel { +class CharacteristicProfile : public Parcelable { public: CharacteristicProfile(const std::string& deviceId, const std::string& serviceName, const std::string& characteristicKey, const std::string& characteristicValue) @@ -57,11 +57,14 @@ public: void SetIsMultiUser(bool isMultiUser); int32_t GetUserId() const; void SetUserId(int32_t userId); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); bool operator!=(const CharacteristicProfile& charProfile) const; - std::string dump() const override; + std::string dump() const; + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static CharacteristicProfile *Unmarshalling(Parcel &parcel); private: std::string deviceId_ = ""; std::string serviceName_ = ""; diff --git a/common/include/interfaces/device_icon_info.h b/common/include/interfaces/device_icon_info.h index 302f67d6..8865c043 100644 --- a/common/include/interfaces/device_icon_info.h +++ b/common/include/interfaces/device_icon_info.h @@ -19,11 +19,11 @@ #include #include -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class DeviceIconInfo : public DpParcel { +class DeviceIconInfo : public Parcelable { public: DeviceIconInfo() : id_(0), @@ -54,11 +54,13 @@ public: void SetUrl(const std::string& url); std::vector GetIcon() const; void SetIcon(const std::vector& icon); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); bool operator!=(const DeviceIconInfo& other) const; - std::string dump() const override; - + std::string dump() const; + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static DeviceIconInfo *Unmarshalling(Parcel &parcel); private: int32_t id_; std::string productId_; diff --git a/common/include/interfaces/device_icon_info_filter_options.h b/common/include/interfaces/device_icon_info_filter_options.h index 7f5be396..31c7ad1d 100644 --- a/common/include/interfaces/device_icon_info_filter_options.h +++ b/common/include/interfaces/device_icon_info_filter_options.h @@ -19,11 +19,11 @@ #include #include -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class DeviceIconInfoFilterOptions : public DpParcel { +class DeviceIconInfoFilterOptions : public Parcelable { public: DeviceIconInfoFilterOptions() : internalModel_(""), subProductId_(""), imageType_(""), specName_("") {} @@ -40,9 +40,12 @@ public: std::string GetSpecName() const; void SetSpecName(const std::string& specName); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const ; + bool UnMarshalling(MessageParcel& parcel) ; + std::string dump() const; + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static DeviceIconInfoFilterOptions *Unmarshalling(Parcel &parcel); private: std::vector productIds_; diff --git a/common/include/interfaces/device_profile.h b/common/include/interfaces/device_profile.h index 7072a39d..8f4a2df2 100644 --- a/common/include/interfaces/device_profile.h +++ b/common/include/interfaces/device_profile.h @@ -19,11 +19,11 @@ #include #include #include "distributed_device_profile_constants.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class DeviceProfile : public DpParcel { +class DeviceProfile : public Parcelable { public: DeviceProfile() : deviceId_(""), @@ -126,10 +126,10 @@ public: void SetAccountId(const std::string& accountId); std::string GetInternalModel() const; void SetInternalModel(const std::string& internalModel); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); bool operator!=(const DeviceProfile& deviceProfile) const; - std::string dump() const override; + std::string dump() const; std::string AnnoymizeDump() const; const std::string GetBleMac() const; void SetBleMac(const std::string& bleMac); @@ -139,6 +139,9 @@ public: void SetSleMac(const std::string& sleMac); int32_t GetSetupType() const; void SetSetupType(int32_t setupType); + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static DeviceProfile *Unmarshalling(Parcel &parcel); private: std::string deviceId_; std::string deviceName_; diff --git a/common/include/interfaces/device_profile_filter_options.h b/common/include/interfaces/device_profile_filter_options.h index db28c64c..ad001c46 100644 --- a/common/include/interfaces/device_profile_filter_options.h +++ b/common/include/interfaces/device_profile_filter_options.h @@ -18,11 +18,11 @@ #include #include "distributed_device_profile_enums.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class DeviceProfileFilterOptions : public DpParcel { +class DeviceProfileFilterOptions : public Parcelable { public: DeviceProfileFilterOptions() : userId_(-1), @@ -43,9 +43,13 @@ public: std::vector GetDeviceProfileIds() const; void SetDeviceProfileIds(std::vector deviceProfileIds); void AddDeviceProfileIds(int32_t deviceProfileId); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static DeviceProfileFilterOptions *Unmarshalling(Parcel &parcel); private: int32_t userId_; diff --git a/common/include/interfaces/dp_subscribe_info.h b/common/include/interfaces/dp_subscribe_info.h index 2429d262..f13a6fe5 100644 --- a/common/include/interfaces/dp_subscribe_info.h +++ b/common/include/interfaces/dp_subscribe_info.h @@ -18,7 +18,7 @@ #include #include -#include "dp_parcel.h" +#include "message_parcel.h" #include "macro_utils.h" #include "iremote_broker.h" #include "i_profile_change_listener.h" @@ -26,7 +26,7 @@ namespace OHOS { namespace DistributedDeviceProfile { -class SubscribeInfo : public DpParcel { +class SubscribeInfo { public: SubscribeInfo(int32_t saId, const std::string& subscribeKey, std::unordered_set subscribeChangeTypes, sptr profileChangeListener, @@ -50,9 +50,9 @@ public: void SetListener(sptr listener); std::unordered_set GetProfileChangeTypes() const; void AddProfileChangeType(ProfileChangeType profileChangeType); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; private: int32_t saId_ = -1; diff --git a/common/include/interfaces/dp_subscribe_info_extension.h b/common/include/interfaces/dp_subscribe_info_extension.h new file mode 100644 index 00000000..359d5e60 --- /dev/null +++ b/common/include/interfaces/dp_subscribe_info_extension.h @@ -0,0 +1,66 @@ +/* + * 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_DP_SUBSCRIBER_INFO_EXTENSION_H +#define OHOS_DP_SUBSCRIBER_INFO_EXTENSION_H + +#include +#include +#include "message_parcel.h" +#include "macro_utils.h" +#include "iremote_broker.h" +#include "i_profile_change_listener.h" +#include "distributed_device_profile_constants.h" +#include "dp_subscribe_info.h" + + +namespace OHOS { +namespace DistributedDeviceProfile { +class SubscribeInfoExtension : public Parcelable, public SubscribeInfo { +public: + SubscribeInfoExtension(int32_t saId, const std::string& subscribeKey, + std::unordered_set subscribeChangeTypes, + sptr profileChangeListener, + int32_t userId = DEFAULT_USER_ID); + SubscribeInfoExtension(const SubscribeInfo& subscribeInfo); + SubscribeInfoExtension(); + ~SubscribeInfoExtension(); + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static SubscribeInfoExtension *Unmarshalling(Parcel &parcel); + +private: + int32_t saId_ = -1; + std::string subscribeKey_ = ""; + std::unordered_set subscribeChangeTypes_; + sptr listener_ = nullptr; +}; + +class SubscribeExtensionCompare : public SubscribeCompare { +public: + SubscribeExtensionCompare() = default; + ~SubscribeExtensionCompare() = default; +}; + +class SubscribeExtensionHash : public SubscribeHash { +public: + SubscribeExtensionHash() = default; + ~SubscribeExtensionHash() = default; +}; +} // namespace DistributedDeviceProfile +} // namespace OHOS + +#endif // OHOS_DP_SUBSCRIBER_INFO_EXTENSION_H \ No newline at end of file diff --git a/common/include/interfaces/dp_sync_options.h b/common/include/interfaces/dp_sync_options.h index ceaf502c..db0ead6d 100644 --- a/common/include/interfaces/dp_sync_options.h +++ b/common/include/interfaces/dp_sync_options.h @@ -19,13 +19,13 @@ #include #include #include -#include "dp_parcel.h" +#include "message_parcel.h" #include "distributed_device_profile_constants.h" #include "distributed_device_profile_enums.h" namespace OHOS { namespace DistributedDeviceProfile { -class DpSyncOptions : public DpParcel { +class DpSyncOptions : public Parcelable { public: DpSyncOptions() = default; ~DpSyncOptions() = default; @@ -35,10 +35,13 @@ public: void AddDevice(const std::string& deviceId); void SetSyncMode(SyncMode mode); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static DpSyncOptions *Unmarshalling(Parcel &parcel); private: SyncMode syncMode_{SyncMode::PUSH_PULL}; std::vector syncDeviceIds_; diff --git a/common/include/interfaces/i_distributed_device_profile.h b/common/include/interfaces/i_distributed_device_profile.h deleted file mode 100644 index b459ecc6..00000000 --- a/common/include/interfaces/i_distributed_device_profile.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2023-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_DP_I_DISTRIBUTED_DEVICE_PROFILE_H -#define OHOS_DP_I_DISTRIBUTED_DEVICE_PROFILE_H - -#include - -#include "iremote_broker.h" - -#include "access_control_profile.h" -#include "characteristic_profile.h" -#include "device_icon_info.h" -#include "device_icon_info_filter_options.h" -#include "device_profile.h" -#include "device_profile_filter_options.h" -#include "dp_subscribe_info.h" -#include "dp_sync_options.h" -#include "i_sync_completed_callback.h" -#include "product_info.h" -#include "service_info_profile.h" -#include "service_info_unique_key.h" -#include "service_profile.h" -#include "trust_device_profile.h" -#include "trusted_device_info.h" -#include "local_service_info.h" - -namespace OHOS { -namespace DistributedDeviceProfile { -class IDistributedDeviceProfile : public OHOS::IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.DeviceProfile.IDistributedDeviceProfile"); - IDistributedDeviceProfile() = default; - virtual ~IDistributedDeviceProfile() = default; - virtual int32_t PutAccessControlProfile(const AccessControlProfile& aclProfile) = 0; - virtual int32_t UpdateAccessControlProfile(const AccessControlProfile& aclProfile) = 0; - virtual int32_t GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile) = 0; - virtual int32_t GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles) = 0; - virtual int32_t GetAccessControlProfile(std::map queryParams, - std::vector& accessControlProfiles) = 0; - virtual int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) = 0; - virtual int32_t GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles) = 0; - virtual int32_t DeleteAccessControlProfile(int32_t accessControlId) = 0; - virtual int32_t PutSessionKey(uint32_t userId, const std::vector& sessionKey, int32_t& sessionKeyId) = 0; - virtual int32_t GetSessionKey(uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey) = 0; - virtual int32_t UpdateSessionKey(uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey) = 0; - virtual int32_t DeleteSessionKey(uint32_t userId, int32_t sessionKeyId) = 0; - virtual int32_t PutDeviceProfileBatch(std::vector& deviceProfiles) = 0; - virtual int32_t PutServiceProfile(const ServiceProfile& serviceProfile) = 0; - virtual int32_t PutServiceProfileBatch(const std::vector& serviceProfiles) = 0; - virtual int32_t PutCharacteristicProfile(const CharacteristicProfile& charProfile) = 0; - virtual int32_t PutCharacteristicProfileBatch(const std::vector& charProfiles) = 0; - virtual int32_t GetDeviceProfile(const std::string& deviceId, DeviceProfile& deviceProfile) = 0; - virtual int32_t GetDeviceProfiles(DeviceProfileFilterOptions& options, - std::vector& deviceProfiles) = 0; - virtual int32_t DeleteDeviceProfileBatch(std::vector& deviceProfiles) = 0; - virtual int32_t GetServiceProfile(const std::string& deviceId, const std::string& serviceName, - ServiceProfile& serviceProfile) = 0; - virtual int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, - const std::string& characteristicId, CharacteristicProfile& charProfile) = 0; - virtual int32_t DeleteServiceProfile(const std::string& deviceId, const std::string& serviceName, - bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID) = 0; - virtual int32_t DeleteCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, - const std::string& characteristicId, bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID) = 0; - virtual int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) = 0; - virtual int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) = 0; - virtual int32_t SubscribeDeviceProfileInited(int32_t saId, sptr dpInitedCallback) = 0; - virtual int32_t UnSubscribeDeviceProfileInited(int32_t saId) = 0; - virtual int32_t SubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType, - sptr pinCodeCallback) = 0; - virtual int32_t UnSubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType) = 0; - virtual int32_t SyncDeviceProfile(const DistributedDeviceProfile::DpSyncOptions& syncOptions, - sptr syncCompletedCallback) = 0; - virtual int32_t SendSubscribeInfos(std::map listenerMap) = 0; - virtual int32_t PutAllTrustedDevices(const std::vector deviceInfos) = 0; - virtual int32_t PutProductInfoBatch(const std::vector& productInfos) = 0; - virtual int32_t PutDeviceIconInfoBatch(const std::vector& deviceIconInfos) = 0; - virtual int32_t GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, - std::vector& deviceIconInfos) = 0; - virtual int32_t PutServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) = 0; - virtual int32_t DeleteServiceInfoProfile(const ServiceInfoUniqueKey& key) = 0; - virtual int32_t UpdateServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) = 0; - virtual int32_t GetServiceInfoProfileByUniqueKey(const ServiceInfoUniqueKey& key, - ServiceInfoProfile& serviceInfoProfile) = 0; - virtual int32_t GetServiceInfoProfileListByTokenId(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) = 0; - virtual int32_t GetAllServiceInfoProfileList(std::vector& serviceInfoProfiles) = 0; - virtual int32_t GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) = 0; - virtual int32_t PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo) = 0; - virtual int32_t UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo) = 0; - virtual int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, - int32_t pinExchangeType, LocalServiceInfo& localServiceInfo) = 0; - virtual int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType) = 0; -}; -} // namespace DistributedDeviceProfile -} // namespace OHOS -#endif // OHOS_DP_I_DISTRIBUTED_DEVICE_PROFILE_H diff --git a/common/include/interfaces/local_service_info.h b/common/include/interfaces/local_service_info.h index 26b682c7..51f17aa3 100644 --- a/common/include/interfaces/local_service_info.h +++ b/common/include/interfaces/local_service_info.h @@ -20,11 +20,11 @@ #include #include "distributed_device_profile_constants.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class LocalServiceInfo : public DpParcel { +class LocalServiceInfo : public Parcelable { public: LocalServiceInfo(const std::string& bundleName, const int32_t authBoxType, const int32_t authType, const int32_t pinExchangeType, @@ -56,9 +56,13 @@ public: std::string GetExtraInfo() const; void SetExtraInfo(const std::string& extraInfo); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static LocalServiceInfo *Unmarshalling(Parcel &parcel); private: std::string bundleName_ = ""; diff --git a/common/include/interfaces/product_info.h b/common/include/interfaces/product_info.h index 3f32690a..f6e8f699 100644 --- a/common/include/interfaces/product_info.h +++ b/common/include/interfaces/product_info.h @@ -19,11 +19,11 @@ #include #include -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class ProductInfo : public DpParcel { +class ProductInfo : public Parcelable { public: ProductInfo() : productId_(""), model_(""), @@ -43,10 +43,14 @@ public: void SetProductShortName(const std::string& productShortName); std::string GetImageVersion() const; void SetImageVersion(const std::string& imageVersion); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); bool operator!=(const ProductInfo& other) const; - std::string dump() const override; + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static ProductInfo *Unmarshalling(Parcel &parcel); private: std::string GetAnonyProductName(const std::string& value) const; diff --git a/common/include/interfaces/service_info_profile.h b/common/include/interfaces/service_info_profile.h index f348a92c..894eb2df 100644 --- a/common/include/interfaces/service_info_profile.h +++ b/common/include/interfaces/service_info_profile.h @@ -20,11 +20,11 @@ #include #include "distributed_device_profile_constants.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class ServiceInfoProfile : public DpParcel { +class ServiceInfoProfile : public Parcelable { public: ServiceInfoProfile(const std::string& deviceId, const int32_t userId, const std::string& networkId, const std::string& tokenId, const int64_t serviceId, const std::string& serviceType, @@ -98,9 +98,13 @@ public: std::string GetExtraInfo() const; void SetExtraInfo(const std::string& extraInfo); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static ServiceInfoProfile *Unmarshalling(Parcel &parcel); private: std::string deviceId_ = ""; diff --git a/common/include/interfaces/service_info_unique_key.h b/common/include/interfaces/service_info_unique_key.h index 201fc880..ad705be3 100644 --- a/common/include/interfaces/service_info_unique_key.h +++ b/common/include/interfaces/service_info_unique_key.h @@ -20,11 +20,11 @@ #include #include "distributed_device_profile_constants.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class ServiceInfoUniqueKey : public DpParcel { +class ServiceInfoUniqueKey : public Parcelable { public: ServiceInfoUniqueKey(const std::string& deviceId, const int32_t userId, const std::string& tokenId, const int64_t serviceId) @@ -53,9 +53,13 @@ public: void SetBundleName(const std::string& bundleName); bool operator<(const ServiceInfoUniqueKey& rhs) const; - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static ServiceInfoUniqueKey *Unmarshalling(Parcel &parcel); private: std::string deviceId_ = ""; diff --git a/common/include/interfaces/service_profile.h b/common/include/interfaces/service_profile.h index b8ff73bd..0aa099b3 100644 --- a/common/include/interfaces/service_profile.h +++ b/common/include/interfaces/service_profile.h @@ -19,11 +19,12 @@ #include #include #include "distributed_device_profile_constants.h" -#include "dp_parcel.h" +#include "message_parcel.h" +#include "distributed_device_profile_errors.h" namespace OHOS { namespace DistributedDeviceProfile { -class ServiceProfile : public DpParcel { +class ServiceProfile : public Parcelable { public: ServiceProfile(const std::string& deviceId, const std::string& serviceName, const std::string& serviceType); ServiceProfile(const std::string& deviceId, const std::string& serviceName, const std::string& serviceType, @@ -41,10 +42,14 @@ public: void SetIsMultiUser(bool isMultiUser); int32_t GetUserId() const; void SetUserId(int32_t userId); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); bool operator!=(const ServiceProfile& serviceProfile) const; - std::string dump() const override; + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static ServiceProfile *Unmarshalling(Parcel &parcel); private: std::string deviceId_ = ""; diff --git a/common/include/interfaces/trust_device_profile.h b/common/include/interfaces/trust_device_profile.h index 8ced271e..69dc7e61 100644 --- a/common/include/interfaces/trust_device_profile.h +++ b/common/include/interfaces/trust_device_profile.h @@ -18,11 +18,11 @@ #include #include "distributed_device_profile_enums.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class TrustDeviceProfile : public DpParcel { +class TrustDeviceProfile : public Parcelable { public: TrustDeviceProfile() : deviceId_(""), @@ -49,9 +49,13 @@ public: void SetPeerUserId(int32_t peerUserId); int32_t GetLocalUserId() const; void SetLocalUserId(int32_t localUserId); - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static TrustDeviceProfile *Unmarshalling(Parcel &parcel); private: std::string deviceId_; diff --git a/common/include/interfaces/trusted_device_info.h b/common/include/interfaces/trusted_device_info.h index 82029040..a0f0127d 100644 --- a/common/include/interfaces/trusted_device_info.h +++ b/common/include/interfaces/trusted_device_info.h @@ -18,11 +18,11 @@ #include #include "distributed_device_profile_constants.h" -#include "dp_parcel.h" +#include "message_parcel.h" namespace OHOS { namespace DistributedDeviceProfile { -class TrustedDeviceInfo : public DpParcel { +class TrustedDeviceInfo : public Parcelable { public: TrustedDeviceInfo() : networkId_(""), authForm_(BINDTYPE_INIT), deviceTypeId_(0), osVersion_(""), osType_(0), udid_(""), uuid_("") @@ -46,9 +46,13 @@ public: bool operator!=(const TrustedDeviceInfo& trustedDeviceInfo) const; bool operator<(const TrustedDeviceInfo& trustedDeviceInfo) const; - bool Marshalling(MessageParcel& parcel) const override; - bool UnMarshalling(MessageParcel& parcel) override; - std::string dump() const override; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); + std::string dump() const; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static TrustedDeviceInfo *Unmarshalling(Parcel &parcel); private: std::string networkId_; diff --git a/common/include/utils/ipc_utils.h b/common/include/utils/ipc_utils.h index 4d3ba092..34300b12 100644 --- a/common/include/utils/ipc_utils.h +++ b/common/include/utils/ipc_utils.h @@ -33,6 +33,7 @@ #include "distributed_device_profile_errors.h" #include "distributed_device_profile_log.h" #include "dp_subscribe_info.h" +#include "dp_subscribe_info_extension.h" #include "product_info.h" #include "service_info_profile.h" #include "service_profile.h" diff --git a/common/src/interfaces/access_control_profile.cpp b/common/src/interfaces/access_control_profile.cpp index 07fc60a0..1615c973 100644 --- a/common/src/interfaces/access_control_profile.cpp +++ b/common/src/interfaces/access_control_profile.cpp @@ -282,5 +282,62 @@ std::string AccessControlProfile::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool AccessControlProfile::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, Int64, accessControlId_, false); + READ_HELPER_RET(parcel, Int64, accesserId_, false); + READ_HELPER_RET(parcel, Int64, accesseeId_, false); + READ_HELPER_RET(parcel, String, sessionKey_, false); + READ_HELPER_RET(parcel, Uint32, bindType_, false); + READ_HELPER_RET(parcel, Uint32, authenticationType_, false); + READ_HELPER_RET(parcel, Uint32, bindLevel_, false); + READ_HELPER_RET(parcel, Int32, status_, false); + READ_HELPER_RET(parcel, Int64, validPeriod_, false); + READ_HELPER_RET(parcel, Int64, lastAuthTime_, false); + READ_HELPER_RET(parcel, String, trustDeviceId_, false); + READ_HELPER_RET(parcel, Uint32, deviceIdType_, false); + READ_HELPER_RET(parcel, String, deviceIdHash_, false); + READ_HELPER_RET(parcel, String, extraData_, false); + accesser_.UnMarshalling(parcel); + accessee_.UnMarshalling(parcel); + return true; +} + +AccessControlProfile *AccessControlProfile::Unmarshalling(Parcel &parcel) +{ + AccessControlProfile *accessControlProfile = new (std::nothrow) AccessControlProfile(); + if (accessControlProfile == nullptr) { + return nullptr; + } + + if (!accessControlProfile->ReadFromParcel(parcel)) { + delete accessControlProfile; + accessControlProfile = nullptr; + } + + return accessControlProfile; +} + +bool AccessControlProfile::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, Int64, accessControlId_, false); + WRITE_HELPER_RET(parcel, Int64, accesserId_, false); + WRITE_HELPER_RET(parcel, Int64, accesseeId_, false); + WRITE_HELPER_RET(parcel, String, sessionKey_, false); + WRITE_HELPER_RET(parcel, Uint32, bindType_, false); + WRITE_HELPER_RET(parcel, Uint32, authenticationType_, false); + WRITE_HELPER_RET(parcel, Uint32, bindLevel_, false); + WRITE_HELPER_RET(parcel, Int32, status_, false); + WRITE_HELPER_RET(parcel, Int32, validPeriod_, false); + WRITE_HELPER_RET(parcel, Int32, lastAuthTime_, false); + WRITE_HELPER_RET(parcel, String, trustDeviceId_, false); + WRITE_HELPER_RET(parcel, Uint32, deviceIdType_, false); + WRITE_HELPER_RET(parcel, String, deviceIdHash_, false); + WRITE_HELPER_RET(parcel, String, extraData_, false); + accesser_.Marshalling(parcel); + accessee_.Marshalling(parcel); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS \ No newline at end of file diff --git a/common/src/interfaces/accessee.cpp b/common/src/interfaces/accessee.cpp index ede75755..fcfaf5dd 100644 --- a/common/src/interfaces/accessee.cpp +++ b/common/src/interfaces/accessee.cpp @@ -283,5 +283,47 @@ std::string Accessee::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool Accessee::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, Int64, accesseeId_, false); + WRITE_HELPER_RET(parcel, String, accesseeDeviceId_, false); + WRITE_HELPER_RET(parcel, Int32, accesseeUserId_, false); + WRITE_HELPER_RET(parcel, String, accesseeAccountId_, false); + WRITE_HELPER_RET(parcel, Int64, accesseeTokenId_, false); + WRITE_HELPER_RET(parcel, String, accesseeBundleName_, false); + WRITE_HELPER_RET(parcel, String, accesseeHapSignature_, false); + WRITE_HELPER_RET(parcel, Uint32, accesseeBindLevel_, false); + WRITE_HELPER_RET(parcel, String, accesseeDeviceName_, false); + WRITE_HELPER_RET(parcel, String, accesseeServiceName_, false); + WRITE_HELPER_RET(parcel, Int32, accesseeCredentialId_, false); + WRITE_HELPER_RET(parcel, String, accesseeCredentialIdStr_, false); + WRITE_HELPER_RET(parcel, Int32, accesseeStatus_, false); + WRITE_HELPER_RET(parcel, Int32, accesseeSessionKeyId_, false); + WRITE_HELPER_RET(parcel, Int64, accesseeSKTimeStamp_, false); + WRITE_HELPER_RET(parcel, String, accesseeExtraData_, false); + return true; +} + +bool Accessee::UnMarshalling(Parcel& parcel) +{ + READ_HELPER_RET(parcel, Int64, accesseeId_, false); + READ_HELPER_RET(parcel, String, accesseeDeviceId_, false); + READ_HELPER_RET(parcel, Int32, accesseeUserId_, false); + READ_HELPER_RET(parcel, String, accesseeAccountId_, false); + READ_HELPER_RET(parcel, Int64, accesseeTokenId_, false); + READ_HELPER_RET(parcel, String, accesseeBundleName_, false); + READ_HELPER_RET(parcel, String, accesseeHapSignature_, false); + READ_HELPER_RET(parcel, Uint32, accesseeBindLevel_, false); + READ_HELPER_RET(parcel, String, accesseeDeviceName_, false); + READ_HELPER_RET(parcel, String, accesseeServiceName_, false); + READ_HELPER_RET(parcel, Int32, accesseeCredentialId_, false); + READ_HELPER_RET(parcel, String, accesseeCredentialIdStr_, false); + READ_HELPER_RET(parcel, Int32, accesseeStatus_, false); + READ_HELPER_RET(parcel, Int32, accesseeSessionKeyId_, false); + READ_HELPER_RET(parcel, Int64, accesseeSKTimeStamp_, false); + READ_HELPER_RET(parcel, String, accesseeExtraData_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS \ No newline at end of file diff --git a/common/src/interfaces/accesser.cpp b/common/src/interfaces/accesser.cpp index aa7b4faa..3808fa73 100644 --- a/common/src/interfaces/accesser.cpp +++ b/common/src/interfaces/accesser.cpp @@ -281,5 +281,47 @@ std::string Accesser::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool Accesser::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, Int64, accesserId_, false); + WRITE_HELPER_RET(parcel, String, accesserDeviceId_, false); + WRITE_HELPER_RET(parcel, Int32, accesserUserId_, false); + WRITE_HELPER_RET(parcel, String, accesserAccountId_, false); + WRITE_HELPER_RET(parcel, Int64, accesserTokenId_, false); + WRITE_HELPER_RET(parcel, String, accesserBundleName_, false); + WRITE_HELPER_RET(parcel, String, accesserHapSignature_, false); + WRITE_HELPER_RET(parcel, Uint32, accesserBindLevel_, false); + WRITE_HELPER_RET(parcel, String, accesserDeviceName_, false); + WRITE_HELPER_RET(parcel, String, accesserServiceName_, false); + WRITE_HELPER_RET(parcel, Int32, accesserCredentialId_, false); + WRITE_HELPER_RET(parcel, String, accesserCredentialIdStr_, false); + WRITE_HELPER_RET(parcel, Int32, accesserStatus_, false); + WRITE_HELPER_RET(parcel, Int32, accesserSessionKeyId_, false); + WRITE_HELPER_RET(parcel, Int64, accesserSKTimeStamp_, false); + WRITE_HELPER_RET(parcel, String, accesserExtraData_, false); + return true; +} + +bool Accesser::UnMarshalling(Parcel& parcel) +{ + READ_HELPER_RET(parcel, Int64, accesserId_, false); + READ_HELPER_RET(parcel, String, accesserDeviceId_, false); + READ_HELPER_RET(parcel, Int32, accesserUserId_, false); + READ_HELPER_RET(parcel, String, accesserAccountId_, false); + READ_HELPER_RET(parcel, Int64, accesserTokenId_, false); + READ_HELPER_RET(parcel, String, accesserBundleName_, false); + READ_HELPER_RET(parcel, String, accesserHapSignature_, false); + READ_HELPER_RET(parcel, Uint32, accesserBindLevel_, false); + READ_HELPER_RET(parcel, String, accesserDeviceName_, false); + READ_HELPER_RET(parcel, String, accesserServiceName_, false); + READ_HELPER_RET(parcel, Int32, accesserCredentialId_, false); + READ_HELPER_RET(parcel, String, accesserCredentialIdStr_, false); + READ_HELPER_RET(parcel, Int32, accesserStatus_, false); + READ_HELPER_RET(parcel, Int32, accesserSessionKeyId_, false); + READ_HELPER_RET(parcel, Int64, accesserSKTimeStamp_, false); + READ_HELPER_RET(parcel, String, accesserExtraData_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS \ No newline at end of file diff --git a/common/src/interfaces/characteristic_profile.cpp b/common/src/interfaces/characteristic_profile.cpp index 13123602..abfedbc9 100644 --- a/common/src/interfaces/characteristic_profile.cpp +++ b/common/src/interfaces/characteristic_profile.cpp @@ -148,5 +148,42 @@ std::string CharacteristicProfile::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool CharacteristicProfile::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, deviceId_, false); + READ_HELPER_RET(parcel, String, serviceName_, false); + READ_HELPER_RET(parcel, String, characteristicKey_, false); + READ_HELPER_RET(parcel, String, characteristicValue_, false); + READ_HELPER_RET(parcel, Bool, isMultiUser_, false); + READ_HELPER_RET(parcel, Int32, userId_, false); + return true; +} + +CharacteristicProfile *CharacteristicProfile::Unmarshalling(Parcel &parcel) +{ + CharacteristicProfile *characteristicProfile = new (std::nothrow) CharacteristicProfile(); + if (characteristicProfile == nullptr) { + return nullptr; + } + + if (!characteristicProfile->ReadFromParcel(parcel)) { + delete characteristicProfile; + characteristicProfile = nullptr; + } + + return characteristicProfile; +} + +bool CharacteristicProfile::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, deviceId_, false); + WRITE_HELPER_RET(parcel, String, serviceName_, false); + WRITE_HELPER_RET(parcel, String, characteristicKey_, false); + WRITE_HELPER_RET(parcel, String, characteristicValue_, false); + WRITE_HELPER_RET(parcel, Bool, isMultiUser_, false); + WRITE_HELPER_RET(parcel, Int32, userId_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/device_icon_info.cpp b/common/src/interfaces/device_icon_info.cpp index 8587c3fc..187b2a21 100644 --- a/common/src/interfaces/device_icon_info.cpp +++ b/common/src/interfaces/device_icon_info.cpp @@ -198,5 +198,79 @@ std::string DeviceIconInfo::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool DeviceIconInfo::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, productId_, false); + READ_HELPER_RET(parcel, String, internalModel_, false); + READ_HELPER_RET(parcel, String, subProductId_, false); + READ_HELPER_RET(parcel, String, imageType_, false); + READ_HELPER_RET(parcel, String, specName_, false); + READ_HELPER_RET(parcel, String, version_, false); + READ_HELPER_RET(parcel, String, wiseVersion_, false); + READ_HELPER_RET(parcel, String, url_, false); + int32_t length = parcel.ReadInt32(); + if (length <= 0 || length > MAX_ICON_SIZE) { + HILOGE("uint8_t vector, params size is invalid! size : %{public}d", length); + return false; + } + + std::vector icon; + icon.reserve(length); + for (int32_t i = 0; i < length; ++i) { + uint8_t byte = 0; + if (!parcel.ReadUint8(byte)) { + HILOGE("ReadUint8 failed at index %{public}d", i); + return false; + } + icon.push_back(byte); + } + icon_ = icon; + return true; +} + +DeviceIconInfo *DeviceIconInfo::Unmarshalling(Parcel &parcel) +{ + DeviceIconInfo *deviceIconInfo = new (std::nothrow) DeviceIconInfo(); + if (deviceIconInfo == nullptr) { + return nullptr; + } + + if (!deviceIconInfo->ReadFromParcel(parcel)) { + delete deviceIconInfo; + deviceIconInfo = nullptr; + } + + return deviceIconInfo; +} + +bool DeviceIconInfo::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, productId_, false); + WRITE_HELPER_RET(parcel, String, internalModel_, false); + WRITE_HELPER_RET(parcel, String, subProductId_, false); + WRITE_HELPER_RET(parcel, String, imageType_, false); + WRITE_HELPER_RET(parcel, String, specName_, false); + WRITE_HELPER_RET(parcel, String, version_, false); + WRITE_HELPER_RET(parcel, String, wiseVersion_, false); + WRITE_HELPER_RET(parcel, String, url_, false); + int32_t length = static_cast(icon_.size()); + WRITE_HELPER_RET(parcel, Int32, length, false); + if (icon_.empty() || icon_.size() > MAX_ICON_SIZE) { + HILOGE("uint8_t vector, params size is invalid! size : %{public}zu", icon_.size()); + return false; + } + if (length > 0) { + const uint8_t* buffer = reinterpret_cast(icon_.data()); + for (int32_t i = 0; i < length; ++i) { + if (!parcel.WriteUint8(buffer[i])) { + HILOGE("WriteUint8 failed at index %{public}d", i); + return false; + } + } + } + + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/device_icon_info_filter_options.cpp b/common/src/interfaces/device_icon_info_filter_options.cpp index 2426a342..2e6468f4 100644 --- a/common/src/interfaces/device_icon_info_filter_options.cpp +++ b/common/src/interfaces/device_icon_info_filter_options.cpp @@ -142,5 +142,57 @@ std::string DeviceIconInfoFilterOptions::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool DeviceIconInfoFilterOptions::ReadFromParcel(Parcel &parcel) +{ + size_t size = parcel.ReadUint32(); + if (size == 0 || size > MAX_ID_SIZE) { + HILOGE("string vector, strings size is invalid!size : %{public}zu", size); + return false; + } + for (uint32_t i = 0; i < size; i++) { + std::string item = ""; + READ_HELPER_RET(parcel, String, item, false); + productIds_.emplace_back(item); + } + READ_HELPER_RET(parcel, String, internalModel_, false); + READ_HELPER_RET(parcel, String, subProductId_, false); + READ_HELPER_RET(parcel, String, imageType_, false); + READ_HELPER_RET(parcel, String, specName_, false); + return true; +} + +DeviceIconInfoFilterOptions *DeviceIconInfoFilterOptions::Unmarshalling(Parcel &parcel) +{ + DeviceIconInfoFilterOptions *deviceIconInfoFilterOptions = new (std::nothrow) DeviceIconInfoFilterOptions(); + if (deviceIconInfoFilterOptions == nullptr) { + return nullptr; + } + + if (!deviceIconInfoFilterOptions->ReadFromParcel(parcel)) { + delete deviceIconInfoFilterOptions; + deviceIconInfoFilterOptions = nullptr; + } + + return deviceIconInfoFilterOptions; +} + +bool DeviceIconInfoFilterOptions::Marshalling(Parcel& parcel) const +{ + size_t size = productIds_.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); + if (productIds_.empty() || productIds_.size() > MAX_ID_SIZE) { + HILOGE("string vector, strings size is invalid! size : %{public}zu", productIds_.size()); + return false; + } + for (const auto& item : productIds_) { + WRITE_HELPER_RET(parcel, String, item, false); + } + WRITE_HELPER_RET(parcel, String, internalModel_, false); + WRITE_HELPER_RET(parcel, String, subProductId_, false); + WRITE_HELPER_RET(parcel, String, imageType_, false); + WRITE_HELPER_RET(parcel, String, specName_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/device_profile.cpp b/common/src/interfaces/device_profile.cpp index c2d49df6..566aa1c2 100644 --- a/common/src/interfaces/device_profile.cpp +++ b/common/src/interfaces/device_profile.cpp @@ -544,5 +544,98 @@ std::string DeviceProfile::AnnoymizeDump() const cJSON_free(jsonChars); return jsonStr; } + +bool DeviceProfile::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, deviceId_, false); + READ_HELPER_RET(parcel, String, deviceName_, false); + READ_HELPER_RET(parcel, String, manufactureName_, false); + READ_HELPER_RET(parcel, String, deviceModel_, false); + READ_HELPER_RET(parcel, Int64, storageCapability_, false); + READ_HELPER_RET(parcel, String, osSysCap_, false); + READ_HELPER_RET(parcel, Int32, osApiLevel_, false); + READ_HELPER_RET(parcel, String, osVersion_, false); + READ_HELPER_RET(parcel, Int32, osType_, false); + READ_HELPER_RET(parcel, Bool, isMultiUser_, false); + READ_HELPER_RET(parcel, Int32, userId_, false); + READ_HELPER_RET(parcel, String, devType_, false); + READ_HELPER_RET(parcel, String, manu_, false); + READ_HELPER_RET(parcel, String, sn_, false); + READ_HELPER_RET(parcel, String, productId_, false); + READ_HELPER_RET(parcel, String, productName_, false); + READ_HELPER_RET(parcel, String, subProductId_, false); + READ_HELPER_RET(parcel, String, hiv_, false); + READ_HELPER_RET(parcel, String, mac_, false); + READ_HELPER_RET(parcel, String, fwv_, false); + READ_HELPER_RET(parcel, String, hwv_, false); + READ_HELPER_RET(parcel, String, swv_, false); + READ_HELPER_RET(parcel, Int32, protType_, false); + READ_HELPER_RET(parcel, String, wiseUserId_, false); + READ_HELPER_RET(parcel, String, wiseDeviceId_, false); + READ_HELPER_RET(parcel, String, registerTime_, false); + READ_HELPER_RET(parcel, String, modifyTime_, false); + READ_HELPER_RET(parcel, String, shareTime_, false); + READ_HELPER_RET(parcel, String, accountId_, false); + READ_HELPER_RET(parcel, String, internalModel_, false); + READ_HELPER_RET(parcel, String, bleMac_, false); + READ_HELPER_RET(parcel, String, brMac_, false); + READ_HELPER_RET(parcel, String, sleMac_, false); + READ_HELPER_RET(parcel, Int32, setupType_, false); + return true; +} + +DeviceProfile *DeviceProfile::Unmarshalling(Parcel &parcel) +{ + DeviceProfile *deviceProfile = new (std::nothrow) DeviceProfile(); + if (deviceProfile == nullptr) { + return nullptr; + } + + if (!deviceProfile->ReadFromParcel(parcel)) { + delete deviceProfile; + deviceProfile = nullptr; + } + + return deviceProfile; +} + +bool DeviceProfile::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, deviceId_, false); + WRITE_HELPER_RET(parcel, String, deviceName_, false); + WRITE_HELPER_RET(parcel, String, manufactureName_, false); + WRITE_HELPER_RET(parcel, String, deviceModel_, false); + WRITE_HELPER_RET(parcel, Int64, storageCapability_, false); + WRITE_HELPER_RET(parcel, String, osSysCap_, false); + WRITE_HELPER_RET(parcel, Int32, osApiLevel_, false); + WRITE_HELPER_RET(parcel, String, osVersion_, false); + WRITE_HELPER_RET(parcel, Int32, osType_, false); + WRITE_HELPER_RET(parcel, Bool, isMultiUser_, false); + WRITE_HELPER_RET(parcel, Int32, userId_, false); + WRITE_HELPER_RET(parcel, String, devType_, false); + WRITE_HELPER_RET(parcel, String, manu_, false); + WRITE_HELPER_RET(parcel, String, sn_, false); + WRITE_HELPER_RET(parcel, String, productId_, false); + WRITE_HELPER_RET(parcel, String, productName_, false); + WRITE_HELPER_RET(parcel, String, subProductId_, false); + WRITE_HELPER_RET(parcel, String, hiv_, false); + WRITE_HELPER_RET(parcel, String, mac_, false); + WRITE_HELPER_RET(parcel, String, fwv_, false); + WRITE_HELPER_RET(parcel, String, hwv_, false); + WRITE_HELPER_RET(parcel, String, swv_, false); + WRITE_HELPER_RET(parcel, Int32, protType_, false); + WRITE_HELPER_RET(parcel, String, wiseUserId_, false); + WRITE_HELPER_RET(parcel, String, wiseDeviceId_, false); + WRITE_HELPER_RET(parcel, String, registerTime_, false); + WRITE_HELPER_RET(parcel, String, modifyTime_, false); + WRITE_HELPER_RET(parcel, String, shareTime_, false); + WRITE_HELPER_RET(parcel, String, accountId_, false); + WRITE_HELPER_RET(parcel, String, internalModel_, false); + WRITE_HELPER_RET(parcel, String, bleMac_, false); + WRITE_HELPER_RET(parcel, String, brMac_, false); + WRITE_HELPER_RET(parcel, String, sleMac_, false); + WRITE_HELPER_RET(parcel, Int32, setupType_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/device_profile_filter_options.cpp b/common/src/interfaces/device_profile_filter_options.cpp index af1d1999..48db66cf 100644 --- a/common/src/interfaces/device_profile_filter_options.cpp +++ b/common/src/interfaces/device_profile_filter_options.cpp @@ -149,5 +149,99 @@ std::string DeviceProfileFilterOptions::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool DeviceProfileFilterOptions::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, Int32, userId_, false); + READ_HELPER_RET(parcel, String, accountId_, false); + + size_t size1 = parcel.ReadUint32(); + if (size1 == 0 || size1 > MAX_ID_SIZE) { + HILOGE("string vector, strings size is invalid!size : %{public}zu", size1); + return false; + } + for (uint32_t i = 0; i < size1; i++) { + std::string item = ""; + READ_HELPER_RET(parcel, String, item, false); + deviceIds_.emplace_back(item); + } + + size_t size2 = parcel.ReadUint32(); + if (size2 == 0 || size2 > MAX_ID_SIZE) { + HILOGE("string vector, strings size is invalid!size : %{public}zu", size2); + return false; + } + for (uint32_t i = 0; i < size2; i++) { + std::string item = ""; + READ_HELPER_RET(parcel, String, item, false); + wiseDeviceIds_.emplace_back(item); + } + + size_t size3 = parcel.ReadUint32(); + if (size3 == 0 || size3 > MAX_ID_SIZE) { + HILOGE("int32_t vector, params size is invalid! size : %{public}zu", size3); + return false; + } + for (uint32_t i = 0; i < size3; i++) { + int32_t item = 0; + READ_HELPER_RET(parcel, Int32, item, false); + deviceProfileIds_.emplace_back(item); + } + + return true; +} + +DeviceProfileFilterOptions *DeviceProfileFilterOptions::Unmarshalling(Parcel &parcel) +{ + DeviceProfileFilterOptions *deviceProfileFilterOptions = new (std::nothrow) DeviceProfileFilterOptions(); + if (deviceProfileFilterOptions == nullptr) { + return nullptr; + } + + if (!deviceProfileFilterOptions->ReadFromParcel(parcel)) { + delete deviceProfileFilterOptions; + deviceProfileFilterOptions = nullptr; + } + + return deviceProfileFilterOptions; +} + +bool DeviceProfileFilterOptions::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, Int32, userId_, false); + WRITE_HELPER_RET(parcel, String, accountId_, false); + + size_t size1 = deviceIds_.size(); + WRITE_HELPER_RET(parcel, Uint32, size1, false); + if (deviceIds_.empty() || deviceIds_.size() > MAX_ID_SIZE) { + HILOGE("string vector, strings size is invalid! size : %{public}zu", deviceIds_.size()); + return false; + } + for (const auto& item : deviceIds_) { + WRITE_HELPER_RET(parcel, String, item, false); + } + + size_t size2 = wiseDeviceIds_.size(); + WRITE_HELPER_RET(parcel, Uint32, size2, false); + if (wiseDeviceIds_.empty() || wiseDeviceIds_.size() > MAX_ID_SIZE) { + HILOGE("string vector, strings size is invalid! size : %{public}zu", wiseDeviceIds_.size()); + return false; + } + for (const auto& item : wiseDeviceIds_) { + WRITE_HELPER_RET(parcel, String, item, false); + } + + size_t size3 = deviceProfileIds_.size(); + WRITE_HELPER_RET(parcel, Uint32, size3, false); + if (deviceProfileIds_.empty() || deviceProfileIds_.size() > MAX_ID_SIZE) { + HILOGE("int32_t vector, params size is invalid! size : %{public}zu", deviceProfileIds_.size()); + return false; + } + for (const auto& item : deviceProfileIds_) { + WRITE_HELPER_RET(parcel, Int32, item, false); + } + + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/dp_inited_callback_proxy.cpp b/common/src/interfaces/dp_inited_callback_proxy.cpp index c318dc84..284b944e 100644 --- a/common/src/interfaces/dp_inited_callback_proxy.cpp +++ b/common/src/interfaces/dp_inited_callback_proxy.cpp @@ -16,7 +16,7 @@ #include "dp_inited_callback_proxy.h" #include "macro_utils.h" #include "distributed_device_profile_errors.h" -#include "i_distributed_device_profile.h" +#include "idistributed_device_profile.h" #include "message_parcel.h" namespace OHOS { diff --git a/common/src/interfaces/dp_subscribe_info.cpp b/common/src/interfaces/dp_subscribe_info.cpp index 78ee3554..9757a694 100644 --- a/common/src/interfaces/dp_subscribe_info.cpp +++ b/common/src/interfaces/dp_subscribe_info.cpp @@ -204,4 +204,3 @@ std::string SubscribeInfo::dump() const } } // namespace DistributedDeviceProfile } // namespace OHOS - diff --git a/common/src/interfaces/dp_subscribe_info_extension.cpp b/common/src/interfaces/dp_subscribe_info_extension.cpp new file mode 100644 index 00000000..b78087a1 --- /dev/null +++ b/common/src/interfaces/dp_subscribe_info_extension.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2023-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 "dp_subscribe_info_extension.h" +#include "cJSON.h" +#include "distributed_device_profile_constants.h" +#include "ipc_utils.h" +#include "macro_utils.h" +#include "profile_change_listener_stub.h" +#include "profile_utils.h" + +namespace OHOS { +namespace DistributedDeviceProfile { +namespace { + const std::string TAG = "SubscribeInfoExtension"; +} +SubscribeInfoExtension::SubscribeInfoExtension(int32_t saId, const std::string& subscribeKey, + std::unordered_set subscribeChangeTypes, + sptr profileChangeListener, + int32_t userId) +{ + this->saId_ = saId; + this->subscribeKey_ = subscribeKey; + if (userId != DEFAULT_USER_ID) { + this->subscribeKey_ = this->subscribeKey_ + SEPARATOR + std::to_string(userId); + } + this->subscribeChangeTypes_ = subscribeChangeTypes; + if (profileChangeListener == nullptr) { + HILOGI("constructor!"); + return; + } + if (profileChangeListener->AsObject() == nullptr) { + HILOGI("constructor!"); + return; + } + this->listener_ = profileChangeListener->AsObject(); +} + +SubscribeInfoExtension::SubscribeInfoExtension(const SubscribeInfo& subscribeInfo) +{ + this->saId_ = subscribeInfo.GetSaId(); + this->subscribeKey_ = subscribeInfo.GetSubscribeKey(); + this->subscribeChangeTypes_ = subscribeInfo.GetProfileChangeTypes(); + if (subscribeInfo.GetListener() == nullptr) { + HILOGI("constructor!"); + return; + } + this->listener_ = subscribeInfo.GetListener(); +} + +SubscribeInfoExtension::SubscribeInfoExtension() +{ +} + +SubscribeInfoExtension::~SubscribeInfoExtension() +{ +} + +bool SubscribeInfoExtension::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, Int32, saId_, false); + READ_HELPER_RET(parcel, String, subscribeKey_, false); + + uint32_t size = parcel.ReadUint32(); + if (size == 0 || size > MAX_SUBSCRIBE_CHANGE_SIZE) { + HILOGE("Params size is invalid! size: %{public}u", size); + return false; + } + for (uint32_t i = 0; i < size; ++i) { + uint32_t num = parcel.ReadUint32(); + if (num <= static_cast(ProfileChangeType::PROFILE_CHANGE_TYPE_MIN) || + num >= static_cast(ProfileChangeType::PROFILE_CHANGE_TYPE_MAX)) { + HILOGE("The value is invalid! index: %{public}u, value: %{public}u", i, num); + return false; + } + subscribeChangeTypes_.emplace(static_cast(num)); + } + + return true; +} + +SubscribeInfoExtension *SubscribeInfoExtension::Unmarshalling(Parcel &parcel) +{ + SubscribeInfoExtension *subscribeInfoExtension = new (std::nothrow) SubscribeInfoExtension(); + if (subscribeInfoExtension == nullptr) { + return nullptr; + } + + if (!subscribeInfoExtension->ReadFromParcel(parcel)) { + delete subscribeInfoExtension; + subscribeInfoExtension = nullptr; + } + + return subscribeInfoExtension; +} + +bool SubscribeInfoExtension::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, Int32, saId_, false); + WRITE_HELPER_RET(parcel, String, subscribeKey_, false); + + uint32_t size = subscribeChangeTypes_.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); + if (size == 0 || size > MAX_SUBSCRIBE_CHANGE_SIZE) { + HILOGE("changeTypes size is invalid! size: %{public}u", size); + return false; + } + for (ProfileChangeType item : subscribeChangeTypes_) { + WRITE_HELPER_RET(parcel, Int32, static_cast(item), false); + } + + WRITE_HELPER_RET(parcel, RemoteObject, listener_, false); + return true; +} +} +} \ No newline at end of file diff --git a/common/src/interfaces/dp_sync_options.cpp b/common/src/interfaces/dp_sync_options.cpp index 4d42d9fc..0a533af0 100644 --- a/common/src/interfaces/dp_sync_options.cpp +++ b/common/src/interfaces/dp_sync_options.cpp @@ -109,5 +109,48 @@ std::string DpSyncOptions::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool DpSyncOptions::ReadFromParcel(Parcel &parcel) +{ + int32_t mode = 0; + READ_HELPER_RET(parcel, Int32, mode, false); + syncMode_ = static_cast(mode); + int32_t size = 0; + READ_HELPER_RET(parcel, Int32, size, false); + if (size > MAX_DEVICE_SIZE) { + return false; + } + for (int32_t i = 0; i < size; i++) { + std::string deviceId; + READ_HELPER_RET(parcel, String, deviceId, false); + syncDeviceIds_.emplace_back(deviceId); + } + return true; +} + +DpSyncOptions *DpSyncOptions::Unmarshalling(Parcel &parcel) +{ + DpSyncOptions *dpSyncOptions = new (std::nothrow) DpSyncOptions(); + if (dpSyncOptions == nullptr) { + return nullptr; + } + + if (!dpSyncOptions->ReadFromParcel(parcel)) { + delete dpSyncOptions; + dpSyncOptions = nullptr; + } + + return dpSyncOptions; +} + +bool DpSyncOptions::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, Int32, static_cast(syncMode_), false); + WRITE_HELPER_RET(parcel, Int32, static_cast(syncDeviceIds_.size()), false); + for (const auto& deviceId : syncDeviceIds_) { + WRITE_HELPER_RET(parcel, String, deviceId, false); + } + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS \ No newline at end of file diff --git a/common/src/interfaces/local_service_info.cpp b/common/src/interfaces/local_service_info.cpp index ea1579b9..374df364 100644 --- a/common/src/interfaces/local_service_info.cpp +++ b/common/src/interfaces/local_service_info.cpp @@ -42,7 +42,7 @@ void LocalServiceInfo::SetBundleName(const std::string& bundleName) { bundleName_ = bundleName; } - + int32_t LocalServiceInfo::GetAuthBoxType() const { return authBoxType_; @@ -52,7 +52,7 @@ void LocalServiceInfo::SetAuthBoxType(const int32_t authBoxType) { authBoxType_ = authBoxType; } - + int32_t LocalServiceInfo::GetAuthType() const { return authType_; @@ -62,7 +62,7 @@ void LocalServiceInfo::SetAuthType(const int32_t authType) { authType_ = authType; } - + int32_t LocalServiceInfo::GetPinExchangeType() const { return pinExchangeType_; @@ -131,5 +131,44 @@ std::string LocalServiceInfo::dump() const { return ""; } + +bool LocalServiceInfo::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, bundleName_, false); + READ_HELPER_RET(parcel, Int32, authBoxType_, false); + READ_HELPER_RET(parcel, Int32, authType_, false); + READ_HELPER_RET(parcel, Int32, pinExchangeType_, false); + READ_HELPER_RET(parcel, String, pinCode_, false); + READ_HELPER_RET(parcel, String, description_, false); + READ_HELPER_RET(parcel, String, extraInfo_, false); + return true; +} + +LocalServiceInfo *LocalServiceInfo::Unmarshalling(Parcel &parcel) +{ + LocalServiceInfo *localServiceInfo = new (std::nothrow) LocalServiceInfo(); + if (localServiceInfo == nullptr) { + return nullptr; + } + + if (!localServiceInfo->ReadFromParcel(parcel)) { + delete localServiceInfo; + localServiceInfo = nullptr; + } + + return localServiceInfo; +} + +bool LocalServiceInfo::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, bundleName_, false); + WRITE_HELPER_RET(parcel, Int32, authBoxType_, false); + WRITE_HELPER_RET(parcel, Int32, authType_, false); + WRITE_HELPER_RET(parcel, Int32, pinExchangeType_, false); + WRITE_HELPER_RET(parcel, String, pinCode_, false); + WRITE_HELPER_RET(parcel, String, description_, false); + WRITE_HELPER_RET(parcel, String, extraInfo_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/pincode_invalid_callback_proxy.cpp b/common/src/interfaces/pincode_invalid_callback_proxy.cpp index 50c9255c..5925844b 100644 --- a/common/src/interfaces/pincode_invalid_callback_proxy.cpp +++ b/common/src/interfaces/pincode_invalid_callback_proxy.cpp @@ -16,7 +16,7 @@ #include "pincode_invalid_callback_proxy.h" #include "macro_utils.h" #include "distributed_device_profile_errors.h" -#include "i_distributed_device_profile.h" +#include "idistributed_device_profile.h" #include "message_parcel.h" namespace OHOS { diff --git a/common/src/interfaces/product_info.cpp b/common/src/interfaces/product_info.cpp index 324b94e8..fdcfb2bd 100644 --- a/common/src/interfaces/product_info.cpp +++ b/common/src/interfaces/product_info.cpp @@ -76,7 +76,6 @@ void ProductInfo::SetImageVersion(const std::string& imageVersion) this->imageVersion_ = imageVersion; } - bool ProductInfo::Marshalling(MessageParcel& parcel) const { WRITE_HELPER_RET(parcel, String, productId_, false); @@ -158,5 +157,40 @@ std::string ProductInfo::GetAnonyProductName(const std::string& productName) con cJSON_Delete(json); return jsonStr; } + +bool ProductInfo::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, productId_, false); + READ_HELPER_RET(parcel, String, model_, false); + READ_HELPER_RET(parcel, String, productName_, false); + READ_HELPER_RET(parcel, String, productShortName_, false); + READ_HELPER_RET(parcel, String, imageVersion_, false); + return true; +} + +ProductInfo *ProductInfo::Unmarshalling(Parcel &parcel) +{ + ProductInfo *productInfo = new (std::nothrow) ProductInfo(); + if (productInfo == nullptr) { + return nullptr; + } + + if (!productInfo->ReadFromParcel(parcel)) { + delete productInfo; + productInfo = nullptr; + } + + return productInfo; +} + +bool ProductInfo::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, productId_, false); + WRITE_HELPER_RET(parcel, String, model_, false); + WRITE_HELPER_RET(parcel, String, productName_, false); + WRITE_HELPER_RET(parcel, String, productShortName_, false); + WRITE_HELPER_RET(parcel, String, imageVersion_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/profile_change_listener_proxy.cpp b/common/src/interfaces/profile_change_listener_proxy.cpp index 740957ae..05d7f5d8 100644 --- a/common/src/interfaces/profile_change_listener_proxy.cpp +++ b/common/src/interfaces/profile_change_listener_proxy.cpp @@ -16,7 +16,7 @@ #include "profile_change_listener_proxy.h" #include "macro_utils.h" #include "distributed_device_profile_errors.h" -#include "i_distributed_device_profile.h" +#include "idistributed_device_profile.h" #include "message_parcel.h" namespace OHOS { diff --git a/common/src/interfaces/service_info_profile.cpp b/common/src/interfaces/service_info_profile.cpp index 9e126f86..64745cc2 100644 --- a/common/src/interfaces/service_info_profile.cpp +++ b/common/src/interfaces/service_info_profile.cpp @@ -74,7 +74,7 @@ void ServiceInfoProfile::SetTokenId(const std::string& tokenId) { tokenId_ = tokenId; } - + int64_t ServiceInfoProfile::GetServiceId() const { return serviceId_; @@ -99,12 +99,12 @@ std::string ServiceInfoProfile::GetServiceName() const { return serviceName_; } - + void ServiceInfoProfile::SetServiceName(const std::string& serviceName) { serviceName_ = serviceName; } - + std::string ServiceInfoProfile::GetServiceDisplayName() const { return serviceDisplayName_; @@ -124,7 +124,7 @@ void ServiceInfoProfile::SetCustomData(const std::string& customData) { customData_ = customData; } - + int32_t ServiceInfoProfile::GetCustomDataLen() const { return customDataLen_; @@ -164,7 +164,7 @@ void ServiceInfoProfile::SetAbilityName(const std::string& abilityName) { abilityName_ = abilityName; } - + int32_t ServiceInfoProfile::GetAuthBoxType() const { return authBoxType_; @@ -174,7 +174,7 @@ void ServiceInfoProfile::SetAuthBoxType(const int32_t authBoxType) { authBoxType_ = authBoxType; } - + int32_t ServiceInfoProfile::GetAuthType() const { return authType_; @@ -184,7 +184,7 @@ void ServiceInfoProfile::SetAuthType(const int32_t authType) { authType_ = authType; } - + int32_t ServiceInfoProfile::GetPinExchangeType() const { return pinExchangeType_; @@ -214,12 +214,12 @@ void ServiceInfoProfile::SetDescription(const std::string& description) { description_ = description; } - + std::string ServiceInfoProfile::GetServiceDicoveryScope() const { return serviceDicoveryScope_; } - + void ServiceInfoProfile::SetServiceDicoveryScope(const std::string& serviceDicoveryScope) { serviceDicoveryScope_ = serviceDicoveryScope; @@ -289,5 +289,70 @@ std::string ServiceInfoProfile::dump() const { return ""; } + +bool ServiceInfoProfile::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, deviceId_, false); + READ_HELPER_RET(parcel, Int32, userId_, false); + READ_HELPER_RET(parcel, String, networkId_, false); + READ_HELPER_RET(parcel, String, tokenId_, false); + READ_HELPER_RET(parcel, Int64, serviceId_, false); + READ_HELPER_RET(parcel, String, serviceType_, false); + READ_HELPER_RET(parcel, String, serviceName_, false); + READ_HELPER_RET(parcel, String, serviceDisplayName_, false); + READ_HELPER_RET(parcel, String, customData_, false); + READ_HELPER_RET(parcel, Int32, customDataLen_, false); + READ_HELPER_RET(parcel, String, bundleName_, false); + READ_HELPER_RET(parcel, String, moduleName_, false); + READ_HELPER_RET(parcel, String, abilityName_, false); + READ_HELPER_RET(parcel, Int32, authBoxType_, false); + READ_HELPER_RET(parcel, Int32, authType_, false); + READ_HELPER_RET(parcel, Int32, pinExchangeType_, false); + READ_HELPER_RET(parcel, String, pinCode_, false); + READ_HELPER_RET(parcel, String, description_, false); + READ_HELPER_RET(parcel, String, serviceDicoveryScope_, false); + READ_HELPER_RET(parcel, String, extraInfo_, false); + return true; +} + +ServiceInfoProfile *ServiceInfoProfile::Unmarshalling(Parcel &parcel) +{ + ServiceInfoProfile *serviceInfoProfile = new (std::nothrow) ServiceInfoProfile(); + if (serviceInfoProfile == nullptr) { + return nullptr; + } + + if (!serviceInfoProfile->ReadFromParcel(parcel)) { + delete serviceInfoProfile; + serviceInfoProfile = nullptr; + } + + return serviceInfoProfile; +} + +bool ServiceInfoProfile::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, deviceId_, false); + WRITE_HELPER_RET(parcel, Int32, userId_, false); + WRITE_HELPER_RET(parcel, String, networkId_, false); + WRITE_HELPER_RET(parcel, String, tokenId_, false); + WRITE_HELPER_RET(parcel, Int64, serviceId_, false); + WRITE_HELPER_RET(parcel, String, serviceType_, false); + WRITE_HELPER_RET(parcel, String, serviceName_, false); + WRITE_HELPER_RET(parcel, String, serviceDisplayName_, false); + WRITE_HELPER_RET(parcel, String, customData_, false); + WRITE_HELPER_RET(parcel, Int32, customDataLen_, false); + WRITE_HELPER_RET(parcel, String, bundleName_, false); + WRITE_HELPER_RET(parcel, String, moduleName_, false); + WRITE_HELPER_RET(parcel, String, abilityName_, false); + WRITE_HELPER_RET(parcel, Int32, authBoxType_, false); + WRITE_HELPER_RET(parcel, Int32, authType_, false); + WRITE_HELPER_RET(parcel, Int32, pinExchangeType_, false); + WRITE_HELPER_RET(parcel, String, pinCode_, false); + WRITE_HELPER_RET(parcel, String, description_, false); + WRITE_HELPER_RET(parcel, String, serviceDicoveryScope_, false); + WRITE_HELPER_RET(parcel, String, extraInfo_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/service_info_unique_key.cpp b/common/src/interfaces/service_info_unique_key.cpp index 9e46fef4..e796a458 100644 --- a/common/src/interfaces/service_info_unique_key.cpp +++ b/common/src/interfaces/service_info_unique_key.cpp @@ -61,7 +61,7 @@ void ServiceInfoUniqueKey::SetTokenId(const std::string& tokenId) { tokenId_ = tokenId; } - + int64_t ServiceInfoUniqueKey::GetServiceId() const { return serviceId_; @@ -111,5 +111,40 @@ std::string ServiceInfoUniqueKey::dump() const { return ""; } + +bool ServiceInfoUniqueKey::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, deviceId_, false); + READ_HELPER_RET(parcel, Int32, userId_, false); + READ_HELPER_RET(parcel, String, tokenId_, false); + READ_HELPER_RET(parcel, Int64, serviceId_, false); + READ_HELPER_RET(parcel, String, bundleName_, false); + return true; +} + +ServiceInfoUniqueKey *ServiceInfoUniqueKey::Unmarshalling(Parcel &parcel) +{ + ServiceInfoUniqueKey *serviceInfoUniqueKey = new (std::nothrow) ServiceInfoUniqueKey(); + if (serviceInfoUniqueKey == nullptr) { + return nullptr; + } + + if (!serviceInfoUniqueKey->ReadFromParcel(parcel)) { + delete serviceInfoUniqueKey; + serviceInfoUniqueKey = nullptr; + } + + return serviceInfoUniqueKey; +} + +bool ServiceInfoUniqueKey::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, deviceId_, false); + WRITE_HELPER_RET(parcel, Int32, userId_, false); + WRITE_HELPER_RET(parcel, String, tokenId_, false); + WRITE_HELPER_RET(parcel, Int64, serviceId_, false); + WRITE_HELPER_RET(parcel, String, bundleName_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/service_profile.cpp b/common/src/interfaces/service_profile.cpp index d4bc2272..f30be63e 100644 --- a/common/src/interfaces/service_profile.cpp +++ b/common/src/interfaces/service_profile.cpp @@ -148,5 +148,40 @@ std::string ServiceProfile::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool ServiceProfile::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, deviceId_, false); + READ_HELPER_RET(parcel, String, serviceName_, false); + READ_HELPER_RET(parcel, String, serviceType_, false); + READ_HELPER_RET(parcel, Bool, isMultiUser_, false); + READ_HELPER_RET(parcel, Int32, userId_, false); + return true; +} + +ServiceProfile *ServiceProfile::Unmarshalling(Parcel &parcel) +{ + ServiceProfile *serviceProfile = new (std::nothrow) ServiceProfile(); + if (serviceProfile == nullptr) { + return nullptr; + } + + if (!serviceProfile->ReadFromParcel(parcel)) { + delete serviceProfile; + serviceProfile = nullptr; + } + + return serviceProfile; +} + +bool ServiceProfile::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, deviceId_, false); + WRITE_HELPER_RET(parcel, String, serviceName_, false); + WRITE_HELPER_RET(parcel, String, serviceType_, false); + WRITE_HELPER_RET(parcel, Bool, isMultiUser_, false); + WRITE_HELPER_RET(parcel, Int32, userId_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/trust_device_profile.cpp b/common/src/interfaces/trust_device_profile.cpp index 75521705..a968bf15 100644 --- a/common/src/interfaces/trust_device_profile.cpp +++ b/common/src/interfaces/trust_device_profile.cpp @@ -145,5 +145,44 @@ std::string TrustDeviceProfile::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool TrustDeviceProfile::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, deviceId_, false); + READ_HELPER_RET(parcel, Uint32, deviceIdType_, false); + READ_HELPER_RET(parcel, String, deviceIdHash_, false); + READ_HELPER_RET(parcel, Int32, status_, false); + READ_HELPER_RET(parcel, Uint32, bindType_, false); + READ_HELPER_RET(parcel, Int32, peerUserId_, false); + READ_HELPER_RET(parcel, Int32, localUserId_, false); + return true; +} + +TrustDeviceProfile *TrustDeviceProfile::Unmarshalling(Parcel &parcel) +{ + TrustDeviceProfile *trustDeviceProfile = new (std::nothrow) TrustDeviceProfile(); + if (trustDeviceProfile == nullptr) { + return nullptr; + } + + if (!trustDeviceProfile->ReadFromParcel(parcel)) { + delete trustDeviceProfile; + trustDeviceProfile = nullptr; + } + + return trustDeviceProfile; +} + +bool TrustDeviceProfile::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, deviceId_, false); + WRITE_HELPER_RET(parcel, Uint32, deviceIdType_, false); + WRITE_HELPER_RET(parcel, String, deviceIdHash_, false); + WRITE_HELPER_RET(parcel, Int32, status_, false); + WRITE_HELPER_RET(parcel, Uint32, bindType_, false); + WRITE_HELPER_RET(parcel, Int32, peerUserId_, false); + WRITE_HELPER_RET(parcel, Int32, localUserId_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS \ No newline at end of file diff --git a/common/src/interfaces/trusted_device_info.cpp b/common/src/interfaces/trusted_device_info.cpp index cb3059f2..3941f9b8 100644 --- a/common/src/interfaces/trusted_device_info.cpp +++ b/common/src/interfaces/trusted_device_info.cpp @@ -175,5 +175,44 @@ std::string TrustedDeviceInfo::dump() const cJSON_free(jsonChars); return jsonStr; } + +bool TrustedDeviceInfo::ReadFromParcel(Parcel &parcel) +{ + READ_HELPER_RET(parcel, String, networkId_, false); + READ_HELPER_RET(parcel, Int32, authForm_, false); + READ_HELPER_RET(parcel, Uint16, deviceTypeId_, false); + READ_HELPER_RET(parcel, String, osVersion_, false); + READ_HELPER_RET(parcel, Int32, osType_, false); + READ_HELPER_RET(parcel, String, udid_, false); + READ_HELPER_RET(parcel, String, uuid_, false); + return true; +} + +TrustedDeviceInfo *TrustedDeviceInfo::Unmarshalling(Parcel &parcel) +{ + TrustedDeviceInfo *trustedDeviceInfo = new (std::nothrow) TrustedDeviceInfo(); + if (trustedDeviceInfo == nullptr) { + return nullptr; + } + + if (!trustedDeviceInfo->ReadFromParcel(parcel)) { + delete trustedDeviceInfo; + trustedDeviceInfo = nullptr; + } + + return trustedDeviceInfo; +} + +bool TrustedDeviceInfo::Marshalling(Parcel& parcel) const +{ + WRITE_HELPER_RET(parcel, String, networkId_, false); + WRITE_HELPER_RET(parcel, Int32, authForm_, false); + WRITE_HELPER_RET(parcel, Uint16, deviceTypeId_, false); + WRITE_HELPER_RET(parcel, String, osVersion_, false); + WRITE_HELPER_RET(parcel, Int32, osType_, false); + WRITE_HELPER_RET(parcel, String, udid_, false); + WRITE_HELPER_RET(parcel, String, uuid_, false); + return true; +} } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/utils/ipc_utils.cpp b/common/src/utils/ipc_utils.cpp index 78a259bd..b0d1d1d4 100644 --- a/common/src/utils/ipc_utils.cpp +++ b/common/src/utils/ipc_utils.cpp @@ -15,6 +15,7 @@ #include "ipc_utils.h" #include "dp_subscribe_info.h" +#include "dp_subscribe_info_extension.h" #include "macro_utils.h" namespace OHOS { diff --git a/interfaces/innerkits/core/BUILD.gn b/interfaces/innerkits/core/BUILD.gn index 8af56923..5e791296 100644 --- a/interfaces/innerkits/core/BUILD.gn +++ b/interfaces/innerkits/core/BUILD.gn @@ -14,16 +14,64 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") import("//foundation/deviceprofile/device_info_manager/deviceprofile.gni") +import("//build/config/components/idl_tool/idl.gni") + +idl_gen_interface("distributed_device_profile_interfaces_gn") { + sources=["IDistributedDeviceProfile.idl"] + hitrace = "HITRACE_TAG_DEVICE_PROFILE" + log_domainid = "0xD004400" + log_tag = "Distributed_Device_Profile" +} + +config("distributed_device_profile_interfaces_ipc_config"){ + include_dirs = [ + ".", + "${target_gen_dir}/", + ] +} + +ohos_source_set("distributed_device_profile_interfaces_ipc") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + + output_values = get_target_outputs(":distributed_device_profile_interfaces_gn") + sources = [] + sources += filter_include(output_values, [ "*.cpp" ]) + configs = [ + ":distributed_device_profile_interfaces_ipc_config" + ] + include_dirs = [ + "${device_profile_common}/include/constants", + "${device_profile_common}/include/interfaces", + "${device_profile_common}/include/utils", + ] + deps = [ ":distributed_device_profile_interfaces_gn",] + external_deps = [ + "cJSON:cjson", + "c_utils:utils", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + part_name = "device_info_manager" + subsystem_name = "deviceprofile" +} config("distributed_device_profile_sdk_config") { visibility = [ ":*" ] include_dirs = [ "include", "include/callback", + "${device_profile_path}/radar/include", "${device_profile_common}/include/constants", "${device_profile_common}/include/interfaces", "${device_profile_common}/include/utils", - "${device_profile_path}/radar/include", ] } @@ -54,14 +102,18 @@ ohos_shared_library("distributed_device_profile_sdk") { sources = [ "src/callback/device_profile_load_callback.cpp", "src/distributed_device_profile_client.cpp", - "src/distributed_device_profile_proxy.cpp", ] - public_configs = [ ":distributed_device_profile_sdk_config" ] + configs = [ ":distributed_device_profile_interfaces_ipc_config", ] + + public_configs = [ + ":distributed_device_profile_sdk_config", + ] deps = [ "${device_profile_common}:distributed_device_profile_common", "${device_profile_path}/radar:device_profile_radar", + ":distributed_device_profile_interfaces_ipc", ] external_deps = [ diff --git a/interfaces/innerkits/core/IDistributedDeviceProfile.idl b/interfaces/innerkits/core/IDistributedDeviceProfile.idl new file mode 100644 index 00000000..6aac8138 --- /dev/null +++ b/interfaces/innerkits/core/IDistributedDeviceProfile.idl @@ -0,0 +1,92 @@ +/* + * 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 OHOS.DistributedDeviceProfile.TrustDeviceProfile; +sequenceable OHOS.DistributedDeviceProfile.DeviceProfile; +sequenceable OHOS.DistributedDeviceProfile.ServiceProfile; +sequenceable OHOS.DistributedDeviceProfile.CharacteristicProfile; +sequenceable OHOS.DistributedDeviceProfile.AccessControlProfile; +sequenceable dp_subscribe_info_extension..OHOS.DistributedDeviceProfile.SubscribeInfoExtension; +sequenceable dp_sync_options..OHOS.DistributedDeviceProfile.DpSyncOptions; +sequenceable OHOS.DistributedDeviceProfile.TrustedDeviceInfo; +sequenceable OHOS.DistributedDeviceProfile.DeviceProfileFilterOptions; +sequenceable OHOS.DistributedDeviceProfile.ProductInfo; +sequenceable OHOS.DistributedDeviceProfile.DeviceIconInfo; +sequenceable OHOS.DistributedDeviceProfile.DeviceIconInfoFilterOptions; +sequenceable OHOS.IRemoteObject; +sequenceable OHOS.DistributedDeviceProfile.ServiceInfoProfile; +sequenceable OHOS.DistributedDeviceProfile.ServiceInfoUniqueKey; +sequenceable OHOS.DistributedDeviceProfile.LocalServiceInfo; + +interface OHOS.DistributedDeviceProfile.IDistributedDeviceProfile { + [ipccode 7] void PutAccessControlProfile([in] AccessControlProfile aclProfile); + [ipccode 8] void UpdateAccessControlProfile([in] AccessControlProfile aclProfile); + [ipccode 9] void GetTrustDeviceProfile([in] String deviceId, [out] TrustDeviceProfile trustDeviceProfile); + [ipccode 10] void GetAllTrustDeviceProfile([out] TrustDeviceProfile[] trustDeviceProfiles); + [ipccode 11] void GetAccessControlProfile([out] OrderedMap queryParams, + [out] AccessControlProfile[] accessControlProfiles); + [ipccode 12] void GetAllAccessControlProfile([out] AccessControlProfile[] accessControlProfiles); + [ipccode 13] void DeleteAccessControlProfile([in] int accessControlId); + [ipccode 46] void PutDeviceProfileBatch([out] DeviceProfile[] deviceProfiles); + [ipccode 14] void PutServiceProfile([in] ServiceProfile serviceProfile); + [ipccode 15] void PutServiceProfileBatch([in] ServiceProfile[] serviceProfiles); + [ipccode 16] void PutCharacteristicProfile([in] CharacteristicProfile charProfile); + [ipccode 17] void PutCharacteristicProfileBatch([in] CharacteristicProfile[] charProfiles); + [ipccode 18] void GetDeviceProfile([in] String deviceId, [out] DeviceProfile deviceProfile); + [ipccode 47] void GetDeviceProfiles([out] DeviceProfileFilterOptions options,[out] DeviceProfile[] deviceProfiles); + [ipccode 51] void DeleteDeviceProfileBatch([out] DeviceProfile[] deviceProfiles); + [ipccode 19] void GetServiceProfile([in] String deviceId, [in] String serviceName, + [out] ServiceProfile serviceProfile); + [ipccode 20] void GetCharacteristicProfile([in] String deviceId, [in] String serviceName, + [in] String characteristicId, [out] CharacteristicProfile charProfile); + [ipccode 21] void DeleteServiceProfile([in] String deviceId, [in] String serviceName, + [in] boolean isMultiUser, [in] int userId); + [ipccode 22] void DeleteCharacteristicProfile([in] String deviceId, [in] String serviceName, + [in] String characteristicId, [in] boolean isMultiUser, [in] int userId); + [ipccode 23] void SubscribeDeviceProfile([in] SubscribeInfoExtension subscribeInfoExtension); + [ipccode 24] void UnSubscribeDeviceProfile([in] SubscribeInfoExtension subscribeInfoExtension); + [ipccode 41] void SubscribeDeviceProfileInited([in] int saId, [in] IRemoteObject dpInitedCallback); + [ipccode 42] void UnSubscribeDeviceProfileInited([in] int saId); + [ipccode 25] void SyncDeviceProfile([in] DpSyncOptions syncOptions, + [in] IRemoteObject syncCompletedCallback); + [ipccode 26] void SendSubscribeInfos([out] OrderedMap listenerMap); + [ipccode 45] void PutAllTrustedDevices([in] TrustedDeviceInfo[] deviceInfos); + [ipccode 50] void PutProductInfoBatch([in] ProductInfo[] productInfos); + [ipccode 49] void PutDeviceIconInfoBatch([in] DeviceIconInfo[] deviceIconInfos); + [ipccode 48] void GetDeviceIconInfos([in] DeviceIconInfoFilterOptions filterOptions,[out] DeviceIconInfo[] deviceIconInfos); + [ipccode 59] void PutSessionKey([in] unsigned int userId, [in] unsigned char[] sessionKey, [out] int sessionKeyId); + [ipccode 60] void GetSessionKey([in] unsigned int userId, [in] int sessionKeyId, [out] unsigned char[] sessionKey); + [ipccode 61] void UpdateSessionKey([in] unsigned int userId, [in] int sessionKeyId, [in] unsigned char[] sessionKey); + [ipccode 62] void DeleteSessionKey([in] unsigned int userId, [in] int sessionKeyId); + [ipccode 64] void SubscribePinCodeInvalid([in] String bundleName, [in] int pinExchangeType, + [in] IRemoteObject pinCodeCallback); + [ipccode 65] void UnSubscribePinCodeInvalid([in] String bundleName, [in] int pinExchangeType); + [ipccode 52] void PutServiceInfoProfile([in] ServiceInfoProfile serviceInfoProfile); + [ipccode 53] void DeleteServiceInfoProfile([in] ServiceInfoUniqueKey key); + [ipccode 54] void UpdateServiceInfoProfile([in] ServiceInfoProfile serviceInfoProfile); + [ipccode 55] void GetServiceInfoProfileByUniqueKey([in] ServiceInfoUniqueKey key, + [inout] ServiceInfoProfile serviceInfoProfile); + [ipccode 56] void GetServiceInfoProfileListByTokenId([in]ServiceInfoUniqueKey key, + [out] ServiceInfoProfile[] serviceInfoProfiles); + [ipccode 57] void GetAllServiceInfoProfileList([out] ServiceInfoProfile[] serviceInfoProfiles); + [ipccode 58] void GetServiceInfoProfileListByBundleName([in] ServiceInfoUniqueKey key, + [out] ServiceInfoProfile[] serviceInfoProfiles); + [ipccode 66] void PutLocalServiceInfo([in] LocalServiceInfo localServiceInfo); + [ipccode 67] void UpdateLocalServiceInfo([in] LocalServiceInfo localServiceInfo); + [ipccode 68] void GetLocalServiceInfoByBundleAndPinType([in] String bundleName, + [in] int pinExchangeType, [out] LocalServiceInfo localServiceInfo); + [ipccode 69] void DeleteLocalServiceInfo([in] String bundleName,[in] int pinExchangeType); + [ipccode 70] void GetAllAclIncludeLnnAcl([out] AccessControlProfile[] accessControlProfiles); +} \ No newline at end of file diff --git a/interfaces/innerkits/core/include/distributed_device_profile_client.h b/interfaces/innerkits/core/include/distributed_device_profile_client.h index c9616d28..42251245 100644 --- a/interfaces/innerkits/core/include/distributed_device_profile_client.h +++ b/interfaces/innerkits/core/include/distributed_device_profile_client.h @@ -27,12 +27,13 @@ #include #include "i_pincode_invalid_callback.h" #include "i_profile_change_listener.h" -#include "i_distributed_device_profile.h" +#include "idistributed_device_profile.h" #include "i_dp_inited_callback.h" #include "iremote_object.h" #include "refbase.h" #include "single_instance.h" #include "dp_subscribe_info.h" +#include "dp_subscribe_info_extension.h" #include "distributed_device_profile_constants.h" #include "sync_completed_callback_stub.h" #include "system_ability_status_change_stub.h" @@ -149,6 +150,7 @@ private: std::mutex subscribeLock_; std::map subscribeInfos_; + std::map subscribeInfoExtensions_; std::mutex saListenerLock_; sptr saListenerCallback_ = nullptr; diff --git a/interfaces/innerkits/core/include/distributed_device_profile_proxy.h b/interfaces/innerkits/core/include/distributed_device_profile_proxy.h deleted file mode 100644 index 103d478d..00000000 --- a/interfaces/innerkits/core/include/distributed_device_profile_proxy.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2023-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_DP_DISTRIBUTED_DEVICE_PROFILE_PROXY_H -#define OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_PROXY_H - -#include -#include -#include -#include - -#include "i_distributed_device_profile.h" -#include "i_dp_inited_callback.h" -#include "iremote_broker.h" -#include "iremote_proxy.h" -#include "refbase.h" -#include "distributed_device_profile_enums.h" -#include "distributed_device_profile_errors.h" -#include "ipc_utils.h" -#include "profile_change_listener_stub.h" - -namespace OHOS { -namespace DistributedDeviceProfile { -class DistributedDeviceProfileProxy : public IRemoteProxy { -public: - explicit DistributedDeviceProfileProxy(const sptr& impl) - : IRemoteProxy(impl) {} - ~DistributedDeviceProfileProxy() {} - - int32_t PutAccessControlProfile(const AccessControlProfile& aclProfile) override; - int32_t UpdateAccessControlProfile(const AccessControlProfile& aclProfile) override; - int32_t GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile) override; - int32_t GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles) override; - int32_t GetAccessControlProfile(std::map queryParams, - std::vector& accessControlProfiles) override; - int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) override; - int32_t GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles) override; - int32_t DeleteAccessControlProfile(int32_t accessControlId) override; - int32_t PutSessionKey(uint32_t userId, const std::vector& sessionKey, int32_t& sessionKeyId) override; - int32_t GetSessionKey(uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey) override; - int32_t UpdateSessionKey(uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey) override; - int32_t DeleteSessionKey(uint32_t userId, int32_t sessionKeyId) override; - int32_t PutDeviceProfileBatch(std::vector& deviceProfiles) override; - int32_t PutServiceProfile(const ServiceProfile& serviceProfile) override; - int32_t PutServiceProfileBatch(const std::vector& serviceProfiles) override; - int32_t PutCharacteristicProfile(const CharacteristicProfile& charProfile) override; - int32_t PutCharacteristicProfileBatch(const std::vector& charProfiles) override; - int32_t GetDeviceProfile(const std::string& deviceId, DeviceProfile& deviceProfile) override; - int32_t GetDeviceProfiles(DeviceProfileFilterOptions& options, - std::vector& deviceProfiles) override; - int32_t DeleteDeviceProfileBatch(std::vector& deviceProfiles) override; - int32_t GetServiceProfile(const std::string& deviceId, const std::string& serviceName, - ServiceProfile& serviceProfile) override; - int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, - const std::string& characteristicId, CharacteristicProfile& charProfile) override; - int32_t DeleteServiceProfile(const std::string& deviceId, const std::string& serviceName, bool isMultiUser = false, - int32_t userId = DEFAULT_USER_ID) override; - int32_t DeleteCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, - const std::string& characteristicId, bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID) override; - int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; - int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; - int32_t SubscribeDeviceProfileInited(int32_t saId, sptr dpInitedCallback) override; - int32_t UnSubscribeDeviceProfileInited(int32_t saId) override; - int32_t SubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType, - sptr pinCodeCallback) override; - int32_t UnSubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType) override; - int32_t SyncDeviceProfile(const DpSyncOptions& syncOptions, sptr syncCompletedCallback) override; - int32_t SendSubscribeInfos(std::map listenerMap) override; - int32_t PutAllTrustedDevices(const std::vector deviceInfos) override; - int32_t PutProductInfoBatch(const std::vector& productInfos) override; - int32_t PutDeviceIconInfoBatch(const std::vector& deviceIconInfos) override; - int32_t GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, - std::vector& deviceIconInfos) override; - int32_t PutServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) override; - int32_t DeleteServiceInfoProfile(const ServiceInfoUniqueKey& key) override; - int32_t UpdateServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) override; - int32_t GetServiceInfoProfileByUniqueKey(const ServiceInfoUniqueKey& key, - ServiceInfoProfile& serviceInfoProfile) override; - int32_t GetServiceInfoProfileListByTokenId(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) override; - int32_t GetAllServiceInfoProfileList(std::vector& serviceInfoProfiles) override; - int32_t GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) override; - int32_t PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo) override; - int32_t UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo) override; - int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, - int32_t pinExchangeType, LocalServiceInfo& localServiceInfo) override; - int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace DeviceProfile -} // namespace OHOS -#endif // OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_PROXY_H diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index ed603963..a3de6fe0 100644 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -33,7 +33,7 @@ #include "dp_radar_helper.h" #include "event_handler.h" #include "event_runner.h" -#include "i_distributed_device_profile.h" +#include "idistributed_device_profile.h" #include "if_system_ability_manager.h" #include "ipc_skeleton.h" #include "iremote_broker.h" @@ -123,7 +123,13 @@ void DistributedDeviceProfileClient::SendSubscribeInfosToService() HILOGE("SubscribeInfos size is invalid!size: %{public}zu!", subscribeInfos_.size()); return; } - dpService->SendSubscribeInfos(subscribeInfos_); + + subscribeInfoExtensions_.clear(); + for (const auto& subscribeInfo : subscribeInfos_) { + SubscribeInfoExtension subscribeInfoExtension(subscribeInfo.second); + subscribeInfoExtensions_.insert(std::make_pair(subscribeInfo.first, subscribeInfoExtension)); + } + dpService->SendSubscribeInfos(subscribeInfoExtensions_); } } diff --git a/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp b/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp deleted file mode 100644 index 96f09af2..00000000 --- a/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp +++ /dev/null @@ -1,789 +0,0 @@ -/* - * Copyright (c) 2021-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 "distributed_device_profile_proxy.h" - -namespace OHOS { -namespace DistributedDeviceProfile { -namespace { - const std::string TAG = "DistributedDeviceProfileProxy"; -} - -int32_t DistributedDeviceProfileProxy::PutAccessControlProfile(const AccessControlProfile& aclProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!aclProfile.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_ACL_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::UpdateAccessControlProfile(const AccessControlProfile& aclProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!aclProfile.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::UPDATE_ACL_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutProductInfoBatch(const std::vector& productInfos) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, productInfos)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_PRODUCT_INFO_BATCH), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutDeviceIconInfoBatch(const std::vector& deviceIconInfos) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, deviceIconInfos)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_DEVICE_ICON_INFO_BATCH), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, - std::vector& deviceIconInfos) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!filterOptions.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_DEVICE_ICON_INFOS), data, reply); - if (!IpcUtils::UnMarshalling(reply, deviceIconInfos)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetTrustDeviceProfile(const std::string& deviceId, - TrustDeviceProfile& trustDeviceProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, deviceId); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_TRUST_DEVICE_PROFILE), data, reply); - if (!trustDeviceProfile.UnMarshalling(reply)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_ALL_TRUST_DEVICE_PROFILE), data, reply); - if (!IpcUtils::UnMarshalling(reply, trustDeviceProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetAccessControlProfile(std::map queryParams, - std::vector& accessControlProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, queryParams)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_ACL_PROFILE), data, reply); - if (!IpcUtils::UnMarshalling(reply, accessControlProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetAllAccessControlProfile( - std::vector& accessControlProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_ALL_ACL_PROFILE), data, reply); - if (!IpcUtils::UnMarshalling(reply, accessControlProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_ALL_ACL_INCLUDE_LNN_ACL), data, reply); - if (!IpcUtils::UnMarshalling(reply, accessControlProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::DeleteAccessControlProfile(int32_t accessControlId) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, Int32, accessControlId); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::DELETE_ACL_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutSessionKey( - uint32_t userId, const std::vector& sessionKey, int32_t& sessionKeyId) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, Uint32, userId); - if (!IpcUtils::Marshalling(data, sessionKey)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_SESSION_KEY), data, reply); - READ_HELPER(reply, Int32, sessionKeyId); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetSessionKey( - uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, Uint32, userId); - WRITE_HELPER(data, Int32, sessionKeyId); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_SESSION_KEY), data, reply); - if (!IpcUtils::UnMarshalling(reply, sessionKey)) { - HILOGE("dp ipc read parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::UpdateSessionKey( - uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, Uint32, userId); - WRITE_HELPER(data, Int32, sessionKeyId); - if (!IpcUtils::Marshalling(data, sessionKey)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::UPDATE_SESSION_KEY), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::DeleteSessionKey(uint32_t userId, int32_t sessionKeyId) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, Uint32, userId); - WRITE_HELPER(data, Int32, sessionKeyId); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::DELETE_SESSION_KEY), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutDeviceProfileBatch(std::vector& deviceProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, deviceProfiles)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_DEVICE_PROFILE_BATCH), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutServiceProfile(const ServiceProfile& serviceProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!serviceProfile.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutServiceProfileBatch(const std::vector& serviceProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, serviceProfiles)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE_BATCH), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutCharacteristicProfile(const CharacteristicProfile& charProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!charProfile.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_CHAR_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutCharacteristicProfileBatch( - const std::vector& charProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, charProfiles)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_CHAR_PROFILE_BATCH), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetDeviceProfile(const std::string& deviceId, DeviceProfile& deviceProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, deviceId); - WRITE_HELPER(data, Bool, deviceProfile.IsMultiUser()); - WRITE_HELPER(data, Int32, deviceProfile.GetUserId()); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_DEVICE_PROFILE_NEW), data, reply); - if (!deviceProfile.UnMarshalling(reply)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetDeviceProfiles(DeviceProfileFilterOptions& options, - std::vector& deviceProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!options.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_DEVICE_PROFILES), data, reply); - if (!IpcUtils::UnMarshalling(reply, deviceProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::DeleteDeviceProfileBatch(std::vector& deviceProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, deviceProfiles)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::DELETE_DEVICE_PROFILE_BATCH), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetServiceProfile(const std::string& deviceId, const std::string& serviceName, - ServiceProfile& serviceProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, deviceId); - WRITE_HELPER(data, String, serviceName); - WRITE_HELPER(data, Bool, serviceProfile.IsMultiUser()); - WRITE_HELPER(data, Int32, serviceProfile.GetUserId()); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_SERVICE_PROFILE), data, reply); - if (!serviceProfile.UnMarshalling(reply)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!serviceInfoProfile.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_SERVICE_INFO_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::DeleteServiceInfoProfile(const ServiceInfoUniqueKey& key) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!key.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::DELETE_SERVICE_INFO_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::UpdateServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!serviceInfoProfile.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::UPDATE_SERVICE_INFO_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetServiceInfoProfileByUniqueKey(const ServiceInfoUniqueKey& key, - ServiceInfoProfile& serviceInfoProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!key.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_BY_UNIQUE_KEY), data, reply); - if (!serviceInfoProfile.UnMarshalling(reply)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetServiceInfoProfileListByTokenId(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!key.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_LIST_BY_TOKEN_ID), - data, reply); - if (!IpcUtils::UnMarshalling(reply, serviceInfoProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetAllServiceInfoProfileList( - std::vector& serviceInfoProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_ALL_SERVICE_INFO_PROFILE_LIST), - data, reply); - if (!IpcUtils::UnMarshalling(reply, serviceInfoProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!key.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_LIST_BY_BUNDLE_NAME), - data, reply); - if (!IpcUtils::UnMarshalling(reply, serviceInfoProfiles)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetCharacteristicProfile(const std::string& deviceId, - const std::string& serviceName, const std::string& characteristicId, CharacteristicProfile& charProfile) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, deviceId); - WRITE_HELPER(data, String, serviceName); - WRITE_HELPER(data, String, characteristicId); - WRITE_HELPER(data, Bool, charProfile.IsMultiUser()); - WRITE_HELPER(data, Int32, charProfile.GetUserId()); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::GET_CHAR_PROFILE), data, reply); - if (!charProfile.UnMarshalling(reply)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::DeleteServiceProfile(const std::string& deviceId, - const std::string& serviceName, bool isMultiUser, int32_t userId) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, deviceId); - WRITE_HELPER(data, String, serviceName); - WRITE_HELPER(data, Bool, isMultiUser); - WRITE_HELPER(data, Int32, userId); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::DEL_SERVICE_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::DeleteCharacteristicProfile(const std::string& deviceId, - const std::string& serviceName, const std::string& characteristicId, bool isMultiUser, int32_t userId) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, deviceId); - WRITE_HELPER(data, String, serviceName); - WRITE_HELPER(data, String, characteristicId); - WRITE_HELPER(data, Bool, isMultiUser); - WRITE_HELPER(data, Int32, userId); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::DEL_CHAR_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!subscribeInfo.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!subscribeInfo.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::SyncDeviceProfile(const DpSyncOptions& syncOptions, - const sptr syncCompletedCallback) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!syncOptions.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - WRITE_HELPER(data, RemoteObject, syncCompletedCallback); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::SYNC_DEVICE_PROFILE_NEW), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::SendSubscribeInfos(std::map listenerMap) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, listenerMap)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::SEND_SUBSCRIBE_INFOS), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::SubscribeDeviceProfileInited(int32_t saId, sptr dpInitedCallback) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, Int32, saId); - WRITE_HELPER(data, RemoteObject, dpInitedCallback); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED), data, reply); - return DP_SUCCESS; -} - -int32_t OHOS::DistributedDeviceProfile::DistributedDeviceProfileProxy::UnSubscribeDeviceProfileInited(int32_t saId) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, Int32, saId); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE_INITED), data, reply); - return DP_SUCCESS; -} - -int32_t OHOS::DistributedDeviceProfile::DistributedDeviceProfileProxy::SubscribePinCodeInvalid( - const std::string& bundleName, int32_t pinExchangeType, sptr pinCodeCallback) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, bundleName); - WRITE_HELPER(data, Int32, pinExchangeType); - WRITE_HELPER(data, RemoteObject, pinCodeCallback); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::SUBSCRIBE_PINCODE_INVALID), data, reply); - return DP_SUCCESS; -} - -int32_t OHOS::DistributedDeviceProfile::DistributedDeviceProfileProxy::UnSubscribePinCodeInvalid( - const std::string& bundleName, int32_t pinExchangeType) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, bundleName); - WRITE_HELPER(data, Int32, pinExchangeType); - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::UNSUBSCRIBE_PINCODE_INVALID), data, reply); - return DP_SUCCESS; -} - -int32_t OHOS::DistributedDeviceProfile::DistributedDeviceProfileProxy::PutAllTrustedDevices( - const std::vector deviceInfos) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!IpcUtils::Marshalling(data, deviceInfos)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_ALL_TRUSTED_DEVICES), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!localServiceInfo.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::PUT_LOCAL_SERVICE_INFO), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - if (!localServiceInfo.Marshalling(data)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - MessageParcel reply; - SEND_REQUEST(remote, static_cast(DPInterfaceCode::UPDATE_LOCAL_SERVICE_INFO), data, reply); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, - int32_t pinExchangeType, LocalServiceInfo& localServiceInfo) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, bundleName); - WRITE_HELPER(data, Int32, pinExchangeType); - MessageParcel reply; - SEND_REQUEST(remote, - static_cast(DPInterfaceCode::GET_LOCAL_SERVICE_INFO_BY_BINDLE_AND_PINTYPE), data, reply); - if (!localServiceInfo.UnMarshalling(reply)) { - HILOGE("dp ipc read parcel fail"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileProxy::DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType) -{ - sptr remote = nullptr; - GET_REMOTE_OBJECT(remote); - MessageParcel data; - WRITE_INTERFACE_TOKEN(data); - WRITE_HELPER(data, String, bundleName); - WRITE_HELPER(data, Int32, pinExchangeType); - MessageParcel reply; - SEND_REQUEST(remote, - static_cast(DPInterfaceCode::DELETE_LOCAL_SERVICE_INFO), data, reply); - return DP_SUCCESS; -} -} // namespace DeviceProfile -} // namespace OHOS diff --git a/old/services/core/test/fuzztest/dumplocalprofile_fuzzer/BUILD.gn b/old/services/core/test/fuzztest/dumplocalprofile_fuzzer/BUILD.gn old mode 100755 new mode 100644 diff --git a/old/services/core/test/fuzztest/getdeviceprofile_fuzzer/BUILD.gn b/old/services/core/test/fuzztest/getdeviceprofile_fuzzer/BUILD.gn old mode 100755 new mode 100644 diff --git a/old/services/core/test/fuzztest/putdeviceprofile_fuzzer/BUILD.gn b/old/services/core/test/fuzztest/putdeviceprofile_fuzzer/BUILD.gn old mode 100755 new mode 100644 diff --git a/old/services/core/test/fuzztest/putdeviceprofileinner_fuzzer/BUILD.gn b/old/services/core/test/fuzztest/putdeviceprofileinner_fuzzer/BUILD.gn old mode 100755 new mode 100644 diff --git a/old/services/core/test/fuzztest/subscribeprofileeventinner_fuzzer/BUILD.gn b/old/services/core/test/fuzztest/subscribeprofileeventinner_fuzzer/BUILD.gn old mode 100755 new mode 100644 diff --git a/old/services/core/test/fuzztest/syncdeviceprofileinner_fuzzer/BUILD.gn b/old/services/core/test/fuzztest/syncdeviceprofileinner_fuzzer/BUILD.gn old mode 100755 new mode 100644 diff --git a/radar/test/unittest/BUILD.gn b/radar/test/unittest/BUILD.gn index 6bae4277..ed8c373c 100644 --- a/radar/test/unittest/BUILD.gn +++ b/radar/test/unittest/BUILD.gn @@ -29,6 +29,7 @@ device_profile_external_deps = [ "hilog:libhilog", "hisysevent:libhisysevent", "ipc:ipc_core", + "c_utils:utils", ] ohos_unittest("dp_radar_helper_test_new") { diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index 30b80960..e374fd77 100644 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -70,9 +70,11 @@ ohos_shared_library("distributed_device_profile_svr") { cflags_cc = cflags sanitize = { - boundary_sanitize = true integer_overflow = true ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true debug = false } @@ -97,7 +99,6 @@ ohos_shared_library("distributed_device_profile_svr") { "src/deviceprofilemanager/switch_profile_manager.cpp", "src/dfx/device_profile_dumper.cpp", "src/distributed_device_profile_service_new.cpp", - "src/distributed_device_profile_stub_new.cpp", "src/dm_adapter/dm_adapter.cpp", "src/localserviceinfomanager/local_service_info_manager.cpp", "src/multiusermanager/multi_user_manager.cpp", @@ -128,6 +129,7 @@ ohos_shared_library("distributed_device_profile_svr") { deps = [ "${device_profile_common}:distributed_device_profile_common", "${device_profile_path}/radar:device_profile_radar", + "${device_profile_innerkits}:distributed_device_profile_interfaces_ipc", ] configs = [ ":device_info_manager_config" ] @@ -163,6 +165,8 @@ ohos_shared_library("distributed_device_profile_svr") { part_name = "device_info_manager" subsystem_name = "deviceprofile" + + public_configs = [ "${device_profile_innerkits}:distributed_device_profile_interfaces_ipc_config" ] } group("unittest") { diff --git a/services/core/include/common/dp_services_constants.h b/services/core/include/common/dp_services_constants.h index a861f216..cedf79d1 100644 --- a/services/core/include/common/dp_services_constants.h +++ b/services/core/include/common/dp_services_constants.h @@ -38,7 +38,7 @@ extern const std::string CREATE_DEVICE_PROFILE_WISE_DEVICEID_INDEX_SQL; extern const std::string ALTER_TABLE_DP_ADD_COLUMN_PRODUCT_NAME_SQL; extern const std::string ALTER_TABLE_DP_RENAME_COLUMN_INTERNAL_MODEL_SQL; // DeviceIconInfoDao -extern const std::string CREATE_DEVICE_ICON_INFO_TABLE_SQL ; +extern const std::string CREATE_DEVICE_ICON_INFO_TABLE_SQL; extern const std::string CREATE_DEVICE_ICON_INFO_TABLE_UNIQUE_INDEX_SQL; extern const std::string SELECT_DEVICE_ICON_INFO_TABLE; extern const std::string ALTER_TABLE_DEVICE_ICON_INFO_ADD_COLUMN_INTENAL_MODEL_SQL; diff --git a/services/core/include/distributed_device_profile_service_new.h b/services/core/include/distributed_device_profile_service_new.h index 47531045..fac2fa5b 100644 --- a/services/core/include/distributed_device_profile_service_new.h +++ b/services/core/include/distributed_device_profile_service_new.h @@ -23,7 +23,7 @@ #include "device_icon_info.h" #include "device_icon_info_filter_options.h" #include "device_profile_filter_options.h" -#include "distributed_device_profile_stub_new.h" +#include "distributed_device_profile_stub.h" #include "dp_account_common_event.h" #include "event_handler.h" #include "event_runner.h" @@ -38,7 +38,7 @@ namespace OHOS { namespace DistributedDeviceProfile { -class DistributedDeviceProfileServiceNew : public SystemAbility, public DistributedDeviceProfileStubNew { +class DistributedDeviceProfileServiceNew : public SystemAbility, public DistributedDeviceProfileStub { DECLARE_SYSTEM_ABILITY(DistributedDeviceProfileServiceNew); DECLARE_SINGLE_INSTANCE_BASE(DistributedDeviceProfileServiceNew); @@ -54,7 +54,7 @@ public: int32_t UpdateAccessControlProfile(const AccessControlProfile& aclProfile) override; int32_t GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile) override; int32_t GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles) override; - int32_t GetAccessControlProfile(std::map queryParams, + int32_t GetAccessControlProfile(std::map& queryParams, std::vector& accessControlProfiles) override; int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) override; int32_t GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles) override; @@ -93,25 +93,25 @@ public: int32_t GetAllServiceInfoProfileList(std::vector& serviceInfoProfiles) override; int32_t GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, std::vector& serviceInfoProfiles) override; - int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; - int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; + int32_t SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfoExtension) override; + int32_t UnSubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfoExtension) override; int32_t SyncDeviceProfile(const DistributedDeviceProfile::DpSyncOptions& syncOptions, - sptr syncCompletedCallback) override; - int32_t SubscribeDeviceProfileInited(int32_t saId, sptr dpInitedCallback) override; + const sptr& syncCompletedCallback) override; + int32_t SubscribeDeviceProfileInited(int32_t saId, const sptr& dpInitedCallback) override; int32_t UnSubscribeDeviceProfileInited(int32_t saId) override; int32_t SubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType, - sptr pinCodeCallback) override; + const sptr& pinCodeCallback) override; int32_t UnSubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType) override; - int32_t PutAllTrustedDevices(const std::vector deviceInfos) override; + int32_t PutAllTrustedDevices(const std::vector& deviceInfos) override; int32_t PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo)override; int32_t UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo)override; int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, int32_t pinExchangeType, LocalServiceInfo& localServiceInfo)override; int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType)override; - int32_t SendSubscribeInfos(std::map listenerMap) override; + int32_t SendSubscribeInfos(std::map& listenerMap) override; int32_t Dump(int32_t fd, const std::vector& args) override; - void DelayUnloadTask() override; - bool IsInited() override; + void DelayUnloadTask(); + bool IsInited(); void SubscribeAccountCommonEvent(); protected: diff --git a/services/core/include/distributed_device_profile_stub_new.h b/services/core/include/distributed_device_profile_stub_new.h deleted file mode 100644 index be823eaf..00000000 --- a/services/core/include/distributed_device_profile_stub_new.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2021-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_DP_DISTRIBUTED_DEVICE_PROFILE_STUB_H -#define OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_STUB_H - -#include -#include - -#include "iremote_stub.h" - -#include "distributed_device_profile_errors.h" -#include "i_distributed_device_profile.h" -#include "ipc_utils.h" - -namespace OHOS { -namespace DistributedDeviceProfile { -class DistributedDeviceProfileStubNew : public IRemoteStub { -public: - DistributedDeviceProfileStubNew(); - ~DistributedDeviceProfileStubNew(); - - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - - int32_t PutAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t UpdateAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetAllTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetAllAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetAllAclIncludeLnnAclInner(MessageParcel& data, MessageParcel& reply); - int32_t DeleteAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t PutSessionKeyInner(MessageParcel& data, MessageParcel& reply); - int32_t GetSessionKeyInner(MessageParcel& data, MessageParcel& reply); - int32_t UpdateSessionKeyInner(MessageParcel& data, MessageParcel& reply); - int32_t PutDeviceProfileBatchInner(MessageParcel& data, MessageParcel& reply); - int32_t DeleteSessionKeyInner(MessageParcel& data, MessageParcel& reply); - int32_t PutServiceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t PutServiceProfileBatchInner(MessageParcel& data, MessageParcel& reply); - int32_t PutCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t PutCharacteristicProfileBatchInner(MessageParcel& data, MessageParcel& reply); - int32_t GetDeviceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetServiceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t DeleteServiceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t DeleteCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t SubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t UnSubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t SyncDeviceProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t SendSubscribeInfosInner(MessageParcel& data, MessageParcel& reply); - int32_t SubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply); - int32_t UnSubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply); - int32_t PutAllTrustedDevicesInner(MessageParcel& data, MessageParcel& reply); - int32_t PutLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply); - int32_t UpdateLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply); - int32_t GetLocalServiceInfoByBundleAndPinTypeInner(MessageParcel& data, MessageParcel& reply); - int32_t DeleteLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply); - int32_t GetDeviceProfilesInner(MessageParcel& data, MessageParcel& reply); - int32_t DeleteDeviceProfileBatchInner(MessageParcel& data, MessageParcel& reply); - int32_t PutProductInfoBatchInner(MessageParcel& data, MessageParcel& reply); - int32_t PutDeviceIconInfoBatchInner(MessageParcel& data, MessageParcel& reply); - int32_t GetDeviceIconInfosInner(MessageParcel& data, MessageParcel& reply); - int32_t PutServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t DeleteServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t UpdateServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply); - int32_t GetServiceInfoProfileByUniqueKeyInner(MessageParcel& data, MessageParcel& reply); - int32_t GetServiceInfoProfileListByTokenIdInner(MessageParcel& data, MessageParcel& reply); - int32_t GetAllServiceInfoProfileListInner(MessageParcel& data, MessageParcel& reply); - int32_t GetServiceInfoProfileListByBundleNameInner(MessageParcel& data, MessageParcel& reply); - int32_t SubscribePinCodeInvalidInner(MessageParcel& data, MessageParcel& reply); - int32_t UnSubscribePinCodeInvalidInner(MessageParcel& data, MessageParcel& reply); - virtual void DelayUnloadTask() = 0; - virtual bool IsInited() = 0; - -private: - using Func = int32_t(DistributedDeviceProfileStubNew::*)(MessageParcel& data, MessageParcel& reply); - bool IsInterfaceTokenValid(MessageParcel& data); - void InitAclAndSubscribe(); - int32_t NotifyEventInner(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option); - int32_t NotifyAclEventInner(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option); - int32_t NotifyProfileDataEventInner(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option); - int32_t NotifyLocalServiceEventInner(uint32_t code, MessageParcel& data, MessageParcel& reply, - MessageOption& option); -private: - std::unordered_set aclAndSubscribeFuncs_; -}; -} // namespace DeviceProfile -} // namespace OHOS -#endif // OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_STUB_H diff --git a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h index 9fe77633..f38687d5 100644 --- a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h +++ b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h @@ -23,6 +23,7 @@ #include "distributed_device_profile_enums.h" #include "device_profile.h" #include "dp_subscribe_info.h" +#include "dp_subscribe_info_extension.h" #include "service_profile.h" #include "characteristic_profile.h" @@ -41,9 +42,9 @@ public: int32_t NotifyTrustDeviceProfileDelete(const TrustDeviceProfile& trustDeviceProfile); int32_t NotifyTrustDeviceProfileActive(const TrustDeviceProfile& trustDeviceProfile); int32_t NotifyTrustDeviceProfileInactive(const TrustDeviceProfile& trustDeviceProfile); - int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo); - int32_t SubscribeDeviceProfile(std::map subscribeInfos); - int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo); + int32_t SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfo); + int32_t SubscribeDeviceProfile(std::map subscribeInfos); + int32_t UnSubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfo); private: int32_t NotifyDeviceProfileAdd(const std::string& dbKey, const std::string& dbValue); @@ -55,7 +56,8 @@ private: int32_t NotifyCharProfileAdd(const std::string& dbKey, const std::string& dbValue); int32_t NotifyCharProfileUpdate(const std::string& dbKey, const std::string& dbValue); int32_t NotifyCharProfileDelete(const std::string& dbKey, const std::string& dbValue); - std::unordered_set GetSubscribeInfos(const std::string& dbKey); + std::unordered_set GetSubscribeInfos( + const std::string& dbKey); std::string DBKeyToSubcribeKey(const std::string& dbkey); private: @@ -63,7 +65,8 @@ private: std::mutex funcsMutex_; std::map funcsMap_; std::mutex subscribeMutex_; - std::map> subscribeInfoMap_; + std::map> + subscribeInfoExtensionMap_; }; } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/services/core/src/distributed_device_profile_service_new.cpp b/services/core/src/distributed_device_profile_service_new.cpp index 07fb1c5d..74aaf7df 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -350,7 +350,7 @@ int32_t DistributedDeviceProfileServiceNew::GetAllTrustDeviceProfile( return ret; } -int32_t DistributedDeviceProfileServiceNew::GetAccessControlProfile(std::map queryParams, +int32_t DistributedDeviceProfileServiceNew::GetAccessControlProfile(std::map& queryParams, std::vector& accessControlProfiles) { if (!PermissionManager::GetInstance().IsCallerTrust(GET_ACCESS_CONTROL_PROFILE)) { @@ -784,32 +784,33 @@ int32_t DistributedDeviceProfileServiceNew::DeleteLocalServiceInfo(const std::st return ret; } -int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfile(const SubscribeInfo& subscriberInfo) +int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfoExtension) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); return DP_PERMISSION_DENIED; } HILOGD("CheckCallerPermission success interface SubscribeDeviceProfile"); - int32_t ret = SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(subscriberInfo); - DpRadarHelper::GetInstance().ReportSubscribeDeviceProfile(ret, subscriberInfo); + int32_t ret = SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(subscribeInfoExtension); + DpRadarHelper::GetInstance().ReportSubscribeDeviceProfile(ret, subscribeInfoExtension); return ret; } -int32_t DistributedDeviceProfileServiceNew::UnSubscribeDeviceProfile(const SubscribeInfo& subscriberInfo) +int32_t DistributedDeviceProfileServiceNew::UnSubscribeDeviceProfile( + const SubscribeInfoExtension& subscribeInfoExtension) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); return DP_PERMISSION_DENIED; } HILOGD("CheckCallerPermission success interface UnSubscribeDeviceProfile"); - int32_t ret = SubscribeProfileManager::GetInstance().UnSubscribeDeviceProfile(subscriberInfo); - DpRadarHelper::GetInstance().ReportUnSubscribeDeviceProfile(ret, subscriberInfo); + int32_t ret = SubscribeProfileManager::GetInstance().UnSubscribeDeviceProfile(subscribeInfoExtension); + DpRadarHelper::GetInstance().ReportUnSubscribeDeviceProfile(ret, subscribeInfoExtension); return ret; } int32_t DistributedDeviceProfileServiceNew::SyncDeviceProfile( - const DistributedDeviceProfile::DpSyncOptions& syncOptions, sptr syncCompletedCallback) + const DistributedDeviceProfile::DpSyncOptions& syncOptions, const sptr& syncCompletedCallback) { if (!PermissionManager::GetInstance().CheckCallerSyncPermission()) { HILOGE("this caller is permission denied!"); @@ -821,7 +822,8 @@ int32_t DistributedDeviceProfileServiceNew::SyncDeviceProfile( return ret; } -int32_t DistributedDeviceProfileServiceNew::SendSubscribeInfos(std::map listenerMap) +int32_t DistributedDeviceProfileServiceNew::SendSubscribeInfos( + std::map& listenerMap) { return SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(listenerMap); } @@ -1137,7 +1139,7 @@ void DistributedDeviceProfileServiceNew::ClearProfileCache() } int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfileInited(int32_t saId, - sptr dpInitedCallback) + const sptr & dpInitedCallback) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); @@ -1177,7 +1179,7 @@ int32_t DistributedDeviceProfileServiceNew::UnSubscribeDeviceProfileInited(int32 } int32_t DistributedDeviceProfileServiceNew::SubscribePinCodeInvalid(const std::string& bundleName, - int32_t pinExchangeType, sptr pinCodeCallback) + int32_t pinExchangeType, const sptr& pinCodeCallback) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); @@ -1268,7 +1270,7 @@ int32_t DistributedDeviceProfileServiceNew::NotifyPinCodeInvalid(const LocalServ return DP_SUCCESS; } -int32_t DistributedDeviceProfileServiceNew::PutAllTrustedDevices(const std::vector deviceInfos) +int32_t DistributedDeviceProfileServiceNew::PutAllTrustedDevices(const std::vector& deviceInfos) { if (!PermissionManager::GetInstance().IsCallerTrust(PUT_ALL_TRUSTED_DEVICES)) { HILOGE("this caller is permission denied!"); diff --git a/services/core/src/distributed_device_profile_stub_new.cpp b/services/core/src/distributed_device_profile_stub_new.cpp deleted file mode 100644 index 9cbacdb9..00000000 --- a/services/core/src/distributed_device_profile_stub_new.cpp +++ /dev/null @@ -1,1057 +0,0 @@ -/* - * Copyright (c) 2021-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 "distributed_device_profile_stub_new.h" - -#include - -#include "ipc_skeleton.h" -#include "ipc_utils.h" - -#include "distributed_device_profile_errors.h" -#include "distributed_device_profile_log.h" -#include "distributed_device_profile_enums.h" -#include "profile_utils.h" - -namespace OHOS { -namespace DistributedDeviceProfile { -namespace { -const std::string TAG = "DistributedDeviceProfileStubNew"; -} - -DistributedDeviceProfileStubNew::DistributedDeviceProfileStubNew() -{ - InitAclAndSubscribe(); -} - -void DistributedDeviceProfileStubNew::InitAclAndSubscribe() -{ - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_ACL_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::UPDATE_ACL_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_TRUST_DEVICE_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_ALL_TRUST_DEVICE_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_ACL_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_ALL_ACL_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_ALL_ACL_INCLUDE_LNN_ACL)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::DELETE_ACL_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::SEND_SUBSCRIBE_INFOS)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE_BATCH)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_CHAR_PROFILE)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_CHAR_PROFILE_BATCH)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE_INITED)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_ALL_TRUSTED_DEVICES)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_DEVICE_PROFILE_BATCH)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_DEVICE_PROFILES)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::DELETE_DEVICE_PROFILE_BATCH)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_DEVICE_ICON_INFOS)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_DEVICE_ICON_INFO_BATCH)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_PRODUCT_INFO_BATCH)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::PUT_SESSION_KEY)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::GET_SESSION_KEY)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::UPDATE_SESSION_KEY)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::DELETE_SESSION_KEY)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::SUBSCRIBE_PINCODE_INVALID)); - aclAndSubscribeFuncs_.insert(static_cast(DPInterfaceCode::UNSUBSCRIBE_PINCODE_INVALID)); -} - -DistributedDeviceProfileStubNew::~DistributedDeviceProfileStubNew() -{ - HILOGI("destructor!"); -} - -bool DistributedDeviceProfileStubNew::IsInterfaceTokenValid(MessageParcel& data) -{ - return data.ReadInterfaceToken() == IDistributedDeviceProfile::GetDescriptor(); -} - - -int32_t DistributedDeviceProfileStubNew::NotifyAclEventInner(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - switch (code) { - case static_cast(DPInterfaceCode::PUT_ACL_PROFILE): - return PutAccessControlProfileInner(data, reply); - case static_cast(DPInterfaceCode::UPDATE_ACL_PROFILE): - return UpdateAccessControlProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_TRUST_DEVICE_PROFILE): - return GetTrustDeviceProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_ALL_TRUST_DEVICE_PROFILE): - return GetAllTrustDeviceProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_ACL_PROFILE): - return GetAccessControlProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_ALL_ACL_PROFILE): - return GetAllAccessControlProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_ALL_ACL_INCLUDE_LNN_ACL): - return GetAllAclIncludeLnnAclInner(data, reply); - case static_cast(DPInterfaceCode::DELETE_ACL_PROFILE): - return DeleteAccessControlProfileInner(data, reply); - case static_cast(DPInterfaceCode::PUT_SESSION_KEY): - return PutSessionKeyInner(data, reply); - case static_cast(DPInterfaceCode::GET_SESSION_KEY): - return GetSessionKeyInner(data, reply); - case static_cast(DPInterfaceCode::UPDATE_SESSION_KEY): - return UpdateSessionKeyInner(data, reply); - case static_cast(DPInterfaceCode::DELETE_SESSION_KEY): - return DeleteSessionKeyInner(data, reply); - default: - return NotifyProfileDataEventInner(code, data, reply, option); - } -} - -int32_t DistributedDeviceProfileStubNew::NotifyProfileDataEventInner( - uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) -{ - switch (code) { - case static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE): - return SubscribeDeviceProfileInner(data, reply); - case static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE): - return UnSubscribeDeviceProfileInner(data, reply); - case static_cast(DPInterfaceCode::SEND_SUBSCRIBE_INFOS): - return SendSubscribeInfosInner(data, reply); - case static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE): - return PutServiceProfileInner(data, reply); - case static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE_BATCH): - return PutServiceProfileBatchInner(data, reply); - case static_cast(DPInterfaceCode::PUT_CHAR_PROFILE): - return PutCharacteristicProfileInner(data, reply); - case static_cast(DPInterfaceCode::PUT_CHAR_PROFILE_BATCH): - return PutCharacteristicProfileBatchInner(data, reply); - case static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED): - return SubscribeDeviceProfileInitedInner(data, reply); - case static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE_INITED): - return UnSubscribeDeviceProfileInitedInner(data, reply); - case static_cast(DPInterfaceCode::PUT_ALL_TRUSTED_DEVICES): - return PutAllTrustedDevicesInner(data, reply); - case static_cast(DPInterfaceCode::PUT_DEVICE_PROFILE_BATCH): - return PutDeviceProfileBatchInner(data, reply); - case static_cast(DPInterfaceCode::GET_DEVICE_PROFILES): - return GetDeviceProfilesInner(data, reply); - case static_cast(DPInterfaceCode::GET_DEVICE_ICON_INFOS): - return GetDeviceIconInfosInner(data, reply); - case static_cast(DPInterfaceCode::PUT_DEVICE_ICON_INFO_BATCH): - return PutDeviceIconInfoBatchInner(data, reply); - case static_cast(DPInterfaceCode::PUT_PRODUCT_INFO_BATCH): - return PutProductInfoBatchInner(data, reply); - case static_cast(DPInterfaceCode::DELETE_DEVICE_PROFILE_BATCH): - return DeleteDeviceProfileBatchInner(data, reply); - case static_cast(DPInterfaceCode::SUBSCRIBE_PINCODE_INVALID): - return SubscribePinCodeInvalidInner(data, reply); - case static_cast(DPInterfaceCode::UNSUBSCRIBE_PINCODE_INVALID): - return UnSubscribePinCodeInvalidInner(data, reply); - default: - HILOGE("unknown request code, please check, code = %{public}u", code); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } -} - -int32_t DistributedDeviceProfileStubNew::NotifyEventInner(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - switch (code) { - case static_cast(DPInterfaceCode::GET_DEVICE_PROFILE_NEW): - return GetDeviceProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_SERVICE_PROFILE): - return GetServiceProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_CHAR_PROFILE): - return GetCharacteristicProfileInner(data, reply); - case static_cast(DPInterfaceCode::DEL_SERVICE_PROFILE): - return DeleteServiceProfileInner(data, reply); - case static_cast(DPInterfaceCode::DEL_CHAR_PROFILE): - return DeleteCharacteristicProfileInner(data, reply); - case static_cast(DPInterfaceCode::SYNC_DEVICE_PROFILE_NEW): - return SyncDeviceProfileInner(data, reply); - case static_cast(DPInterfaceCode::PUT_SERVICE_INFO_PROFILE): - return PutServiceInfoProfileInner(data, reply); - case static_cast(DPInterfaceCode::DELETE_SERVICE_INFO_PROFILE): - return DeleteServiceInfoProfileInner(data, reply); - case static_cast(DPInterfaceCode::UPDATE_SERVICE_INFO_PROFILE): - return UpdateServiceInfoProfileInner(data, reply); - case static_cast(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_BY_UNIQUE_KEY): - return GetServiceInfoProfileByUniqueKeyInner(data, reply); - case static_cast(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_LIST_BY_TOKEN_ID): - return GetServiceInfoProfileListByTokenIdInner(data, reply); - case static_cast(DPInterfaceCode::GET_ALL_SERVICE_INFO_PROFILE_LIST): - return GetAllServiceInfoProfileListInner(data, reply); - case static_cast(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_LIST_BY_BUNDLE_NAME): - return GetServiceInfoProfileListByBundleNameInner(data, reply); - default: - return NotifyLocalServiceEventInner(code, data, reply, option); - } -} - -int32_t DistributedDeviceProfileStubNew::NotifyLocalServiceEventInner(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - switch (code) { - case static_cast(DPInterfaceCode::PUT_LOCAL_SERVICE_INFO): - return PutLocalServiceInfoInner(data, reply); - case static_cast(DPInterfaceCode::UPDATE_LOCAL_SERVICE_INFO): - return UpdateLocalServiceInfoInner(data, reply); - case static_cast(DPInterfaceCode::GET_LOCAL_SERVICE_INFO_BY_BINDLE_AND_PINTYPE): - return GetLocalServiceInfoByBundleAndPinTypeInner(data, reply); - case static_cast(DPInterfaceCode::DELETE_LOCAL_SERVICE_INFO): - return DeleteLocalServiceInfoInner(data, reply); - default: - HILOGW("unknown request code, please check, code = %{public}u", code); - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } -} - -int32_t DistributedDeviceProfileStubNew::OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - HILOGI("code = %{public}u, CallingPid = %{public}u", code, IPCSkeleton::GetCallingPid()); - DelayUnloadTask(); - if (!IsInterfaceTokenValid(data)) { - HILOGE("check interface token failed"); - return DP_INTERFACE_CHECK_FAILED; - } - if (aclAndSubscribeFuncs_.find(code) != aclAndSubscribeFuncs_.end()) { - return NotifyAclEventInner(code, data, reply, option); - } - if (!IsInited()) { - HILOGE("DP not finish init"); - return DP_LOAD_SERVICE_ERR; - } - int32_t ret = NotifyEventInner(code, data, reply, option); - return ret; -} - -int32_t DistributedDeviceProfileStubNew::PutAccessControlProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - AccessControlProfile accessControlProfile; - if (!accessControlProfile.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutAccessControlProfile(accessControlProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::UpdateAccessControlProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - AccessControlProfile accessControlProfile; - if (!accessControlProfile.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = UpdateAccessControlProfile(accessControlProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGD("called"); - std::string deviceId; - READ_HELPER(data, String, deviceId); - TrustDeviceProfile trustDeviceProfile; - int32_t ret = GetTrustDeviceProfile(deviceId, trustDeviceProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!trustDeviceProfile.Marshalling(reply)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetAllTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - std::vector trustDeviceProfiles; - int32_t ret = GetAllTrustDeviceProfile(trustDeviceProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!IpcUtils::Marshalling(reply, trustDeviceProfiles)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetAccessControlProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - std::map queryParams; - if (!IpcUtils::UnMarshalling(data, queryParams)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - std::vector accessControlProfiles; - int32_t ret = GetAccessControlProfile(queryParams, accessControlProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!IpcUtils::Marshalling(reply, accessControlProfiles)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetAllAccessControlProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - std::vector accessControlProfiles; - int32_t ret = GetAllAccessControlProfile(accessControlProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!IpcUtils::Marshalling(reply, accessControlProfiles)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetAllAclIncludeLnnAclInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - std::vector accessControlProfiles; - int32_t ret = GetAllAclIncludeLnnAcl(accessControlProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!IpcUtils::Marshalling(reply, accessControlProfiles)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::DeleteAccessControlProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - int32_t accessControlId; - READ_HELPER(data, Int32, accessControlId); - int32_t ret = DeleteAccessControlProfile(accessControlId); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutSessionKeyInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - uint32_t userId = 0; - std::vector sessionKey; - int32_t sessionKeyId = 0; - READ_HELPER(data, Uint32, userId); - if (!IpcUtils::UnMarshalling(data, sessionKey)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - int32_t ret = PutSessionKey(userId, sessionKey, sessionKeyId); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - WRITE_HELPER(reply, Int32, sessionKeyId); - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetSessionKeyInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - uint32_t userId = 0; - int32_t sessionKeyId = 0; - std::vector sessionKey; - READ_HELPER(data, Uint32, userId); - READ_HELPER(data, Int32, sessionKeyId); - int32_t ret = GetSessionKey(userId, sessionKeyId, sessionKey); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - if (!IpcUtils::Marshalling(reply, sessionKey)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::UpdateSessionKeyInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - uint32_t userId = 0; - std::vector sessionKey; - int32_t sessionKeyId = 0; - READ_HELPER(data, Uint32, userId); - READ_HELPER(data, Int32, sessionKeyId); - if (!IpcUtils::UnMarshalling(data, sessionKey)) { - HILOGE("dp ipc write parcel fail"); - return DP_WRITE_PARCEL_FAIL; - } - int32_t ret = UpdateSessionKey(userId, sessionKeyId, sessionKey); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::DeleteSessionKeyInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - uint32_t userId = 0; - int32_t sessionKeyId = 0; - READ_HELPER(data, Uint32, userId); - READ_HELPER(data, Int32, sessionKeyId); - int32_t ret = DeleteSessionKey(userId, sessionKeyId); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutServiceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - ServiceProfile serviceProfile; - if (!serviceProfile.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutServiceProfile(serviceProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutServiceProfileBatchInner(MessageParcel& data, MessageParcel& reply) -{ - std::vector serviceProfiles; - if (!IpcUtils::UnMarshalling(data, serviceProfiles)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutServiceProfileBatch(serviceProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply) -{ - CharacteristicProfile charProfile; - if (!charProfile.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutCharacteristicProfile(charProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutCharacteristicProfileBatchInner(MessageParcel& data, MessageParcel& reply) -{ - std::vector charProfiles; - if (!IpcUtils::UnMarshalling(data, charProfiles)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutCharacteristicProfileBatch(charProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetDeviceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - std::string deviceId; - bool isMultiUser = false; - int32_t userId = DEFAULT_USER_ID; - DeviceProfile deviceProfile; - READ_HELPER(data, String, deviceId); - READ_HELPER(data, Bool, isMultiUser); - READ_HELPER(data, Int32, userId); - deviceProfile.SetIsMultiUser(isMultiUser); - deviceProfile.SetUserId(userId); - int32_t ret = GetDeviceProfile(deviceId, deviceProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!deviceProfile.Marshalling(reply)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetServiceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - std::string deviceId; - std::string serviceName; - bool isMultiUser = false; - int32_t userId = DEFAULT_USER_ID; - ServiceProfile serviceProfile; - READ_HELPER(data, String, deviceId); - READ_HELPER(data, String, serviceName); - READ_HELPER(data, Bool, isMultiUser); - READ_HELPER(data, Int32, userId); - serviceProfile.SetIsMultiUser(isMultiUser); - serviceProfile.SetUserId(userId); - int32_t ret = GetServiceProfile(deviceId, serviceName, serviceProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!serviceProfile.Marshalling(reply)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply) -{ - std::string deviceId; - std::string serviceName; - std::string characteristicKey; - bool isMultiUser = false; - int32_t userId = DEFAULT_USER_ID; - READ_HELPER(data, String, deviceId); - READ_HELPER(data, String, serviceName); - READ_HELPER(data, String, characteristicKey); - READ_HELPER(data, Bool, isMultiUser); - READ_HELPER(data, Int32, userId); - CharacteristicProfile charProfile; - charProfile.SetIsMultiUser(isMultiUser); - charProfile.SetUserId(userId); - int32_t ret = GetCharacteristicProfile(deviceId, serviceName, characteristicKey, charProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!charProfile.Marshalling(reply)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::DeleteServiceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - std::string deviceId; - std::string serviceName; - bool isMultiUser = false; - int32_t userId = DEFAULT_USER_ID; - READ_HELPER(data, String, deviceId); - READ_HELPER(data, String, serviceName); - READ_HELPER(data, Bool, isMultiUser); - READ_HELPER(data, Int32, userId); - int32_t ret = DeleteServiceProfile(deviceId, serviceName, isMultiUser, userId); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::DeleteCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply) -{ - std::string deviceId; - std::string serviceName; - std::string characteristicKey; - bool isMultiUser = false; - int32_t userId = DEFAULT_USER_ID; - READ_HELPER(data, String, deviceId); - READ_HELPER(data, String, serviceName); - READ_HELPER(data, String, characteristicKey); - READ_HELPER(data, Bool, isMultiUser); - READ_HELPER(data, Int32, userId); - int32_t ret = DeleteCharacteristicProfile(deviceId, serviceName, characteristicKey, isMultiUser, userId); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::SubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - SubscribeInfo subscribeInfo; - if (!subscribeInfo.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = SubscribeDeviceProfile(subscribeInfo); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::UnSubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - SubscribeInfo subscribeInfo; - if (!subscribeInfo.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = UnSubscribeDeviceProfile(subscribeInfo); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::SyncDeviceProfileInner(MessageParcel& data, MessageParcel& reply) -{ - DistributedDeviceProfile::DpSyncOptions syncOptions; - if (!syncOptions.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - sptr syncCompletedCallback = data.ReadRemoteObject(); - int32_t ret = SyncDeviceProfile(syncOptions, syncCompletedCallback); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::SendSubscribeInfosInner(MessageParcel& data, MessageParcel& reply) -{ - std::map listenerMap; - if (!IpcUtils::UnMarshalling(data, listenerMap)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = SendSubscribeInfos(listenerMap); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::SubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply) -{ - int32_t saId = -1; - READ_HELPER(data, Int32, saId); - sptr dpInitedCallback = data.ReadRemoteObject(); - if (dpInitedCallback == nullptr) { - HILOGE("read remoteObject failed!"); - return ERR_FLATTEN_OBJECT; - } - int32_t ret = SubscribeDeviceProfileInited(saId, dpInitedCallback); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::UnSubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply) -{ - int32_t saId = -1; - READ_HELPER(data, Int32, saId); - int32_t ret = UnSubscribeDeviceProfileInited(saId); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutAllTrustedDevicesInner(MessageParcel& data, MessageParcel& reply) -{ - std::vector deviceInfos; - if (!IpcUtils::UnMarshalling(data, deviceInfos)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutAllTrustedDevices(deviceInfos); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - LocalServiceInfo localServiceInfo; - if (!localServiceInfo.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutLocalServiceInfo(localServiceInfo); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::UpdateLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - LocalServiceInfo localServiceInfo; - if (!localServiceInfo.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = UpdateLocalServiceInfo(localServiceInfo); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetLocalServiceInfoByBundleAndPinTypeInner(MessageParcel& data, - MessageParcel& reply) -{ - LocalServiceInfo localServiceInfo; - int32_t pinExchangeType = 0; - std::string bundleName = ""; - READ_HELPER(data, String, bundleName); - READ_HELPER(data, Int32, pinExchangeType); - int32_t ret = GetLocalServiceInfoByBundleAndPinType(bundleName, pinExchangeType, localServiceInfo); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!localServiceInfo.Marshalling(reply)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::DeleteLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply) -{ - int32_t pinExchangeType = 0; - std::string bundleName = ""; - READ_HELPER(data, String, bundleName); - READ_HELPER(data, Int32, pinExchangeType); - int32_t ret = DeleteLocalServiceInfo(bundleName, pinExchangeType); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutDeviceProfileBatchInner(MessageParcel& data, MessageParcel& reply) -{ - std::vector deviceProfiles; - if (!IpcUtils::UnMarshalling(data, deviceProfiles)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutDeviceProfileBatch(deviceProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetDeviceProfilesInner(MessageParcel& data, MessageParcel& reply) -{ - DeviceProfileFilterOptions options; - std::vector deviceProfiles; - if (!options.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = GetDeviceProfiles(options, deviceProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!IpcUtils::Marshalling(reply, deviceProfiles)) { - HILOGE("write parcel fail!"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::SubscribePinCodeInvalidInner(MessageParcel& data, MessageParcel& reply) -{ - std::string bundleName = ""; - int32_t pinExchangeType = DEFAULT_PIN_EXCHANGE_TYPE; - READ_HELPER(data, String, bundleName); - READ_HELPER(data, Int32, pinExchangeType); - sptr pincodeInvalidCallback = data.ReadRemoteObject(); - if (pincodeInvalidCallback == nullptr) { - HILOGE("read remoteObject failed!"); - return ERR_FLATTEN_OBJECT; - } - int32_t ret = SubscribePinCodeInvalid(bundleName, - pinExchangeType, pincodeInvalidCallback); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::UnSubscribePinCodeInvalidInner(MessageParcel& data, MessageParcel& reply) -{ - std::string bundleName = ""; - int32_t pinExchangeType = DEFAULT_PIN_EXCHANGE_TYPE; - READ_HELPER(data, String, bundleName); - READ_HELPER(data, Int32, pinExchangeType); - int32_t ret = UnSubscribePinCodeInvalid(bundleName, - pinExchangeType); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutProductInfoBatchInner(MessageParcel& data, MessageParcel& reply) -{ - std::vector productInfos; - if (!IpcUtils::UnMarshalling(data, productInfos)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutProductInfoBatch(productInfos); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutDeviceIconInfoBatchInner(MessageParcel& data, MessageParcel& reply) -{ - std::vector deviceIconInfos; - if (!IpcUtils::UnMarshalling(data, deviceIconInfos)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutDeviceIconInfoBatch(deviceIconInfos); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetDeviceIconInfosInner(MessageParcel& data, MessageParcel& reply) -{ - DeviceIconInfoFilterOptions filterOptions; - std::vector deviceIconInfos; - if (!filterOptions.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = GetDeviceIconInfos(filterOptions, - deviceIconInfos); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!IpcUtils::Marshalling(reply, deviceIconInfos)) { - HILOGE("Write parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::PutServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - ServiceInfoProfile serviceInfoProfile; - if (!serviceInfoProfile.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = PutServiceInfoProfile(serviceInfoProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::DeleteServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - ServiceInfoUniqueKey key; - if (!key.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = DeleteServiceInfoProfile(key); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::UpdateServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply) -{ - HILOGI("called"); - ServiceInfoProfile serviceInfoProfile; - if (!serviceInfoProfile.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = UpdateServiceInfoProfile(serviceInfoProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return DP_WRITE_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetServiceInfoProfileByUniqueKeyInner(MessageParcel& data, - MessageParcel& reply) -{ - ServiceInfoUniqueKey key; - ServiceInfoProfile serviceInfoProfile; - if (!key.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = GetServiceInfoProfileByUniqueKey(key, - serviceInfoProfile); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - if (!serviceInfoProfile.Marshalling(reply)) { - HILOGE("write parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetServiceInfoProfileListByTokenIdInner(MessageParcel& data, - MessageParcel& reply) -{ - ServiceInfoUniqueKey key; - std::vector serviceInfoProfiles; - if (!key.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = GetServiceInfoProfileListByTokenId(key, - serviceInfoProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!IpcUtils::Marshalling(reply, serviceInfoProfiles)) { - HILOGE("Write parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetAllServiceInfoProfileListInner(MessageParcel& data, - MessageParcel& reply) -{ - std::vector serviceInfoProfiles; - int32_t ret = GetAllServiceInfoProfileList(serviceInfoProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!IpcUtils::Marshalling(reply, serviceInfoProfiles)) { - HILOGE("Write parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::GetServiceInfoProfileListByBundleNameInner(MessageParcel& data, - MessageParcel& reply) -{ - ServiceInfoUniqueKey key; - std::vector serviceInfoProfiles; - if (!key.UnMarshalling(data)) { - HILOGE("read parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = GetServiceInfoProfileListByBundleName(key, - serviceInfoProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - - if (!IpcUtils::Marshalling(reply, serviceInfoProfiles)) { - HILOGE("Write parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - return DP_SUCCESS; -} - -int32_t DistributedDeviceProfileStubNew::DeleteDeviceProfileBatchInner(MessageParcel& data, MessageParcel& reply) -{ - std::vector deviceProfiles; - if (!IpcUtils::UnMarshalling(data, deviceProfiles)) { - HILOGE("Write parcel fail!"); - return DP_READ_PARCEL_FAIL; - } - int32_t ret = DeleteDeviceProfileBatch(deviceProfiles); - if (!reply.WriteInt32(ret)) { - HILOGE("Write reply failed"); - return ERR_FLATTEN_OBJECT; - } - return DP_SUCCESS; -} -} // namespace DeviceProfile -} // namespace OHOS diff --git a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp index 06cebceb..065e1c2d 100644 --- a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp +++ b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp @@ -59,7 +59,7 @@ int32_t SubscribeProfileManager::UnInit() HILOGI("call!"); { std::lock_guard lockGuard(subscribeMutex_); - subscribeInfoMap_.clear(); + subscribeInfoExtensionMap_.clear(); } { std::lock_guard lockGuard(funcsMutex_); @@ -199,32 +199,32 @@ int32_t SubscribeProfileManager::NotifyTrustDeviceProfileInactive(const TrustDev return DP_SUCCESS; } -int32_t SubscribeProfileManager::SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) +int32_t SubscribeProfileManager::SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfo) { HILOGI("saId: %{public}d!, subscribeKey: %{public}s", subscribeInfo.GetSaId(), ProfileUtils::GetDbKeyAnonyString(subscribeInfo.GetSubscribeKey()).c_str()); { std::lock_guard lock(subscribeMutex_); - if (subscribeInfoMap_.size() > MAX_LISTENER_SIZE) { - HILOGE("SubscribeInfoMap size is invalid!size: %{public}zu!", subscribeInfoMap_.size()); + if (subscribeInfoExtensionMap_.size() > MAX_LISTENER_SIZE) { + HILOGE("SubscribeInfoMap size is invalid!size: %{public}zu!", subscribeInfoExtensionMap_.size()); return DP_EXCEED_MAX_SIZE_FAIL; } - if (subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].size() > MAX_LISTENER_SIZE) { + if (subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].size() > MAX_LISTENER_SIZE) { HILOGE("SubscribeInfoMap size is invalid!size: %{public}zu!", - subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].size()); + subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].size()); return DP_EXCEED_MAX_SIZE_FAIL; } - if (subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].find(subscribeInfo) != - subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].end()) { + if (subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].find(subscribeInfo) != + subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].end()) { HILOGI("this sa subscribeInfo is exist, saId : %{public}d", subscribeInfo.GetSaId()); - subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].erase(subscribeInfo); + subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].erase(subscribeInfo); } - subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].emplace(subscribeInfo); + subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].emplace(subscribeInfo); } return DP_SUCCESS; } -int32_t SubscribeProfileManager::SubscribeDeviceProfile(std::map subscribeInfos) +int32_t SubscribeProfileManager::SubscribeDeviceProfile(std::map subscribeInfos) { HILOGD("call!"); for (auto item : subscribeInfos) { @@ -233,16 +233,16 @@ int32_t SubscribeProfileManager::SubscribeDeviceProfile(std::map lock(subscribeMutex_); - if (subscribeInfoMap_.find(subscribeInfo.GetSubscribeKey()) != subscribeInfoMap_.end()) { - subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].erase(subscribeInfo); - if (subscribeInfoMap_[subscribeInfo.GetSubscribeKey()].empty()) { - subscribeInfoMap_.erase(subscribeInfo.GetSubscribeKey()); + if (subscribeInfoExtensionMap_.find(subscribeInfo.GetSubscribeKey()) != subscribeInfoExtensionMap_.end()) { + subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].erase(subscribeInfo); + if (subscribeInfoExtensionMap_[subscribeInfo.GetSubscribeKey()].empty()) { + subscribeInfoExtensionMap_.erase(subscribeInfo.GetSubscribeKey()); } } } @@ -514,16 +514,17 @@ int32_t SubscribeProfileManager::NotifyCharProfileDelete(const std::string& dbKe } return DP_SUCCESS; } -std::unordered_set SubscribeProfileManager::GetSubscribeInfos( - const std::string& dbKey) + +std::unordered_set +SubscribeProfileManager::GetSubscribeInfos(const std::string& dbKey) { { std::lock_guard lock(subscribeMutex_); - if (subscribeInfoMap_.find(dbKey) == subscribeInfoMap_.end()) { + if (subscribeInfoExtensionMap_.find(dbKey) == subscribeInfoExtensionMap_.end()) { HILOGD("This dbKey is not subscribed, dbKey: %{public}s", ProfileUtils::GetDbKeyAnonyString(dbKey).c_str()); return {}; } - return subscribeInfoMap_[dbKey]; + return subscribeInfoExtensionMap_[dbKey]; } } diff --git a/services/core/test/BUILD.gn b/services/core/test/BUILD.gn index 5d82a44f..088fe7cb 100644 --- a/services/core/test/BUILD.gn +++ b/services/core/test/BUILD.gn @@ -324,20 +324,6 @@ ohos_unittest("dp_dm_adapter_test") { subsystem_name = "deviceprofile" } -ohos_unittest("distributed_device_profile_stub_new_test") { - module_out_path = module_output_path - sources = [ "unittest/distributed_device_profile_stub_new_test.cpp" ] - configs = device_profile_configs - deps = device_profile_deps - external_deps = device_profile_external_deps - part_name = "device_info_manager" - subsystem_name = "deviceprofile" - cflags = [ - "-Dprivate=public", - "-Dprotected=public", - ] -} - ohos_unittest("content_sensor_manager_utils_test") { module_out_path = module_output_path sources = [ "unittest/content_sensor_manager_utils_test.cpp" ] @@ -504,7 +490,6 @@ group("unittest") { ":device_profile_locd_callback_test", ":device_profile_manager_new_test", ":distributed_device_profile_client_kv_new_test", - ":distributed_device_profile_stub_new_test", ":dp_account_common_event_test", ":dp_content_sensor_test", ":dp_dm_adapter_test", diff --git a/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp b/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp index 56b98343..b2707cfb 100644 --- a/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp +++ b/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp @@ -101,7 +101,6 @@ void FuzzDeviceProfile(const uint8_t* rawData, size_t size) code += MIN_INTERFACE_CODE; } DistributedDeviceProfileServiceNew::GetInstance().OnRemoteRequest(code, data, reply, option); - DistributedDeviceProfileServiceNew::GetInstance().NotifyEventInner(code, data, reply, option); } } } diff --git a/services/core/test/unittest/distributed_device_profile_stub_new_test.cpp b/services/core/test/unittest/distributed_device_profile_stub_new_test.cpp deleted file mode 100644 index 4c77e733..00000000 --- a/services/core/test/unittest/distributed_device_profile_stub_new_test.cpp +++ /dev/null @@ -1,1132 +0,0 @@ -/* - * Copyright (c) 2024-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 -#include -#include - -#include "profile_utils.h" -#include "distributed_device_profile_constants.h" -#include "distributed_device_profile_client.h" -#include "distributed_device_profile_log.h" -#include "distributed_device_profile_errors.h" -#include "distributed_device_profile_enums.h" -#include "distributed_device_profile_stub_new.h" - -namespace OHOS { -namespace DistributedDeviceProfile { -using namespace testing::ext; -using namespace std; - -class MockDistributedDeviceProfileStubNew : public DistributedDeviceProfileStubNew { - int32_t PutAccessControlProfile(const AccessControlProfile& aclProfile) override; - int32_t UpdateAccessControlProfile(const AccessControlProfile& aclProfile) override; - int32_t GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile) override; - int32_t GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles) override; - int32_t GetAccessControlProfile(std::map queryParams, - std::vector& accessControlProfiles) override; - int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) override; - int32_t GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles) override; - int32_t DeleteAccessControlProfile(int32_t accessControlId) override; - int32_t PutSessionKey(uint32_t userId, const std::vector& sessionKey, int32_t& sessionKeyId) override; - int32_t GetSessionKey(uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey) override; - int32_t UpdateSessionKey(uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey) override; - int32_t DeleteSessionKey(uint32_t userId, int32_t sessionKeyId) override; - int32_t PutServiceProfile(const ServiceProfile& serviceProfile) override; - int32_t PutServiceProfileBatch(const std::vector& serviceProfiles) override; - int32_t PutCharacteristicProfile(const CharacteristicProfile& charProfile) override; - int32_t PutCharacteristicProfileBatch(const std::vector& charProfiles) override; - int32_t GetDeviceProfile(const std::string& deviceId, DeviceProfile& deviceProfile) override; - int32_t DeleteDeviceProfileBatch(std::vector& deviceProfiles) override; - int32_t GetServiceProfile(const std::string& deviceId, const std::string& serviceName, - ServiceProfile& serviceProfile) override; - int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, - const std::string& characteristicId, CharacteristicProfile& charProfile) override; - int32_t DeleteServiceProfile(const std::string& deviceId, const std::string& serviceName, bool isMultiUser = false, - int32_t userId = DEFAULT_USER_ID) override; - int32_t DeleteCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, - const std::string& characteristicId, bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID) override; - int32_t SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; - int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; - int32_t SubscribeDeviceProfileInited(int32_t saId, sptr dpInitedCallback) override; - int32_t UnSubscribeDeviceProfileInited(int32_t saId) override; - int32_t SubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType, - sptr pinCodeCallback) override; - int32_t UnSubscribePinCodeInvalid(const std::string& bundleName, int32_t pinExchangeType) override; - int32_t PutAllTrustedDevices(const std::vector deviceInfos) override; - int32_t SyncDeviceProfile(const DistributedDeviceProfile::DpSyncOptions& syncOptions, - sptr syncCompletedCallback) override; - int32_t SendSubscribeInfos(std::map listenerMap) override; - int32_t PutDeviceProfileBatch(std::vector& deviceProfiles) override; - int32_t GetDeviceProfiles(DeviceProfileFilterOptions& options, - std::vector& deviceProfiles) override; - int32_t PutProductInfoBatch(const std::vector& productInfos) override; - int32_t PutDeviceIconInfoBatch(const std::vector& deviceIconInfos) override; - int32_t GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, - std::vector& deviceIconInfos) override; - int32_t PutServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) override; - int32_t DeleteServiceInfoProfile(const ServiceInfoUniqueKey& key) override; - int32_t UpdateServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) override; - int32_t GetServiceInfoProfileByUniqueKey(const ServiceInfoUniqueKey& key, - ServiceInfoProfile& serviceInfoProfile) override; - int32_t GetServiceInfoProfileListByTokenId(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) override; - int32_t GetAllServiceInfoProfileList(std::vector& serviceInfoProfiles) override; - int32_t GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) override; - int32_t PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo) override; - int32_t UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo) override; - int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, - int32_t pinExchangeType, LocalServiceInfo& localServiceInfo) override; - int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType) override; - void DelayUnloadTask() override; - bool IsInited() override; -}; - -class DistributedDeviceProfileStubNewTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::shared_ptr ProfileStub_ = nullptr; -}; - -void DistributedDeviceProfileStubNewTest::SetUpTestCase(void) -{ -} - -void DistributedDeviceProfileStubNewTest::TearDownTestCase(void) -{ -} - -void DistributedDeviceProfileStubNewTest::SetUp() -{ - ProfileStub_ = std::make_shared(); -} - -void DistributedDeviceProfileStubNewTest::TearDown() -{ - ProfileStub_ = nullptr; -} - -int32_t MockDistributedDeviceProfileStubNew::PutAccessControlProfile(const AccessControlProfile& aclProfile) -{ - (void)aclProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::UpdateAccessControlProfile(const AccessControlProfile& aclProfile) -{ - (void)aclProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetTrustDeviceProfile(const std::string& deviceId, - TrustDeviceProfile& trustDeviceProfile) -{ - (void)deviceId; - (void)trustDeviceProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetAllTrustDeviceProfile( - std::vector& trustDeviceProfiles) -{ - (void)trustDeviceProfiles; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::DeleteDeviceProfileBatch(std::vector& deviceProfiles) -{ - (void)deviceProfiles; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::GetAccessControlProfile(std::map queryParams, - std::vector& accessControlProfiles) -{ - (void)queryParams; - (void)accessControlProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetAllAccessControlProfile( - std::vector& accessControlProfiles) -{ - (void)accessControlProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetAllAclIncludeLnnAcl( - std::vector& accessControlProfiles) -{ - (void)accessControlProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::DeleteAccessControlProfile(int32_t accessControlId) -{ - (void)accessControlId; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::PutSessionKey( - uint32_t userId, const std::vector& sessionKey, int32_t& sessionKeyId) -{ - (void)userId; - (void)sessionKey; - (void)sessionKeyId; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetSessionKey( - uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey) -{ - (void)userId; - (void)sessionKey; - (void)sessionKeyId; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::UpdateSessionKey( - uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey) -{ - (void)userId; - (void)sessionKey; - (void)sessionKeyId; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::DeleteSessionKey(uint32_t userId, int32_t sessionKeyId) -{ - (void)userId; - (void)sessionKeyId; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::PutServiceProfile(const ServiceProfile& serviceProfile) -{ - (void)serviceProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::PutServiceProfileBatch(const std::vector& serviceProfiles) -{ - (void)serviceProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::PutCharacteristicProfile(const CharacteristicProfile& charProfile) -{ - (void)charProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::PutCharacteristicProfileBatch( - const std::vector& charProfiles) -{ - (void)charProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetDeviceProfile(const std::string& deviceId, - DeviceProfile& deviceProfile) -{ - (void)deviceId; - (void)deviceProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetServiceProfile(const std::string& deviceId, - const std::string& serviceName, ServiceProfile& serviceProfile) -{ - (void)deviceId; - (void)serviceName; - (void)serviceProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetCharacteristicProfile(const std::string& deviceId, - const std::string& serviceName, const std::string& characteristicId, CharacteristicProfile& charProfile) -{ - (void)deviceId; - (void)serviceName; - (void)characteristicId; - (void)charProfile; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::DeleteServiceProfile(const std::string& deviceId, - const std::string& serviceName, bool isMultiUser, int32_t userId) -{ - (void)deviceId; - (void)serviceName; - (void)isMultiUser; - (void)userId; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::DeleteCharacteristicProfile(const std::string& deviceId, - const std::string& serviceName, const std::string& characteristicId, bool isMultiUser, int32_t userId) -{ - (void)deviceId; - (void)serviceName; - (void)characteristicId; - (void)isMultiUser; - (void)userId; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) -{ - (void)subscribeInfo; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) -{ - (void)subscribeInfo; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::SubscribeDeviceProfileInited(int32_t saId, - sptr dpInitedCallback) -{ - (void)saId; - (void)dpInitedCallback; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::UnSubscribeDeviceProfileInited(int32_t saId) -{ - (void)saId; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::SubscribePinCodeInvalid(const std::string& bundleName, - int32_t pinExchangeType, sptr pinCodeCallback) -{ - (void)bundleName; - (void)pinExchangeType; - (void)pinCodeCallback; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::UnSubscribePinCodeInvalid(const std::string& bundleName, - int32_t pinExchangeType) -{ - (void)bundleName; - (void)pinExchangeType; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::PutAllTrustedDevices(const std::vector deviceInfos) -{ - (void)deviceInfos; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::SyncDeviceProfile( - const DistributedDeviceProfile::DpSyncOptions& syncOptions, sptr syncCompletedCallback) -{ - (void)syncOptions; - (void)syncCompletedCallback; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::SendSubscribeInfos(std::map listenerMap) -{ - (void)listenerMap; - return 0; -} -void MockDistributedDeviceProfileStubNew::DelayUnloadTask() -{ - return; -} -bool MockDistributedDeviceProfileStubNew::IsInited() -{ - return true; -} - -int32_t MockDistributedDeviceProfileStubNew::GetDeviceProfiles(DeviceProfileFilterOptions& options, - std::vector& deviceProfiles) -{ - (void)options; - (void)deviceProfiles; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::PutDeviceProfileBatch(std::vector& deviceProfiles) -{ - (void)deviceProfiles; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::PutProductInfoBatch(const std::vector& productInfos) -{ - (void)productInfos; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::PutDeviceIconInfoBatch(const std::vector& deviceIconInfos) -{ - (void)deviceIconInfos; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, - std::vector& deviceIconInfos) -{ - (void)filterOptions; - (void)deviceIconInfos; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::PutServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) -{ - (void)serviceInfoProfile; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::DeleteServiceInfoProfile(const ServiceInfoUniqueKey& key) -{ - (void)key; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::UpdateServiceInfoProfile(const ServiceInfoProfile& serviceInfoProfile) -{ - (void)serviceInfoProfile; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::GetServiceInfoProfileByUniqueKey(const ServiceInfoUniqueKey& key, - ServiceInfoProfile& serviceInfoProfile) -{ - (void)key; - (void)serviceInfoProfile; - return 0; -} - -int32_t MockDistributedDeviceProfileStubNew::GetServiceInfoProfileListByTokenId(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) -{ - (void)key; - (void)serviceInfoProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetAllServiceInfoProfileList( - std::vector& serviceInfoProfiles) -{ - (void)serviceInfoProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, - std::vector& serviceInfoProfiles) -{ - (void)key; - (void)serviceInfoProfiles; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::PutLocalServiceInfo(const LocalServiceInfo& localServiceInfo) -{ - (void)localServiceInfo; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::UpdateLocalServiceInfo(const LocalServiceInfo& localServiceInfo) -{ - (void)localServiceInfo; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, - int32_t pinExchangeType, LocalServiceInfo& localServiceInfo) -{ - (void)bundleName; - (void)pinExchangeType; - (void)localServiceInfo; - return 0; -} -int32_t MockDistributedDeviceProfileStubNew::DeleteLocalServiceInfo(const std::string& bundleName, - int32_t pinExchangeType) -{ - (void)bundleName; - (void)pinExchangeType; - return 0; -} -/** - * @tc.name: IsInterfaceTokenValid001 - * @tc.desc: IsInterfaceTokenValid - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, IsInterfaceTokenValid_001, TestSize.Level1) -{ - std::shared_ptr devProStubNew = - std::make_shared(); - - MessageParcel data; - bool ret = ProfileStub_->IsInterfaceTokenValid(data); - EXPECT_EQ(false, ret); -} - -/** - * @tc.name: OnRemoteRequest001 - * @tc.desc: OnRemoteRequest - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, OnRemoteRequest_001, TestSize.Level1) -{ - uint32_t code = static_cast(DPInterfaceCode::ON_TRUST_DEVICE_PROFILE_ADD); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(DP_INTERFACE_CHECK_FAILED, ret); -} - -/** - * @tc.name: OnRemoteRequest002 - * @tc.desc: OnRemoteRequest - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, OnRemoteRequest_002, TestSize.Level1) -{ - uint32_t code = static_cast(DPInterfaceCode::PUT_ACL_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(DP_INTERFACE_CHECK_FAILED, ret); -} - -/** - * @tc.name: PutAccessControlProfileInner001 - * @tc.desc: PutAccessControlProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, PutAccessControlProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->PutAccessControlProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: UpdateAccessControlProfileInner001 - * @tc.desc: UpdateAccessControlProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, UpdateAccessControlProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->UpdateAccessControlProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: GetTrustDeviceProfileInner001 - * @tc.desc: GetTrustDeviceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, GetTrustDeviceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->GetTrustDeviceProfileInner(data, reply); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: GetAllTrustDeviceProfileInner001 - * @tc.desc: GetAllTrustDeviceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, GetAllTrustDeviceProfileInner_001, TestSize.Level1) -{ - std::string udid = "udid"; - std::string serviceId = "serviceId"; - MessageParcel data; - MessageParcel reply; - data.WriteString(udid); - data.WriteString(serviceId); - int32_t ret = ProfileStub_->GetAllTrustDeviceProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: GetAccessControlProfileInner001 - * @tc.desc: GetAccessControlProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, GetAccessControlProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->GetAccessControlProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: GetAllAccessControlProfileInner001 - * @tc.desc: GetAllAccessControlProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, GetAllAccessControlProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->GetAllAccessControlProfileInner(data, reply); - EXPECT_EQ(DP_WRITE_PARCEL_FAIL, ret); -} - -/** - * @tc.name: DeleteAccessControlProfileInner001 - * @tc.desc: DeleteAccessControlProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, DeleteAccessControlProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->DeleteAccessControlProfileInner(data, reply); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: PutServiceProfileInner001 - * @tc.desc: PutServiceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, PutServiceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->PutServiceProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: PutServiceProfileBatchInner001 - * @tc.desc: PutServiceProfileBatchInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, PutServiceProfileBatchInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->PutServiceProfileBatchInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: PutCharacteristicProfileBatchInner001 - * @tc.desc: PutCharacteristicProfileBatchInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, PutCharacteristicProfileBatchInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->PutCharacteristicProfileBatchInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: GetDeviceProfileInner001 - * @tc.desc: GetDeviceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, GetDeviceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->GetDeviceProfileInner(data, reply); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: GetServiceProfileInner001 - * @tc.desc: GetServiceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, GetServiceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->GetServiceProfileInner(data, reply); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: GetCharacteristicProfileInner001 - * @tc.desc: GetCharacteristicProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, GetCharacteristicProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->GetCharacteristicProfileInner(data, reply); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: DeleteServiceProfileInner001 - * @tc.desc: DeleteServiceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, DeleteServiceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->DeleteServiceProfileInner(data, reply); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: DeleteCharacteristicProfileInner001 - * @tc.desc: DeleteCharacteristicProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, DeleteCharacteristicProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->DeleteServiceProfileInner(data, reply); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: SubscribeDeviceProfileInner001 - * @tc.desc: SubscribeDeviceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, SubscribeDeviceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->SubscribeDeviceProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: UnSubscribeDeviceProfileInner001 - * @tc.desc: UnSubscribeDeviceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, UnSubscribeDeviceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->UnSubscribeDeviceProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: SyncDeviceProfileInner001 - * @tc.desc: SyncDeviceProfileInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, SyncDeviceProfileInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->SyncDeviceProfileInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: SendSubscribeInfosInner001 - * @tc.desc: SendSubscribeInfosInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, SendSubscribeInfosInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->SendSubscribeInfosInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_001 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_001, TestSize.Level0) -{ - uint32_t code = 1000; - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(305, ret); -} - -/** - * @tc.name: NotifyAclEventInner_002 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_002, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::PUT_ACL_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_003 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_003, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::UPDATE_ACL_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_004 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_004, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::GET_TRUST_DEVICE_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: NotifyAclEventInner_005 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_005, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::GET_ALL_TRUST_DEVICE_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_006 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_006, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::GET_ACL_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_007 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_007, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::GET_ALL_ACL_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_WRITE_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_008 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_008, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::DELETE_ACL_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: NotifyAclEventInner_009 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_009, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_010 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_010, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_011 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_011, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::SEND_SUBSCRIBE_INFOS); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_012 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_012, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_013 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_013, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::PUT_SERVICE_PROFILE_BATCH); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_014 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_014, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::PUT_CHAR_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyAclEventInner_015 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyAclEventInner_015, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::PUT_CHAR_PROFILE_BATCH); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyAclEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyEventInner_001 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyEventInner_001, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::GET_DEVICE_PROFILE_NEW); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyEventInner(code, data, reply, option); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: NotifyEventInner_002 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyEventInner_002, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::GET_SERVICE_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyEventInner(code, data, reply, option); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: NotifyEventInner_003 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyEventInner_003, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::GET_CHAR_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyEventInner(code, data, reply, option); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: NotifyEventInner_004 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyEventInner_004, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::DEL_SERVICE_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyEventInner(code, data, reply, option); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: NotifyEventInner_005 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyEventInner_005, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::DEL_CHAR_PROFILE); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyEventInner(code, data, reply, option); - EXPECT_EQ(ERR_FLATTEN_OBJECT, ret); -} - -/** - * @tc.name: NotifyEventInner_006 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyEventInner_006, TestSize.Level0) -{ - uint32_t code = static_cast(DPInterfaceCode::SYNC_DEVICE_PROFILE_NEW); - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyEventInner(code, data, reply, option); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} - -/** - * @tc.name: NotifyEventInner_007 - * @tc.desc: succeed - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, NotifyEventInner_007, TestSize.Level0) -{ - uint32_t code = 1000; - MessageParcel data; - MessageParcel reply; - MessageOption option; - int32_t ret = ProfileStub_->NotifyEventInner(code, data, reply, option); - EXPECT_EQ(305, ret); -} - -/** - * @tc.name: PutAllTrustedDevicesInner001 - * @tc.desc: PutAllTrustedDevicesInner - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(DistributedDeviceProfileStubNewTest, PutAllTrustedDevicesInner_001, TestSize.Level1) -{ - MessageParcel data; - MessageParcel reply; - int32_t ret = ProfileStub_->PutAllTrustedDevicesInner(data, reply); - EXPECT_EQ(DP_READ_PARCEL_FAIL, ret); -} -} // namespace DistributedDeviceProfile -} // namespace OHOS -- Gitee From c1951dc8aaee51e5dbe6d7ce09e9af594b869ad3 Mon Sep 17 00:00:00 2001 From: BrainL Date: Wed, 4 Jun 2025 16:03:56 +0800 Subject: [PATCH 2/9] fixed codecheck Signed-off-by: BrainL Change-Id: I76f632c0a51f37b3d16d9593768291b032a4e812 --- interfaces/innerkits/core/BUILD.gn | 2 ++ .../subscribeprofilemanager/subscribe_profile_manager.cpp | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/interfaces/innerkits/core/BUILD.gn b/interfaces/innerkits/core/BUILD.gn index 5e791296..480b01a8 100644 --- a/interfaces/innerkits/core/BUILD.gn +++ b/interfaces/innerkits/core/BUILD.gn @@ -94,6 +94,8 @@ ohos_shared_library("distributed_device_profile_sdk") { boundary_sanitize = true integer_overflow = true ubsan = true + cfi = true + cfi_cross_dso = true debug = false } diff --git a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp index 065e1c2d..65678f6c 100644 --- a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp +++ b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp @@ -515,8 +515,9 @@ int32_t SubscribeProfileManager::NotifyCharProfileDelete(const std::string& dbKe return DP_SUCCESS; } -std::unordered_set -SubscribeProfileManager::GetSubscribeInfos(const std::string& dbKey) +std::unordered_set SubscribeProfileManager::GetSubscribeInfos(const std::string& dbKey) { { std::lock_guard lock(subscribeMutex_); -- Gitee From 692eeafda7603d310d7bd0744ae65805beb19025 Mon Sep 17 00:00:00 2001 From: BrainL Date: Thu, 5 Jun 2025 11:21:12 +0800 Subject: [PATCH 3/9] codecheck modify. Signed-off-by: BrainL Change-Id: I0b874d7850a0735af70bf43b75e8f76b4546e001 --- .../interfaces/dp_subscribe_info_extension.h | 24 +++++++------- .../dp_subscribe_info_extension.cpp | 18 +++++------ .../core/IDistributedDeviceProfile.idl | 8 ++--- .../distributed_device_profile_client.h | 2 +- .../src/distributed_device_profile_client.cpp | 2 +- .../distributed_device_profile_service_new.h | 6 ++-- .../subscribe_profile_manager.h | 10 +++--- ...distributed_device_profile_service_new.cpp | 6 ++-- .../subscribe_profile_manager.cpp | 11 +++---- ...tributed_device_profile_client_kv_test.cpp | 32 +++++++++---------- ...ributed_device_profile_client_rdb_test.cpp | 4 +-- 11 files changed, 61 insertions(+), 62 deletions(-) diff --git a/common/include/interfaces/dp_subscribe_info_extension.h b/common/include/interfaces/dp_subscribe_info_extension.h index 359d5e60..57ccb38c 100644 --- a/common/include/interfaces/dp_subscribe_info_extension.h +++ b/common/include/interfaces/dp_subscribe_info_extension.h @@ -28,19 +28,19 @@ namespace OHOS { namespace DistributedDeviceProfile { -class SubscribeInfoExtension : public Parcelable, public SubscribeInfo { +class SubscribeInfoExt : public Parcelable, public SubscribeInfo { public: - SubscribeInfoExtension(int32_t saId, const std::string& subscribeKey, + SubscribeInfoExt(int32_t saId, const std::string& subscribeKey, std::unordered_set subscribeChangeTypes, sptr profileChangeListener, int32_t userId = DEFAULT_USER_ID); - SubscribeInfoExtension(const SubscribeInfo& subscribeInfo); - SubscribeInfoExtension(); - ~SubscribeInfoExtension(); + SubscribeInfoExt(const SubscribeInfo& subscribeInfo); + SubscribeInfoExt(); + ~SubscribeInfoExt(); bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; - static SubscribeInfoExtension *Unmarshalling(Parcel &parcel); + static SubscribeInfoExt *Unmarshalling(Parcel &parcel); private: int32_t saId_ = -1; @@ -49,16 +49,16 @@ private: sptr listener_ = nullptr; }; -class SubscribeExtensionCompare : public SubscribeCompare { +class SubscribeExtCompare : public SubscribeCompare { public: - SubscribeExtensionCompare() = default; - ~SubscribeExtensionCompare() = default; + SubscribeExtCompare() = default; + ~SubscribeExtCompare() = default; }; -class SubscribeExtensionHash : public SubscribeHash { +class SubscribeExtHash : public SubscribeHash { public: - SubscribeExtensionHash() = default; - ~SubscribeExtensionHash() = default; + SubscribeExtHash() = default; + ~SubscribeExtHash() = default; }; } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/src/interfaces/dp_subscribe_info_extension.cpp b/common/src/interfaces/dp_subscribe_info_extension.cpp index b78087a1..f8b3dd11 100644 --- a/common/src/interfaces/dp_subscribe_info_extension.cpp +++ b/common/src/interfaces/dp_subscribe_info_extension.cpp @@ -24,9 +24,9 @@ namespace OHOS { namespace DistributedDeviceProfile { namespace { - const std::string TAG = "SubscribeInfoExtension"; + const std::string TAG = "SubscribeInfoExt"; } -SubscribeInfoExtension::SubscribeInfoExtension(int32_t saId, const std::string& subscribeKey, +SubscribeInfoExt::SubscribeInfoExt(int32_t saId, const std::string& subscribeKey, std::unordered_set subscribeChangeTypes, sptr profileChangeListener, int32_t userId) @@ -48,7 +48,7 @@ SubscribeInfoExtension::SubscribeInfoExtension(int32_t saId, const std::string& this->listener_ = profileChangeListener->AsObject(); } -SubscribeInfoExtension::SubscribeInfoExtension(const SubscribeInfo& subscribeInfo) +SubscribeInfoExt::SubscribeInfoExt(const SubscribeInfo& subscribeInfo) { this->saId_ = subscribeInfo.GetSaId(); this->subscribeKey_ = subscribeInfo.GetSubscribeKey(); @@ -60,15 +60,15 @@ SubscribeInfoExtension::SubscribeInfoExtension(const SubscribeInfo& subscribeInf this->listener_ = subscribeInfo.GetListener(); } -SubscribeInfoExtension::SubscribeInfoExtension() +SubscribeInfoExt::SubscribeInfoExt() { } -SubscribeInfoExtension::~SubscribeInfoExtension() +SubscribeInfoExt::~SubscribeInfoExt() { } -bool SubscribeInfoExtension::ReadFromParcel(Parcel &parcel) +bool SubscribeInfoExt::ReadFromParcel(Parcel &parcel) { READ_HELPER_RET(parcel, Int32, saId_, false); READ_HELPER_RET(parcel, String, subscribeKey_, false); @@ -91,9 +91,9 @@ bool SubscribeInfoExtension::ReadFromParcel(Parcel &parcel) return true; } -SubscribeInfoExtension *SubscribeInfoExtension::Unmarshalling(Parcel &parcel) +SubscribeInfoExt *SubscribeInfoExt::Unmarshalling(Parcel &parcel) { - SubscribeInfoExtension *subscribeInfoExtension = new (std::nothrow) SubscribeInfoExtension(); + SubscribeInfoExt *subscribeInfoExtension = new (std::nothrow) SubscribeInfoExt(); if (subscribeInfoExtension == nullptr) { return nullptr; } @@ -106,7 +106,7 @@ SubscribeInfoExtension *SubscribeInfoExtension::Unmarshalling(Parcel &parcel) return subscribeInfoExtension; } -bool SubscribeInfoExtension::Marshalling(Parcel& parcel) const +bool SubscribeInfoExt::Marshalling(Parcel& parcel) const { WRITE_HELPER_RET(parcel, Int32, saId_, false); WRITE_HELPER_RET(parcel, String, subscribeKey_, false); diff --git a/interfaces/innerkits/core/IDistributedDeviceProfile.idl b/interfaces/innerkits/core/IDistributedDeviceProfile.idl index 6aac8138..39944a4a 100644 --- a/interfaces/innerkits/core/IDistributedDeviceProfile.idl +++ b/interfaces/innerkits/core/IDistributedDeviceProfile.idl @@ -18,7 +18,7 @@ sequenceable OHOS.DistributedDeviceProfile.DeviceProfile; sequenceable OHOS.DistributedDeviceProfile.ServiceProfile; sequenceable OHOS.DistributedDeviceProfile.CharacteristicProfile; sequenceable OHOS.DistributedDeviceProfile.AccessControlProfile; -sequenceable dp_subscribe_info_extension..OHOS.DistributedDeviceProfile.SubscribeInfoExtension; +sequenceable dp_subscribe_info_extension..OHOS.DistributedDeviceProfile.SubscribeInfoExt; sequenceable dp_sync_options..OHOS.DistributedDeviceProfile.DpSyncOptions; sequenceable OHOS.DistributedDeviceProfile.TrustedDeviceInfo; sequenceable OHOS.DistributedDeviceProfile.DeviceProfileFilterOptions; @@ -55,13 +55,13 @@ interface OHOS.DistributedDeviceProfile.IDistributedDeviceProfile { [in] boolean isMultiUser, [in] int userId); [ipccode 22] void DeleteCharacteristicProfile([in] String deviceId, [in] String serviceName, [in] String characteristicId, [in] boolean isMultiUser, [in] int userId); - [ipccode 23] void SubscribeDeviceProfile([in] SubscribeInfoExtension subscribeInfoExtension); - [ipccode 24] void UnSubscribeDeviceProfile([in] SubscribeInfoExtension subscribeInfoExtension); + [ipccode 23] void SubscribeDeviceProfile([in] SubscribeInfoExt subscribeInfoExtension); + [ipccode 24] void UnSubscribeDeviceProfile([in] SubscribeInfoExt subscribeInfoExtension); [ipccode 41] void SubscribeDeviceProfileInited([in] int saId, [in] IRemoteObject dpInitedCallback); [ipccode 42] void UnSubscribeDeviceProfileInited([in] int saId); [ipccode 25] void SyncDeviceProfile([in] DpSyncOptions syncOptions, [in] IRemoteObject syncCompletedCallback); - [ipccode 26] void SendSubscribeInfos([out] OrderedMap listenerMap); + [ipccode 26] void SendSubscribeInfos([out] OrderedMap listenerMap); [ipccode 45] void PutAllTrustedDevices([in] TrustedDeviceInfo[] deviceInfos); [ipccode 50] void PutProductInfoBatch([in] ProductInfo[] productInfos); [ipccode 49] void PutDeviceIconInfoBatch([in] DeviceIconInfo[] deviceIconInfos); diff --git a/interfaces/innerkits/core/include/distributed_device_profile_client.h b/interfaces/innerkits/core/include/distributed_device_profile_client.h index 42251245..27401e71 100644 --- a/interfaces/innerkits/core/include/distributed_device_profile_client.h +++ b/interfaces/innerkits/core/include/distributed_device_profile_client.h @@ -150,7 +150,7 @@ private: std::mutex subscribeLock_; std::map subscribeInfos_; - std::map subscribeInfoExtensions_; + std::map subscribeInfoExtensions_; std::mutex saListenerLock_; sptr saListenerCallback_ = nullptr; diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index a3de6fe0..93c2fe5f 100644 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -126,7 +126,7 @@ void DistributedDeviceProfileClient::SendSubscribeInfosToService() subscribeInfoExtensions_.clear(); for (const auto& subscribeInfo : subscribeInfos_) { - SubscribeInfoExtension subscribeInfoExtension(subscribeInfo.second); + SubscribeInfoExt subscribeInfoExtension(subscribeInfo.second); subscribeInfoExtensions_.insert(std::make_pair(subscribeInfo.first, subscribeInfoExtension)); } dpService->SendSubscribeInfos(subscribeInfoExtensions_); diff --git a/services/core/include/distributed_device_profile_service_new.h b/services/core/include/distributed_device_profile_service_new.h index fac2fa5b..ee3e9453 100644 --- a/services/core/include/distributed_device_profile_service_new.h +++ b/services/core/include/distributed_device_profile_service_new.h @@ -93,8 +93,8 @@ public: int32_t GetAllServiceInfoProfileList(std::vector& serviceInfoProfiles) override; int32_t GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, std::vector& serviceInfoProfiles) override; - int32_t SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfoExtension) override; - int32_t UnSubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfoExtension) override; + int32_t SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension) override; + int32_t UnSubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension) override; int32_t SyncDeviceProfile(const DistributedDeviceProfile::DpSyncOptions& syncOptions, const sptr& syncCompletedCallback) override; int32_t SubscribeDeviceProfileInited(int32_t saId, const sptr& dpInitedCallback) override; @@ -108,7 +108,7 @@ public: int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, int32_t pinExchangeType, LocalServiceInfo& localServiceInfo)override; int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType)override; - int32_t SendSubscribeInfos(std::map& listenerMap) override; + int32_t SendSubscribeInfos(std::map& listenerMap) override; int32_t Dump(int32_t fd, const std::vector& args) override; void DelayUnloadTask(); bool IsInited(); diff --git a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h index f38687d5..31866e5b 100644 --- a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h +++ b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h @@ -42,9 +42,9 @@ public: int32_t NotifyTrustDeviceProfileDelete(const TrustDeviceProfile& trustDeviceProfile); int32_t NotifyTrustDeviceProfileActive(const TrustDeviceProfile& trustDeviceProfile); int32_t NotifyTrustDeviceProfileInactive(const TrustDeviceProfile& trustDeviceProfile); - int32_t SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfo); - int32_t SubscribeDeviceProfile(std::map subscribeInfos); - int32_t UnSubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfo); + int32_t SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfo); + int32_t SubscribeDeviceProfile(std::map subscribeInfos); + int32_t UnSubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfo); private: int32_t NotifyDeviceProfileAdd(const std::string& dbKey, const std::string& dbValue); @@ -56,7 +56,7 @@ private: int32_t NotifyCharProfileAdd(const std::string& dbKey, const std::string& dbValue); int32_t NotifyCharProfileUpdate(const std::string& dbKey, const std::string& dbValue); int32_t NotifyCharProfileDelete(const std::string& dbKey, const std::string& dbValue); - std::unordered_set GetSubscribeInfos( + std::unordered_set GetSubscribeInfos( const std::string& dbKey); std::string DBKeyToSubcribeKey(const std::string& dbkey); @@ -65,7 +65,7 @@ private: std::mutex funcsMutex_; std::map funcsMap_; std::mutex subscribeMutex_; - std::map> + std::map> subscribeInfoExtensionMap_; }; } // namespace DistributedDeviceProfile diff --git a/services/core/src/distributed_device_profile_service_new.cpp b/services/core/src/distributed_device_profile_service_new.cpp index 74aaf7df..bc6c3489 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -784,7 +784,7 @@ int32_t DistributedDeviceProfileServiceNew::DeleteLocalServiceInfo(const std::st return ret; } -int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfoExtension) +int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); @@ -797,7 +797,7 @@ int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfile(const Subscri } int32_t DistributedDeviceProfileServiceNew::UnSubscribeDeviceProfile( - const SubscribeInfoExtension& subscribeInfoExtension) + const SubscribeInfoExt& subscribeInfoExtension) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); @@ -823,7 +823,7 @@ int32_t DistributedDeviceProfileServiceNew::SyncDeviceProfile( } int32_t DistributedDeviceProfileServiceNew::SendSubscribeInfos( - std::map& listenerMap) + std::map& listenerMap) { return SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(listenerMap); } diff --git a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp index 65678f6c..4f5c06dd 100644 --- a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp +++ b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp @@ -199,7 +199,7 @@ int32_t SubscribeProfileManager::NotifyTrustDeviceProfileInactive(const TrustDev return DP_SUCCESS; } -int32_t SubscribeProfileManager::SubscribeDeviceProfile(const SubscribeInfoExtension& subscribeInfo) +int32_t SubscribeProfileManager::SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfo) { HILOGI("saId: %{public}d!, subscribeKey: %{public}s", subscribeInfo.GetSaId(), ProfileUtils::GetDbKeyAnonyString(subscribeInfo.GetSubscribeKey()).c_str()); @@ -224,7 +224,7 @@ int32_t SubscribeProfileManager::SubscribeDeviceProfile(const SubscribeInfoExten return DP_SUCCESS; } -int32_t SubscribeProfileManager::SubscribeDeviceProfile(std::map subscribeInfos) +int32_t SubscribeProfileManager::SubscribeDeviceProfile(std::map subscribeInfos) { HILOGD("call!"); for (auto item : subscribeInfos) { @@ -233,7 +233,7 @@ int32_t SubscribeProfileManager::SubscribeDeviceProfile(std::map SubscribeProfileManager::GetSubscribeInfos(const std::string& dbKey) +std::unordered_set SubscribeProfileManager::GetSubscribeInfos + (const std::string& dbKey) { { std::lock_guard lock(subscribeMutex_); diff --git a/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp b/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp index e6d45f20..509b19cc 100644 --- a/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp @@ -183,7 +183,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfile001, TestSize.Le HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch001, TestSize.Level1) { vector serviceProfiles; - + ServiceProfile serviceProfile1; serviceProfile1.SetDeviceId("deviceId1"); serviceProfile1.SetServiceName("serviceName1"); @@ -194,7 +194,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch001, TestSi serviceProfile2.SetServiceType("serviceType2"); serviceProfiles.push_back(serviceProfile1); serviceProfiles.push_back(serviceProfile2); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceProfileBatch(serviceProfiles); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -208,7 +208,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch001, TestSi HWTEST_F(DistributedDeviceProfileClientKvTest, PutServiceProfileBatch002, TestSize.Level1) { vector serviceProfiles; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutServiceProfileBatch(serviceProfiles); EXPECT_EQ(errCode, DP_INVALID_PARAMS); } @@ -226,7 +226,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfile001, Test charProfile.SetServiceName("serviceName"); charProfile.SetCharacteristicKey("characteristicKey"); charProfile.SetCharacteristicValue("characteristicValue"); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutCharacteristicProfile(charProfile); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -240,7 +240,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfile001, Test HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch001, TestSize.Level1) { vector charProfiles; - + CharacteristicProfile charProfile1; charProfile1.SetDeviceId("deviceId1"); charProfile1.SetServiceName("serviceName1"); @@ -267,7 +267,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch001, HWTEST_F(DistributedDeviceProfileClientKvTest, PutCharacteristicProfileBatch002, TestSize.Level1) { vector charProfiles; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutCharacteristicProfileBatch(charProfiles); EXPECT_EQ(errCode, DP_INVALID_PARAMS); } @@ -282,7 +282,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceProfile001, TestSize.Lev { string deviceId = "deviceId"; DeviceProfile deviceProfile; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetDeviceProfile(deviceId, deviceProfile); EXPECT_NE(errCode, DP_SUCCESS); @@ -319,7 +319,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetServiceProfile001, TestSize.Le string deviceId = "deviceId"; string serviceName = "serviceName"; ServiceProfile serviceProfile; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetServiceProfile( deviceId, serviceName, serviceProfile); EXPECT_NE(errCode, DP_SUCCESS); @@ -337,7 +337,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetCharacteristicProfile001, Test string serviceName = "serviceName"; string characteristicKey = "characteristicKey"; CharacteristicProfile characteristicProfile; - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetCharacteristicProfile( deviceId, serviceName, characteristicKey, characteristicProfile); EXPECT_NE(errCode, DP_SUCCESS); @@ -391,7 +391,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, SubscribeDeviceProfile001, TestSi OHOS::sptr subscribeDPChangeListener = OHOS::sptr(new SubscribeDPChangeListener); SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().SubscribeDeviceProfile(subscribeInfo); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -414,7 +414,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, UnSubscribeDeviceProfile001, Test OHOS::sptr subscribeDPChangeListener = OHOS::sptr(new SubscribeDPChangeListener); SubscribeInfo subscribeInfo(saId, subscribeKey, subscribeTypes, subscribeDPChangeListener); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().UnSubscribeDeviceProfile(subscribeInfo); EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } @@ -429,11 +429,11 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, SyncDeviceProfile001, TestSize.Le { DistributedDeviceProfile::DpSyncOptions syncOptions; OHOS::sptr syncCb = nullptr; - + syncOptions.AddDevice("deviceId1"); syncOptions.AddDevice("deviceId2"); syncOptions.SetSyncMode(SyncMode::MIN); - + int32_t errCode = DistributedDeviceProfileClient::GetInstance().SyncDeviceProfile(syncOptions, syncCb); EXPECT_EQ(errCode, DP_SYNC_DEVICE_FAIL); } @@ -633,7 +633,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, PutDeviceProfileBatch_001, TestSi { std::vector deviceProfiles; int32_t errCode = DistributedDeviceProfileClient::GetInstance().PutDeviceProfileBatch(deviceProfiles); - EXPECT_EQ(errCode, DP_WRITE_PARCEL_FAIL); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } /** @@ -660,7 +660,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, DeleteDeviceProfileBatch_001, Tes { std::vector deviceProfiles; int32_t errCode = DistributedDeviceProfileClient::GetInstance().DeleteDeviceProfileBatch(deviceProfiles); - EXPECT_EQ(errCode, DP_WRITE_PARCEL_FAIL); + EXPECT_EQ(errCode, DP_PERMISSION_DENIED); } /** @@ -687,7 +687,7 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceIconInfos_001, TestSize. DeviceIconInfoFilterOptions filterOptions; std::vector deviceIconInfos; int32_t errCode = DistributedDeviceProfileClient::GetInstance().GetDeviceIconInfos(filterOptions, deviceIconInfos); - EXPECT_EQ(errCode, DP_PERMISSION_DENIED); + EXPECT_EQ(errCode, ERR_INVALID_DATA); } /** diff --git a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp index 8fe8e11b..8e1dad40 100644 --- a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp @@ -117,7 +117,7 @@ void DistributedDeviceProfileClientRdbTest::SetUpTestCase() std::string subscribekey = "trust_device_profile"; std::unordered_set subscribeTypes = {ProfileChangeType::TRUST_DEVICE_PROFILE_ADD, ProfileChangeType::TRUST_DEVICE_PROFILE_UPDATE, ProfileChangeType::TRUST_DEVICE_PROFILE_DELETE}; - + OHOS::sptr subscribeDPChangeListener = OHOS::sptr(new SubscribeDPChangeListener); SubscribeInfo subscribeInfo(saId, subscribekey, subscribeTypes, subscribeDPChangeListener); @@ -196,7 +196,7 @@ HWTEST_F(DistributedDeviceProfileClientRdbTest, PutAccessControlProfile_001, Tes value.Clear(); ProfileUtils::AccesseeToEntries(profile, value); ProfileUtils::EntriesToAccessee(value, accessee); - EXPECT_EQ(ret, DP_PERMISSION_DENIED); + EXPECT_EQ(ret, ERR_INVALID_DATA); } /* -- Gitee From fb3c630ad6228b61c949cdc6a24e6344414af74c Mon Sep 17 00:00:00 2001 From: BrainL Date: Fri, 6 Jun 2025 16:43:36 +0800 Subject: [PATCH 4/9] code check Signed-off-by: BrainL --- common/include/interfaces/access_control_profile.h | 4 ++-- common/include/interfaces/device_icon_info_filter_options.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/include/interfaces/access_control_profile.h b/common/include/interfaces/access_control_profile.h index ef8feee2..9a889a25 100644 --- a/common/include/interfaces/access_control_profile.h +++ b/common/include/interfaces/access_control_profile.h @@ -63,8 +63,8 @@ public: void SetDeviceIdHash(const std::string& deviceIdHash); std::string GetExtraData() const; void SetExtraData(const std::string& extraData); - bool Marshalling(MessageParcel& parcel) const ; - bool UnMarshalling(MessageParcel& parcel) ; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); std::string dump() const; bool ReadFromParcel(Parcel &parcel); diff --git a/common/include/interfaces/device_icon_info_filter_options.h b/common/include/interfaces/device_icon_info_filter_options.h index 31c7ad1d..7d5fcd58 100644 --- a/common/include/interfaces/device_icon_info_filter_options.h +++ b/common/include/interfaces/device_icon_info_filter_options.h @@ -40,8 +40,8 @@ public: std::string GetSpecName() const; void SetSpecName(const std::string& specName); - bool Marshalling(MessageParcel& parcel) const ; - bool UnMarshalling(MessageParcel& parcel) ; + bool Marshalling(MessageParcel& parcel) const; + bool UnMarshalling(MessageParcel& parcel); std::string dump() const; bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; -- Gitee From 4bad96f41d24b71f1c0b3108b91c0d3d26987ca0 Mon Sep 17 00:00:00 2001 From: BrainL Date: Mon, 9 Jun 2025 16:35:17 +0800 Subject: [PATCH 5/9] gn and license modify Signed-off-by: BrainL --- common/BUILD.gn | 4 +++- common/include/interfaces/access_control_profile.h | 2 +- common/include/interfaces/characteristic_profile.h | 2 +- common/include/interfaces/device_icon_info.h | 2 +- common/include/interfaces/device_icon_info_filter_options.h | 2 +- common/include/interfaces/device_profile.h | 2 +- common/include/interfaces/device_profile_filter_options.h | 2 +- common/include/interfaces/dp_subscribe_info.h | 2 +- common/include/interfaces/dp_sync_options.h | 2 +- common/include/interfaces/product_info.h | 2 +- common/include/interfaces/service_profile.h | 2 +- common/include/interfaces/trust_device_profile.h | 2 +- common/include/interfaces/trusted_device_info.h | 2 +- common/include/utils/ipc_utils.h | 2 +- common/src/interfaces/access_control_profile.cpp | 2 +- common/src/interfaces/characteristic_profile.cpp | 2 +- common/src/interfaces/device_icon_info.cpp | 2 +- common/src/interfaces/device_icon_info_filter_options.cpp | 2 +- common/src/interfaces/device_profile.cpp | 2 +- common/src/interfaces/device_profile_filter_options.cpp | 2 +- common/src/interfaces/dp_inited_callback_proxy.cpp | 2 +- common/src/interfaces/dp_subscribe_info.cpp | 2 +- common/src/interfaces/dp_subscribe_info_extension.cpp | 2 +- common/src/interfaces/dp_sync_options.cpp | 2 +- common/src/interfaces/product_info.cpp | 2 +- common/src/interfaces/profile_change_listener_proxy.cpp | 2 +- common/src/interfaces/service_profile.cpp | 2 +- common/src/interfaces/trust_device_profile.cpp | 2 +- common/src/interfaces/trusted_device_info.cpp | 2 +- common/src/utils/ipc_utils.cpp | 2 +- interfaces/innerkits/core/BUILD.gn | 5 ++--- radar/test/unittest/BUILD.gn | 2 +- services/core/include/common/dp_services_constants.h | 2 +- .../subscribeprofilemanager/subscribe_profile_manager.h | 2 +- .../subscribeprofilemanager/subscribe_profile_manager.cpp | 2 +- services/core/test/BUILD.gn | 2 +- .../newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp | 2 +- .../unittest/distributed_device_profile_client_kv_test.cpp | 2 +- .../unittest/distributed_device_profile_client_rdb_test.cpp | 2 +- 39 files changed, 42 insertions(+), 41 deletions(-) diff --git a/common/BUILD.gn b/common/BUILD.gn index d4f03880..ef66966b 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -84,7 +84,9 @@ ohos_shared_library("distributed_device_profile_common") { "src/utils/profile_utils.cpp", ] - deps = [] + deps = [ + "${device_profile_innerkits}:distributed_device_profile_interfaces_ipc", + ] public_configs = [ ":distributed_device_profile_common_config", diff --git a/common/include/interfaces/access_control_profile.h b/common/include/interfaces/access_control_profile.h index 9a889a25..797daac7 100644 --- a/common/include/interfaces/access_control_profile.h +++ b/common/include/interfaces/access_control_profile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/include/interfaces/characteristic_profile.h b/common/include/interfaces/characteristic_profile.h index af4e6d99..6cb5d757 100644 --- a/common/include/interfaces/characteristic_profile.h +++ b/common/include/interfaces/characteristic_profile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/include/interfaces/device_icon_info.h b/common/include/interfaces/device_icon_info.h index 8865c043..c666e440 100644 --- a/common/include/interfaces/device_icon_info.h +++ b/common/include/interfaces/device_icon_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/include/interfaces/device_icon_info_filter_options.h b/common/include/interfaces/device_icon_info_filter_options.h index 7d5fcd58..f57274c3 100644 --- a/common/include/interfaces/device_icon_info_filter_options.h +++ b/common/include/interfaces/device_icon_info_filter_options.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/include/interfaces/device_profile.h b/common/include/interfaces/device_profile.h index 8f4a2df2..756153a0 100644 --- a/common/include/interfaces/device_profile.h +++ b/common/include/interfaces/device_profile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/include/interfaces/device_profile_filter_options.h b/common/include/interfaces/device_profile_filter_options.h index ad001c46..1f5e4670 100644 --- a/common/include/interfaces/device_profile_filter_options.h +++ b/common/include/interfaces/device_profile_filter_options.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/include/interfaces/dp_subscribe_info.h b/common/include/interfaces/dp_subscribe_info.h index f13a6fe5..ea4d16c9 100644 --- a/common/include/interfaces/dp_subscribe_info.h +++ b/common/include/interfaces/dp_subscribe_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/include/interfaces/dp_sync_options.h b/common/include/interfaces/dp_sync_options.h index db0ead6d..7ac11e8c 100644 --- a/common/include/interfaces/dp_sync_options.h +++ b/common/include/interfaces/dp_sync_options.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/include/interfaces/product_info.h b/common/include/interfaces/product_info.h index f6e8f699..042e406e 100644 --- a/common/include/interfaces/product_info.h +++ b/common/include/interfaces/product_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/include/interfaces/service_profile.h b/common/include/interfaces/service_profile.h index 0aa099b3..a075afcb 100644 --- a/common/include/interfaces/service_profile.h +++ b/common/include/interfaces/service_profile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/include/interfaces/trust_device_profile.h b/common/include/interfaces/trust_device_profile.h index 69dc7e61..ddde58f8 100644 --- a/common/include/interfaces/trust_device_profile.h +++ b/common/include/interfaces/trust_device_profile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/include/interfaces/trusted_device_info.h b/common/include/interfaces/trusted_device_info.h index a0f0127d..986cc2a6 100644 --- a/common/include/interfaces/trusted_device_info.h +++ b/common/include/interfaces/trusted_device_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/include/utils/ipc_utils.h b/common/include/utils/ipc_utils.h index 34300b12..708dfc43 100644 --- a/common/include/utils/ipc_utils.h +++ b/common/include/utils/ipc_utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/access_control_profile.cpp b/common/src/interfaces/access_control_profile.cpp index 1615c973..23b24c8c 100644 --- a/common/src/interfaces/access_control_profile.cpp +++ b/common/src/interfaces/access_control_profile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/characteristic_profile.cpp b/common/src/interfaces/characteristic_profile.cpp index abfedbc9..1acbe87a 100644 --- a/common/src/interfaces/characteristic_profile.cpp +++ b/common/src/interfaces/characteristic_profile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/device_icon_info.cpp b/common/src/interfaces/device_icon_info.cpp index 187b2a21..723586c5 100644 --- a/common/src/interfaces/device_icon_info.cpp +++ b/common/src/interfaces/device_icon_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/src/interfaces/device_icon_info_filter_options.cpp b/common/src/interfaces/device_icon_info_filter_options.cpp index 2e6468f4..f8b898c6 100644 --- a/common/src/interfaces/device_icon_info_filter_options.cpp +++ b/common/src/interfaces/device_icon_info_filter_options.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/src/interfaces/device_profile.cpp b/common/src/interfaces/device_profile.cpp index 566aa1c2..68babbbe 100644 --- a/common/src/interfaces/device_profile.cpp +++ b/common/src/interfaces/device_profile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/device_profile_filter_options.cpp b/common/src/interfaces/device_profile_filter_options.cpp index 48db66cf..2e61556b 100644 --- a/common/src/interfaces/device_profile_filter_options.cpp +++ b/common/src/interfaces/device_profile_filter_options.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/src/interfaces/dp_inited_callback_proxy.cpp b/common/src/interfaces/dp_inited_callback_proxy.cpp index 284b944e..07d6d30b 100644 --- a/common/src/interfaces/dp_inited_callback_proxy.cpp +++ b/common/src/interfaces/dp_inited_callback_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/src/interfaces/dp_subscribe_info.cpp b/common/src/interfaces/dp_subscribe_info.cpp index 9757a694..0867413d 100644 --- a/common/src/interfaces/dp_subscribe_info.cpp +++ b/common/src/interfaces/dp_subscribe_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/dp_subscribe_info_extension.cpp b/common/src/interfaces/dp_subscribe_info_extension.cpp index f8b3dd11..e7fefa6e 100644 --- a/common/src/interfaces/dp_subscribe_info_extension.cpp +++ b/common/src/interfaces/dp_subscribe_info_extension.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2025 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/common/src/interfaces/dp_sync_options.cpp b/common/src/interfaces/dp_sync_options.cpp index 0a533af0..726aa648 100644 --- a/common/src/interfaces/dp_sync_options.cpp +++ b/common/src/interfaces/dp_sync_options.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/product_info.cpp b/common/src/interfaces/product_info.cpp index fdcfb2bd..0bc16af1 100644 --- a/common/src/interfaces/product_info.cpp +++ b/common/src/interfaces/product_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/src/interfaces/profile_change_listener_proxy.cpp b/common/src/interfaces/profile_change_listener_proxy.cpp index 05d7f5d8..939dc4e4 100644 --- a/common/src/interfaces/profile_change_listener_proxy.cpp +++ b/common/src/interfaces/profile_change_listener_proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/service_profile.cpp b/common/src/interfaces/service_profile.cpp index f30be63e..01b32ff1 100644 --- a/common/src/interfaces/service_profile.cpp +++ b/common/src/interfaces/service_profile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/trust_device_profile.cpp b/common/src/interfaces/trust_device_profile.cpp index a968bf15..26716299 100644 --- a/common/src/interfaces/trust_device_profile.cpp +++ b/common/src/interfaces/trust_device_profile.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/common/src/interfaces/trusted_device_info.cpp b/common/src/interfaces/trusted_device_info.cpp index 3941f9b8..86646825 100644 --- a/common/src/interfaces/trusted_device_info.cpp +++ b/common/src/interfaces/trusted_device_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/common/src/utils/ipc_utils.cpp b/common/src/utils/ipc_utils.cpp index b0d1d1d4..7976e2e0 100644 --- a/common/src/utils/ipc_utils.cpp +++ b/common/src/utils/ipc_utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/interfaces/innerkits/core/BUILD.gn b/interfaces/innerkits/core/BUILD.gn index 480b01a8..17be7673 100644 --- a/interfaces/innerkits/core/BUILD.gn +++ b/interfaces/innerkits/core/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-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 @@ -106,10 +106,9 @@ ohos_shared_library("distributed_device_profile_sdk") { "src/distributed_device_profile_client.cpp", ] - configs = [ ":distributed_device_profile_interfaces_ipc_config", ] - public_configs = [ ":distributed_device_profile_sdk_config", + ":distributed_device_profile_interfaces_ipc_config", ] deps = [ diff --git a/radar/test/unittest/BUILD.gn b/radar/test/unittest/BUILD.gn index ed8c373c..612cac1e 100644 --- a/radar/test/unittest/BUILD.gn +++ b/radar/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. +# Copyright (c) 2024-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 diff --git a/services/core/include/common/dp_services_constants.h b/services/core/include/common/dp_services_constants.h index cedf79d1..12341993 100644 --- a/services/core/include/common/dp_services_constants.h +++ b/services/core/include/common/dp_services_constants.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h index 31866e5b..37aedc46 100644 --- a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h +++ b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp index 4f5c06dd..b30e67c6 100644 --- a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp +++ b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/services/core/test/BUILD.gn b/services/core/test/BUILD.gn index 088fe7cb..34117317 100644 --- a/services/core/test/BUILD.gn +++ b/services/core/test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023-2024 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 diff --git a/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp b/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp index b2707cfb..2b31cdd9 100644 --- a/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp +++ b/services/core/test/fuzztest/newdeviceprofile_fuzzer/new_device_profile_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-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 diff --git a/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp b/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp index 509b19cc..f47e34e4 100644 --- a/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_kv_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 diff --git a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp index 8e1dad40..86501e44 100644 --- a/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_client_rdb_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 -- Gitee From dd85242b3c11de4e7ca4d8f8762f0c87798d1b67 Mon Sep 17 00:00:00 2001 From: BrainL Date: Tue, 10 Jun 2025 18:22:10 +0800 Subject: [PATCH 6/9] interface declaration modify Signed-off-by: BrainL --- .../core/IDistributedDeviceProfile.idl | 18 +++++++++--------- .../distributed_device_profile_client.h | 8 ++++---- .../src/distributed_device_profile_client.cpp | 8 ++++---- .../distributed_device_profile_service_new.h | 11 ++++++----- .../profiledatamanager/profile_data_manager.h | 8 ++++---- .../subscribe_profile_manager.h | 2 +- .../distributed_device_profile_service_new.cpp | 13 +++++++------ .../profile_data_manager.cpp | 6 +++--- .../subscribe_profile_manager.cpp | 2 +- 9 files changed, 39 insertions(+), 37 deletions(-) diff --git a/interfaces/innerkits/core/IDistributedDeviceProfile.idl b/interfaces/innerkits/core/IDistributedDeviceProfile.idl index 39944a4a..4c62ceb7 100644 --- a/interfaces/innerkits/core/IDistributedDeviceProfile.idl +++ b/interfaces/innerkits/core/IDistributedDeviceProfile.idl @@ -35,22 +35,22 @@ interface OHOS.DistributedDeviceProfile.IDistributedDeviceProfile { [ipccode 8] void UpdateAccessControlProfile([in] AccessControlProfile aclProfile); [ipccode 9] void GetTrustDeviceProfile([in] String deviceId, [out] TrustDeviceProfile trustDeviceProfile); [ipccode 10] void GetAllTrustDeviceProfile([out] TrustDeviceProfile[] trustDeviceProfiles); - [ipccode 11] void GetAccessControlProfile([out] OrderedMap queryParams, + [ipccode 11] void GetAccessControlProfile([in] OrderedMap queryParams, [out] AccessControlProfile[] accessControlProfiles); [ipccode 12] void GetAllAccessControlProfile([out] AccessControlProfile[] accessControlProfiles); [ipccode 13] void DeleteAccessControlProfile([in] int accessControlId); - [ipccode 46] void PutDeviceProfileBatch([out] DeviceProfile[] deviceProfiles); + [ipccode 46] void PutDeviceProfileBatch([in] DeviceProfile[] deviceProfiles); [ipccode 14] void PutServiceProfile([in] ServiceProfile serviceProfile); [ipccode 15] void PutServiceProfileBatch([in] ServiceProfile[] serviceProfiles); [ipccode 16] void PutCharacteristicProfile([in] CharacteristicProfile charProfile); [ipccode 17] void PutCharacteristicProfileBatch([in] CharacteristicProfile[] charProfiles); - [ipccode 18] void GetDeviceProfile([in] String deviceId, [out] DeviceProfile deviceProfile); - [ipccode 47] void GetDeviceProfiles([out] DeviceProfileFilterOptions options,[out] DeviceProfile[] deviceProfiles); - [ipccode 51] void DeleteDeviceProfileBatch([out] DeviceProfile[] deviceProfiles); + [ipccode 18] void GetDeviceProfile([in] String deviceId, [inout] DeviceProfile deviceProfile); + [ipccode 47] void GetDeviceProfiles([in] DeviceProfileFilterOptions options,[out] DeviceProfile[] deviceProfiles); + [ipccode 51] void DeleteDeviceProfileBatch([in] DeviceProfile[] deviceProfiles); [ipccode 19] void GetServiceProfile([in] String deviceId, [in] String serviceName, - [out] ServiceProfile serviceProfile); + [inout] ServiceProfile serviceProfile); [ipccode 20] void GetCharacteristicProfile([in] String deviceId, [in] String serviceName, - [in] String characteristicId, [out] CharacteristicProfile charProfile); + [in] String characteristicId, [inout] CharacteristicProfile charProfile); [ipccode 21] void DeleteServiceProfile([in] String deviceId, [in] String serviceName, [in] boolean isMultiUser, [in] int userId); [ipccode 22] void DeleteCharacteristicProfile([in] String deviceId, [in] String serviceName, @@ -61,7 +61,7 @@ interface OHOS.DistributedDeviceProfile.IDistributedDeviceProfile { [ipccode 42] void UnSubscribeDeviceProfileInited([in] int saId); [ipccode 25] void SyncDeviceProfile([in] DpSyncOptions syncOptions, [in] IRemoteObject syncCompletedCallback); - [ipccode 26] void SendSubscribeInfos([out] OrderedMap listenerMap); + [ipccode 26] void SendSubscribeInfos([in] OrderedMap listenerMap); [ipccode 45] void PutAllTrustedDevices([in] TrustedDeviceInfo[] deviceInfos); [ipccode 50] void PutProductInfoBatch([in] ProductInfo[] productInfos); [ipccode 49] void PutDeviceIconInfoBatch([in] DeviceIconInfo[] deviceIconInfos); @@ -77,7 +77,7 @@ interface OHOS.DistributedDeviceProfile.IDistributedDeviceProfile { [ipccode 53] void DeleteServiceInfoProfile([in] ServiceInfoUniqueKey key); [ipccode 54] void UpdateServiceInfoProfile([in] ServiceInfoProfile serviceInfoProfile); [ipccode 55] void GetServiceInfoProfileByUniqueKey([in] ServiceInfoUniqueKey key, - [inout] ServiceInfoProfile serviceInfoProfile); + [out] ServiceInfoProfile serviceInfoProfile); [ipccode 56] void GetServiceInfoProfileListByTokenId([in]ServiceInfoUniqueKey key, [out] ServiceInfoProfile[] serviceInfoProfiles); [ipccode 57] void GetAllServiceInfoProfileList([out] ServiceInfoProfile[] serviceInfoProfiles); diff --git a/interfaces/innerkits/core/include/distributed_device_profile_client.h b/interfaces/innerkits/core/include/distributed_device_profile_client.h index 27401e71..caeb1472 100644 --- a/interfaces/innerkits/core/include/distributed_device_profile_client.h +++ b/interfaces/innerkits/core/include/distributed_device_profile_client.h @@ -51,7 +51,7 @@ public: int32_t UpdateAccessControlProfile(const AccessControlProfile& accessControlProfile); int32_t GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile); int32_t GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles); - int32_t GetAccessControlProfile(std::map params, + int32_t GetAccessControlProfile(const std::map params, std::vector& accessControlProfiles); int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles); int32_t GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles); @@ -60,14 +60,14 @@ public: int32_t GetSessionKey(uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey); int32_t UpdateSessionKey(uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey); int32_t DeleteSessionKey(uint32_t userId, int32_t sessionKeyId); - int32_t PutDeviceProfileBatch(std::vector& deviceProfiles); + int32_t PutDeviceProfileBatch(const std::vector& deviceProfiles); int32_t PutServiceProfile(const ServiceProfile& serviceProfile); int32_t PutServiceProfileBatch(const std::vector& serviceProfiles); int32_t PutCharacteristicProfile(const CharacteristicProfile& characteristicProfile); int32_t PutCharacteristicProfileBatch(const std::vector& characteristicProfiles); int32_t GetDeviceProfile(const std::string& deviceId, DeviceProfile& deviceProfile); - int32_t GetDeviceProfiles(DeviceProfileFilterOptions& options, std::vector& deviceProfiles); - int32_t DeleteDeviceProfileBatch(std::vector& deviceProfiles); + int32_t GetDeviceProfiles(const DeviceProfileFilterOptions& options, std::vector& deviceProfiles); + int32_t DeleteDeviceProfileBatch(const std::vector& deviceProfiles); int32_t GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile); int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index 93c2fe5f..9db6707e 100644 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -174,7 +174,7 @@ int32_t DistributedDeviceProfileClient::GetAllTrustDeviceProfile(std::vectorGetAllTrustDeviceProfile(trustDeviceProfiles); } -int32_t DistributedDeviceProfileClient::GetAccessControlProfile(std::map params, +int32_t DistributedDeviceProfileClient::GetAccessControlProfile(const std::map params, std::vector& accessControlProfiles) { auto dpService = GetDeviceProfileService(); @@ -220,7 +220,7 @@ int32_t DistributedDeviceProfileClient::DeleteAccessControlProfile(int32_t acces return dpService->DeleteAccessControlProfile(accessControlId); } -int32_t DistributedDeviceProfileClient::PutDeviceProfileBatch(std::vector& deviceProfiles) +int32_t DistributedDeviceProfileClient::PutDeviceProfileBatch(const std::vector& deviceProfiles) { auto dpService = GetDeviceProfileService(); if (dpService == nullptr) { @@ -230,7 +230,7 @@ int32_t DistributedDeviceProfileClient::PutDeviceProfileBatch(std::vectorPutDeviceProfileBatch(deviceProfiles); } -int32_t DistributedDeviceProfileClient::DeleteDeviceProfileBatch(std::vector& deviceProfiles) +int32_t DistributedDeviceProfileClient::DeleteDeviceProfileBatch(const std::vector& deviceProfiles) { auto dpService = GetDeviceProfileService(); if (dpService == nullptr) { @@ -373,7 +373,7 @@ int32_t DistributedDeviceProfileClient::GetDeviceProfile(const std::string& devi return dpService->GetDeviceProfile(deviceId, deviceProfile); } -int32_t DistributedDeviceProfileClient::GetDeviceProfiles(DeviceProfileFilterOptions& options, +int32_t DistributedDeviceProfileClient::GetDeviceProfiles(const DeviceProfileFilterOptions& options, std::vector& deviceProfiles) { auto dpService = GetDeviceProfileService(); diff --git a/services/core/include/distributed_device_profile_service_new.h b/services/core/include/distributed_device_profile_service_new.h index ee3e9453..36e2db14 100644 --- a/services/core/include/distributed_device_profile_service_new.h +++ b/services/core/include/distributed_device_profile_service_new.h @@ -54,7 +54,7 @@ public: int32_t UpdateAccessControlProfile(const AccessControlProfile& aclProfile) override; int32_t GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile) override; int32_t GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles) override; - int32_t GetAccessControlProfile(std::map& queryParams, + int32_t GetAccessControlProfile(const std::map& queryParams, std::vector& accessControlProfiles) override; int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) override; int32_t GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles) override; @@ -63,14 +63,15 @@ public: int32_t GetSessionKey(uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey) override; int32_t UpdateSessionKey(uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey) override; int32_t DeleteSessionKey(uint32_t userId, int32_t sessionKeyId) override; - int32_t PutDeviceProfileBatch(std::vector& deviceProfiles) override; + int32_t PutDeviceProfileBatch(const std::vector& deviceProfiles) override; int32_t PutServiceProfile(const ServiceProfile& serviceProfile) override; int32_t PutServiceProfileBatch(const std::vector& serviceProfiles) override; int32_t PutCharacteristicProfile(const CharacteristicProfile& charProfile) override; int32_t PutCharacteristicProfileBatch(const std::vector& charProfiles) override; int32_t GetDeviceProfile(const std::string& deviceId, DeviceProfile& deviceProfile) override; - int32_t GetDeviceProfiles(DeviceProfileFilterOptions& options, std::vector& deviceProfiles) override; - int32_t DeleteDeviceProfileBatch(std::vector& deviceProfiles) override; + int32_t GetDeviceProfiles(const DeviceProfileFilterOptions& options, + std::vector& deviceProfiles) override; + int32_t DeleteDeviceProfileBatch(const std::vector& deviceProfiles) override; int32_t GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile) override; int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, @@ -108,7 +109,7 @@ public: int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, int32_t pinExchangeType, LocalServiceInfo& localServiceInfo)override; int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType)override; - int32_t SendSubscribeInfos(std::map& listenerMap) override; + int32_t SendSubscribeInfos(const std::map& listenerMap) override; int32_t Dump(int32_t fd, const std::vector& args) override; void DelayUnloadTask(); bool IsInited(); diff --git a/services/core/include/profiledatamanager/profile_data_manager.h b/services/core/include/profiledatamanager/profile_data_manager.h index 5bebd545..32565268 100644 --- a/services/core/include/profiledatamanager/profile_data_manager.h +++ b/services/core/include/profiledatamanager/profile_data_manager.h @@ -33,16 +33,16 @@ class ProfileDataManager { public: int32_t Init(); int32_t UnInit(); - - int32_t PutDeviceProfileBatch(std::vector& deviceProfiles); - int32_t DeleteDeviceProfileBatch(std::vector& deviceProfiles); + + int32_t PutDeviceProfileBatch(const std::vector& deviceProfiles); + int32_t DeleteDeviceProfileBatch(const std::vector& deviceProfiles); int32_t GetDeviceProfiles(DeviceProfileFilterOptions& options, std::vector& deviceProfiles); int32_t PutProductInfoBatch(const std::vector& productInfos); int32_t PutDeviceIconInfoBatch(const std::vector& deviceIconInfos); int32_t GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, std::vector& deviceIconInfos); - + int32_t PutDeviceProfile(DeviceProfile deviceProfile); private: bool FilterInvaildSymbol(std::string str); diff --git a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h index 37aedc46..b0dba465 100644 --- a/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h +++ b/services/core/include/subscribeprofilemanager/subscribe_profile_manager.h @@ -43,7 +43,7 @@ public: int32_t NotifyTrustDeviceProfileActive(const TrustDeviceProfile& trustDeviceProfile); int32_t NotifyTrustDeviceProfileInactive(const TrustDeviceProfile& trustDeviceProfile); int32_t SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfo); - int32_t SubscribeDeviceProfile(std::map subscribeInfos); + int32_t SubscribeDeviceProfile(const std::map subscribeInfos); int32_t UnSubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfo); private: diff --git a/services/core/src/distributed_device_profile_service_new.cpp b/services/core/src/distributed_device_profile_service_new.cpp index bc6c3489..2aad2c61 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -315,7 +315,7 @@ int32_t DistributedDeviceProfileServiceNew::GetDeviceIconInfos(const DeviceIconI return ret; } -int32_t DistributedDeviceProfileServiceNew::DeleteDeviceProfileBatch(std::vector& deviceProfiles) +int32_t DistributedDeviceProfileServiceNew::DeleteDeviceProfileBatch(const std::vector& deviceProfiles) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("the caller is permission denied!"); @@ -350,7 +350,7 @@ int32_t DistributedDeviceProfileServiceNew::GetAllTrustDeviceProfile( return ret; } -int32_t DistributedDeviceProfileServiceNew::GetAccessControlProfile(std::map& queryParams, +int32_t DistributedDeviceProfileServiceNew::GetAccessControlProfile(const std::map& queryParams, std::vector& accessControlProfiles) { if (!PermissionManager::GetInstance().IsCallerTrust(GET_ACCESS_CONTROL_PROFILE)) { @@ -440,7 +440,7 @@ int32_t DistributedDeviceProfileServiceNew::DeleteSessionKey(uint32_t userId, in return ret; } -int32_t DistributedDeviceProfileServiceNew::PutDeviceProfileBatch(std::vector& deviceProfiles) +int32_t DistributedDeviceProfileServiceNew::PutDeviceProfileBatch(const std::vector& deviceProfiles) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("the caller is permission denied!"); @@ -649,7 +649,7 @@ int32_t DistributedDeviceProfileServiceNew::GetDeviceProfile(const std::string& return ret; } -int32_t DistributedDeviceProfileServiceNew::GetDeviceProfiles(DeviceProfileFilterOptions& options, +int32_t DistributedDeviceProfileServiceNew::GetDeviceProfiles(const DeviceProfileFilterOptions& options, std::vector& deviceProfiles) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { @@ -657,7 +657,8 @@ int32_t DistributedDeviceProfileServiceNew::GetDeviceProfiles(DeviceProfileFilte return DP_PERMISSION_DENIED; } HILOGD("CheckCallerPermission success interface GetDeviceProfiles"); - int32_t ret = ProfileDataManager::GetInstance().GetDeviceProfiles(options, deviceProfiles); + DeviceProfileFilterOptions newOptions = options; + int32_t ret = ProfileDataManager::GetInstance().GetDeviceProfiles(newOptions, deviceProfiles); return ret; } @@ -823,7 +824,7 @@ int32_t DistributedDeviceProfileServiceNew::SyncDeviceProfile( } int32_t DistributedDeviceProfileServiceNew::SendSubscribeInfos( - std::map& listenerMap) + const std::map& listenerMap) { return SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(listenerMap); } diff --git a/services/core/src/profiledatamanager/profile_data_manager.cpp b/services/core/src/profiledatamanager/profile_data_manager.cpp index a52ccab6..61662338 100644 --- a/services/core/src/profiledatamanager/profile_data_manager.cpp +++ b/services/core/src/profiledatamanager/profile_data_manager.cpp @@ -67,7 +67,7 @@ int32_t ProfileDataManager::UnInit() } return 0; } - + int32_t ProfileDataManager::PutDeviceProfile(DeviceProfile deviceProfile) { if (deviceProfile.GetDeviceId().empty() || ProfileDataManager::FilterInvaildSymbol(deviceProfile.GetDeviceId())) { @@ -107,7 +107,7 @@ int32_t ProfileDataManager::PutDeviceProfile(DeviceProfile deviceProfile) return DP_SUCCESS; } -int32_t ProfileDataManager::DeleteDeviceProfileBatch(std::vector& deviceProfiles) +int32_t ProfileDataManager::DeleteDeviceProfileBatch(const std::vector& deviceProfiles) { HILOGI("deviceProfiles.size:%{public}zu", deviceProfiles.size()); if (deviceProfiles.empty()) { @@ -156,7 +156,7 @@ bool ProfileDataManager::FilterInvaildSymbol(std::string str) return true; } -int32_t ProfileDataManager::PutDeviceProfileBatch(std::vector& deviceProfiles) +int32_t ProfileDataManager::PutDeviceProfileBatch(const std::vector& deviceProfiles) { if (deviceProfiles.empty()) { HILOGE("deviceProfiles is empty"); diff --git a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp index b30e67c6..02a2298a 100644 --- a/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp +++ b/services/core/src/subscribeprofilemanager/subscribe_profile_manager.cpp @@ -224,7 +224,7 @@ int32_t SubscribeProfileManager::SubscribeDeviceProfile(const SubscribeInfoExt& return DP_SUCCESS; } -int32_t SubscribeProfileManager::SubscribeDeviceProfile(std::map subscribeInfos) +int32_t SubscribeProfileManager::SubscribeDeviceProfile(const std::map subscribeInfos) { HILOGD("call!"); for (auto item : subscribeInfos) { -- Gitee From 2666248a4705d80bd2993a2e79ef88da460f2630 Mon Sep 17 00:00:00 2001 From: BrainL Date: Sat, 14 Jun 2025 11:26:45 +0800 Subject: [PATCH 7/9] merge Signed-off-by: BrainL --- .../interfaces/dp_subscribe_info_extension.h | 2 + .../src/interfaces/access_control_profile.cpp | 4 +- .../dp_subscribe_info_extension.cpp | 8 ++-- .../core/IDistributedDeviceProfile.idl | 9 +++-- .../distributed_device_profile_client.h | 12 ++++-- .../src/distributed_device_profile_client.cpp | 21 +++++++---- .../distributed_device_profile_service_new.h | 12 ++++-- ...distributed_device_profile_service_new.cpp | 37 ++++++++++++++----- .../test/unittest/dp_profile_service_test.cpp | 12 +++--- 9 files changed, 80 insertions(+), 37 deletions(-) diff --git a/common/include/interfaces/dp_subscribe_info_extension.h b/common/include/interfaces/dp_subscribe_info_extension.h index 57ccb38c..ebf2ff51 100644 --- a/common/include/interfaces/dp_subscribe_info_extension.h +++ b/common/include/interfaces/dp_subscribe_info_extension.h @@ -38,6 +38,8 @@ public: SubscribeInfoExt(); ~SubscribeInfoExt(); + void SetListener(sptr listener); + bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; static SubscribeInfoExt *Unmarshalling(Parcel &parcel); diff --git a/common/src/interfaces/access_control_profile.cpp b/common/src/interfaces/access_control_profile.cpp index 23b24c8c..e7f86454 100644 --- a/common/src/interfaces/access_control_profile.cpp +++ b/common/src/interfaces/access_control_profile.cpp @@ -329,8 +329,8 @@ bool AccessControlProfile::Marshalling(Parcel& parcel) const WRITE_HELPER_RET(parcel, Uint32, authenticationType_, false); WRITE_HELPER_RET(parcel, Uint32, bindLevel_, false); WRITE_HELPER_RET(parcel, Int32, status_, false); - WRITE_HELPER_RET(parcel, Int32, validPeriod_, false); - WRITE_HELPER_RET(parcel, Int32, lastAuthTime_, false); + WRITE_HELPER_RET(parcel, Int64, validPeriod_, false); + WRITE_HELPER_RET(parcel, Int64, lastAuthTime_, false); WRITE_HELPER_RET(parcel, String, trustDeviceId_, false); WRITE_HELPER_RET(parcel, Uint32, deviceIdType_, false); WRITE_HELPER_RET(parcel, String, deviceIdHash_, false); diff --git a/common/src/interfaces/dp_subscribe_info_extension.cpp b/common/src/interfaces/dp_subscribe_info_extension.cpp index e7fefa6e..90cf5e9c 100644 --- a/common/src/interfaces/dp_subscribe_info_extension.cpp +++ b/common/src/interfaces/dp_subscribe_info_extension.cpp @@ -68,6 +68,11 @@ SubscribeInfoExt::~SubscribeInfoExt() { } +void SubscribeInfoExt::SetListener(sptr listener) +{ + this->listener_ = listener; +} + bool SubscribeInfoExt::ReadFromParcel(Parcel &parcel) { READ_HELPER_RET(parcel, Int32, saId_, false); @@ -87,7 +92,6 @@ bool SubscribeInfoExt::ReadFromParcel(Parcel &parcel) } subscribeChangeTypes_.emplace(static_cast(num)); } - return true; } @@ -120,8 +124,6 @@ bool SubscribeInfoExt::Marshalling(Parcel& parcel) const for (ProfileChangeType item : subscribeChangeTypes_) { WRITE_HELPER_RET(parcel, Int32, static_cast(item), false); } - - WRITE_HELPER_RET(parcel, RemoteObject, listener_, false); return true; } } diff --git a/interfaces/innerkits/core/IDistributedDeviceProfile.idl b/interfaces/innerkits/core/IDistributedDeviceProfile.idl index 4c62ceb7..6f29d932 100644 --- a/interfaces/innerkits/core/IDistributedDeviceProfile.idl +++ b/interfaces/innerkits/core/IDistributedDeviceProfile.idl @@ -55,13 +55,16 @@ interface OHOS.DistributedDeviceProfile.IDistributedDeviceProfile { [in] boolean isMultiUser, [in] int userId); [ipccode 22] void DeleteCharacteristicProfile([in] String deviceId, [in] String serviceName, [in] String characteristicId, [in] boolean isMultiUser, [in] int userId); - [ipccode 23] void SubscribeDeviceProfile([in] SubscribeInfoExt subscribeInfoExtension); - [ipccode 24] void UnSubscribeDeviceProfile([in] SubscribeInfoExt subscribeInfoExtension); + [ipccode 23] void SubscribeDeviceProfile([in] SubscribeInfoExt subscribeInfoExtension, + [in] IRemoteObject listener); + [ipccode 24] void UnSubscribeDeviceProfile([in] SubscribeInfoExt subscribeInfoExtension, + [in] IRemoteObject listener); [ipccode 41] void SubscribeDeviceProfileInited([in] int saId, [in] IRemoteObject dpInitedCallback); [ipccode 42] void UnSubscribeDeviceProfileInited([in] int saId); [ipccode 25] void SyncDeviceProfile([in] DpSyncOptions syncOptions, [in] IRemoteObject syncCompletedCallback); - [ipccode 26] void SendSubscribeInfos([in] OrderedMap listenerMap); + [ipccode 26] void SendSubscribeInfos([in] OrderedMap listenerMap, + [in] OrderedMap listeners); [ipccode 45] void PutAllTrustedDevices([in] TrustedDeviceInfo[] deviceInfos); [ipccode 50] void PutProductInfoBatch([in] ProductInfo[] productInfos); [ipccode 49] void PutDeviceIconInfoBatch([in] DeviceIconInfo[] deviceIconInfos); diff --git a/interfaces/innerkits/core/include/distributed_device_profile_client.h b/interfaces/innerkits/core/include/distributed_device_profile_client.h index caeb1472..a520fb1c 100644 --- a/interfaces/innerkits/core/include/distributed_device_profile_client.h +++ b/interfaces/innerkits/core/include/distributed_device_profile_client.h @@ -51,7 +51,7 @@ public: int32_t UpdateAccessControlProfile(const AccessControlProfile& accessControlProfile); int32_t GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile); int32_t GetAllTrustDeviceProfile(std::vector& trustDeviceProfiles); - int32_t GetAccessControlProfile(const std::map params, + int32_t GetAccessControlProfile(std::map params, std::vector& accessControlProfiles); int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles); int32_t GetAllAclIncludeLnnAcl(std::vector& accessControlProfiles); @@ -60,14 +60,14 @@ public: int32_t GetSessionKey(uint32_t userId, int32_t sessionKeyId, std::vector& sessionKey); int32_t UpdateSessionKey(uint32_t userId, int32_t sessionKeyId, const std::vector& sessionKey); int32_t DeleteSessionKey(uint32_t userId, int32_t sessionKeyId); - int32_t PutDeviceProfileBatch(const std::vector& deviceProfiles); + int32_t PutDeviceProfileBatch(std::vector& deviceProfiles); int32_t PutServiceProfile(const ServiceProfile& serviceProfile); int32_t PutServiceProfileBatch(const std::vector& serviceProfiles); int32_t PutCharacteristicProfile(const CharacteristicProfile& characteristicProfile); int32_t PutCharacteristicProfileBatch(const std::vector& characteristicProfiles); int32_t GetDeviceProfile(const std::string& deviceId, DeviceProfile& deviceProfile); - int32_t GetDeviceProfiles(const DeviceProfileFilterOptions& options, std::vector& deviceProfiles); - int32_t DeleteDeviceProfileBatch(const std::vector& deviceProfiles); + int32_t GetDeviceProfiles(DeviceProfileFilterOptions& options, std::vector& deviceProfiles); + int32_t DeleteDeviceProfileBatch(std::vector& deviceProfiles); int32_t GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile); int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, @@ -151,9 +151,13 @@ private: std::mutex subscribeLock_; std::map subscribeInfos_; std::map subscribeInfoExtensions_; + std::map> listeners_; std::mutex saListenerLock_; sptr saListenerCallback_ = nullptr; + + SubscribeInfoExt subscribeInfoExt_; + sptr listener_ = nullptr; }; } // namespace DeviceProfile } // namespace OHOS diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index 9db6707e..a5fff5c9 100644 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -125,11 +125,14 @@ void DistributedDeviceProfileClient::SendSubscribeInfosToService() } subscribeInfoExtensions_.clear(); + listeners_.clear(); for (const auto& subscribeInfo : subscribeInfos_) { SubscribeInfoExt subscribeInfoExtension(subscribeInfo.second); + sptr listener = subscribeInfo.second.GetListener(); subscribeInfoExtensions_.insert(std::make_pair(subscribeInfo.first, subscribeInfoExtension)); + listeners_.insert(subscribeInfo.first, listener); } - dpService->SendSubscribeInfos(subscribeInfoExtensions_); + dpService->SendSubscribeInfos(subscribeInfoExtensions_, listeners_); } } @@ -174,7 +177,7 @@ int32_t DistributedDeviceProfileClient::GetAllTrustDeviceProfile(std::vectorGetAllTrustDeviceProfile(trustDeviceProfiles); } -int32_t DistributedDeviceProfileClient::GetAccessControlProfile(const std::map params, +int32_t DistributedDeviceProfileClient::GetAccessControlProfile(std::map params, std::vector& accessControlProfiles) { auto dpService = GetDeviceProfileService(); @@ -220,7 +223,7 @@ int32_t DistributedDeviceProfileClient::DeleteAccessControlProfile(int32_t acces return dpService->DeleteAccessControlProfile(accessControlId); } -int32_t DistributedDeviceProfileClient::PutDeviceProfileBatch(const std::vector& deviceProfiles) +int32_t DistributedDeviceProfileClient::PutDeviceProfileBatch(std::vector& deviceProfiles) { auto dpService = GetDeviceProfileService(); if (dpService == nullptr) { @@ -230,7 +233,7 @@ int32_t DistributedDeviceProfileClient::PutDeviceProfileBatch(const std::vector< return dpService->PutDeviceProfileBatch(deviceProfiles); } -int32_t DistributedDeviceProfileClient::DeleteDeviceProfileBatch(const std::vector& deviceProfiles) +int32_t DistributedDeviceProfileClient::DeleteDeviceProfileBatch(std::vector& deviceProfiles) { auto dpService = GetDeviceProfileService(); if (dpService == nullptr) { @@ -373,7 +376,7 @@ int32_t DistributedDeviceProfileClient::GetDeviceProfile(const std::string& devi return dpService->GetDeviceProfile(deviceId, deviceProfile); } -int32_t DistributedDeviceProfileClient::GetDeviceProfiles(const DeviceProfileFilterOptions& options, +int32_t DistributedDeviceProfileClient::GetDeviceProfiles(DeviceProfileFilterOptions& options, std::vector& deviceProfiles) { auto dpService = GetDeviceProfileService(); @@ -479,7 +482,9 @@ int32_t DistributedDeviceProfileClient::SubscribeDeviceProfile(const SubscribeIn subscribeInfos_[subscribeTag] = subscribeInfo; HILOGI("subscribeInfos_.size is %{public}zu", subscribeInfos_.size()); } - return dpService->SubscribeDeviceProfile(subscribeInfo); + subscribeInfoExt_ = SubscribeInfoExt(subscribeInfo); + listener_ = subscribeInfo.GetListener(); + return dpService->SubscribeDeviceProfile(subscribeInfoExt_, listener_); } int32_t DistributedDeviceProfileClient::UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) @@ -495,7 +500,9 @@ int32_t DistributedDeviceProfileClient::UnSubscribeDeviceProfile(const Subscribe subscribeInfos_.erase(subscribeInfo.GetSubscribeKey() + SEPARATOR + std::to_string(subscribeInfo.GetSaId())); HILOGI("subscribeInfos_.size is %{public}zu", subscribeInfos_.size()); } - return dpService->UnSubscribeDeviceProfile(subscribeInfo); + subscribeInfoExt_ = SubscribeInfoExt(subscribeInfo); + listener_ = subscribeInfo.GetListener(); + return dpService->UnSubscribeDeviceProfile(subscribeInfoExt_, listener_); } int32_t DistributedDeviceProfileClient::SyncDeviceProfile(const DpSyncOptions& syncOptions, diff --git a/services/core/include/distributed_device_profile_service_new.h b/services/core/include/distributed_device_profile_service_new.h index 36e2db14..4a5aff5a 100644 --- a/services/core/include/distributed_device_profile_service_new.h +++ b/services/core/include/distributed_device_profile_service_new.h @@ -94,8 +94,10 @@ public: int32_t GetAllServiceInfoProfileList(std::vector& serviceInfoProfiles) override; int32_t GetServiceInfoProfileListByBundleName(const ServiceInfoUniqueKey& key, std::vector& serviceInfoProfiles) override; - int32_t SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension) override; - int32_t UnSubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension) override; + int32_t SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension, + const sptr& listener) override; + int32_t UnSubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension, + const sptr& listener) override; int32_t SyncDeviceProfile(const DistributedDeviceProfile::DpSyncOptions& syncOptions, const sptr& syncCompletedCallback) override; int32_t SubscribeDeviceProfileInited(int32_t saId, const sptr& dpInitedCallback) override; @@ -109,7 +111,8 @@ public: int32_t GetLocalServiceInfoByBundleAndPinType(const std::string& bundleName, int32_t pinExchangeType, LocalServiceInfo& localServiceInfo)override; int32_t DeleteLocalServiceInfo(const std::string& bundleName, int32_t pinExchangeType)override; - int32_t SendSubscribeInfos(const std::map& listenerMap) override; + int32_t SendSubscribeInfos(const std::map& listenerMap, + const std::map>& listeners) override; int32_t Dump(int32_t fd, const std::vector& args) override; void DelayUnloadTask(); bool IsInited(); @@ -156,6 +159,9 @@ private: DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID, SUBSYS_ACCOUNT_SYS_ABILITY_ID_BEGIN }; + + SubscribeInfoExt subscribeInfoExt_ + std::map listenerMapTrans_; }; } // namespace DeviceProfile } // namespace OHOS diff --git a/services/core/src/distributed_device_profile_service_new.cpp b/services/core/src/distributed_device_profile_service_new.cpp index 2aad2c61..34f69af8 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -350,8 +350,8 @@ int32_t DistributedDeviceProfileServiceNew::GetAllTrustDeviceProfile( return ret; } -int32_t DistributedDeviceProfileServiceNew::GetAccessControlProfile(const std::map& queryParams, - std::vector& accessControlProfiles) +int32_t DistributedDeviceProfileServiceNew::GetAccessControlProfile( + const std::map& queryParams, std::vector& accessControlProfiles) { if (!PermissionManager::GetInstance().IsCallerTrust(GET_ACCESS_CONTROL_PROFILE)) { HILOGE("the caller is permission denied!"); @@ -785,28 +785,33 @@ int32_t DistributedDeviceProfileServiceNew::DeleteLocalServiceInfo(const std::st return ret; } -int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension) +int32_t DistributedDeviceProfileServiceNew::SubscribeDeviceProfile(const SubscribeInfoExt& subscribeInfoExtension, + const sptr& listener) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); return DP_PERMISSION_DENIED; } + subscribeInfoExt_ = subscribeInfoExtension; + subscribeInfoExt_.SetListener(listener); HILOGD("CheckCallerPermission success interface SubscribeDeviceProfile"); - int32_t ret = SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(subscribeInfoExtension); - DpRadarHelper::GetInstance().ReportSubscribeDeviceProfile(ret, subscribeInfoExtension); + int32_t ret = SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(subscribeInfoExt_); + DpRadarHelper::GetInstance().ReportSubscribeDeviceProfile(ret, subscribeInfoExt_); return ret; } int32_t DistributedDeviceProfileServiceNew::UnSubscribeDeviceProfile( - const SubscribeInfoExt& subscribeInfoExtension) + const SubscribeInfoExt& subscribeInfoExtension, const sptr& listener) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { HILOGE("this caller is permission denied!"); return DP_PERMISSION_DENIED; } + subscribeInfoExt_ = subscribeInfoExtension; + subscribeInfoExt_.SetListener(listener); HILOGD("CheckCallerPermission success interface UnSubscribeDeviceProfile"); - int32_t ret = SubscribeProfileManager::GetInstance().UnSubscribeDeviceProfile(subscribeInfoExtension); - DpRadarHelper::GetInstance().ReportUnSubscribeDeviceProfile(ret, subscribeInfoExtension); + int32_t ret = SubscribeProfileManager::GetInstance().UnSubscribeDeviceProfile(subscribeInfoExt_); + DpRadarHelper::GetInstance().ReportUnSubscribeDeviceProfile(ret, subscribeInfoExt_); return ret; } @@ -824,9 +829,21 @@ int32_t DistributedDeviceProfileServiceNew::SyncDeviceProfile( } int32_t DistributedDeviceProfileServiceNew::SendSubscribeInfos( - const std::map& listenerMap) + const std::map& listenerMap, + const std::map>& listeners) { - return SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(listenerMap); + listenerMapTrans_.clear(); + for (const auto& [key, subscribeInfoExt] : listenerMap) + { + auto listenerIt = listeners.find(key); + if (listenerIt == listeners.end()) { + continue; + } + SubscribeInfoExt subscribeInfoExtTemp = subscribeInfoExt; + subscribeInfoExtTemp.SetListener(listenerIt->second); + listenerMapTrans_.emplace(key, std::move(subscribeInfoExtTemp)); + } + return SubscribeProfileManager::GetInstance().SubscribeDeviceProfile(listenerMapTrans_); } int32_t DistributedDeviceProfileServiceNew::Dump(int32_t fd, const std::vector& args) diff --git a/services/core/test/unittest/dp_profile_service_test.cpp b/services/core/test/unittest/dp_profile_service_test.cpp index fccddf0d..996ba527 100644 --- a/services/core/test/unittest/dp_profile_service_test.cpp +++ b/services/core/test/unittest/dp_profile_service_test.cpp @@ -116,14 +116,14 @@ HWTEST_F(DpProfileServiceTest, CreateUnloadHandler_001, TestSize.Level1) DistributedDeviceProfileServiceNew::GetInstance().unloadHandler_ = nullptr; int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().CreateUnloadHandler(); EXPECT_EQ(DP_SUCCESS, ret); - + ret = DistributedDeviceProfileServiceNew::GetInstance().DestroyUnloadHandler(); EXPECT_EQ(DP_SUCCESS, ret); - + EventHandlerFactory::GetInstance().Init(); ret = DistributedDeviceProfileServiceNew::GetInstance().CreateUnloadHandler(); EXPECT_EQ(DP_SUCCESS, ret); - + ret = DistributedDeviceProfileServiceNew::GetInstance().DestroyUnloadHandler(); EXPECT_EQ(DP_SUCCESS, ret); } @@ -435,14 +435,16 @@ HWTEST_F(DpProfileServiceTest, DeleteLocalServiceInfo_001, TestSize.Level1) HWTEST_F(DpProfileServiceTest, SubscribeDeviceProfile_001, TestSize.Level1) { SubscribeInfo subscriberInfo; - int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().SubscribeDeviceProfile(subscriberInfo); + sptr listener = nullptr; + int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().SubscribeDeviceProfile(subscriberInfo, listener); EXPECT_EQ(DP_PERMISSION_DENIED, ret); } HWTEST_F(DpProfileServiceTest, UnSubscribeDeviceProfile_001, TestSize.Level1) { SubscribeInfo subscriberInfo; - int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UnSubscribeDeviceProfile(subscriberInfo); + sptr listener = nullptr; + int32_t ret = DistributedDeviceProfileServiceNew::GetInstance().UnSubscribeDeviceProfile(subscriberInfo, listener); EXPECT_EQ(DP_PERMISSION_DENIED, ret); } -- Gitee From 9de9c9938f9a15980833f4bc8cb21e4b1befafb3 Mon Sep 17 00:00:00 2001 From: BrainL Date: Sat, 14 Jun 2025 11:50:17 +0800 Subject: [PATCH 8/9] merge fix Signed-off-by: BrainL --- .../innerkits/core/src/distributed_device_profile_client.cpp | 2 +- services/core/src/distributed_device_profile_service_new.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index a5fff5c9..f77ef5a6 100644 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -130,7 +130,7 @@ void DistributedDeviceProfileClient::SendSubscribeInfosToService() SubscribeInfoExt subscribeInfoExtension(subscribeInfo.second); sptr listener = subscribeInfo.second.GetListener(); subscribeInfoExtensions_.insert(std::make_pair(subscribeInfo.first, subscribeInfoExtension)); - listeners_.insert(subscribeInfo.first, listener); + listeners_.insert(std::make_pair(subscribeInfo.first, listener)); } dpService->SendSubscribeInfos(subscribeInfoExtensions_, listeners_); } diff --git a/services/core/src/distributed_device_profile_service_new.cpp b/services/core/src/distributed_device_profile_service_new.cpp index 34f69af8..acee876d 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -833,8 +833,7 @@ int32_t DistributedDeviceProfileServiceNew::SendSubscribeInfos( const std::map>& listeners) { listenerMapTrans_.clear(); - for (const auto& [key, subscribeInfoExt] : listenerMap) - { + for (const auto& [key, subscribeInfoExt] : listenerMap) { auto listenerIt = listeners.find(key); if (listenerIt == listeners.end()) { continue; -- Gitee From 63708daa0b2c375ea1782b64183ca48dad647c6c Mon Sep 17 00:00:00 2001 From: BrainL Date: Sat, 14 Jun 2025 12:29:15 +0800 Subject: [PATCH 9/9] merge fix Signed-off-by: BrainL --- services/core/include/distributed_device_profile_service_new.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/include/distributed_device_profile_service_new.h b/services/core/include/distributed_device_profile_service_new.h index 4a5aff5a..ecc665d2 100644 --- a/services/core/include/distributed_device_profile_service_new.h +++ b/services/core/include/distributed_device_profile_service_new.h @@ -160,7 +160,7 @@ private: SUBSYS_ACCOUNT_SYS_ABILITY_ID_BEGIN }; - SubscribeInfoExt subscribeInfoExt_ + SubscribeInfoExt subscribeInfoExt_; std::map listenerMapTrans_; }; } // namespace DeviceProfile -- Gitee