diff --git a/bundle.json b/bundle.json index ed1e699dd1077a097ddcbc0944c771f37d1391b0..13d18d0360b09ec16f9e5b325285f170d06a770e 100644 --- a/bundle.json +++ b/bundle.json @@ -28,6 +28,7 @@ "c_utils", "common_event_service", "config_policy", + "data_share", "ffrt", "hisysevent", "hilog", diff --git a/common/BUILD.gn b/common/BUILD.gn index 0dd870dd174503a3fe920d360d824ec02bdc45b7..cf00d93411a1e8d4c8644d2a8b58c306bb1c78d7 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -55,12 +55,16 @@ ohos_shared_library("distributed_device_profile_common") { "src/interfaces/accessee.cpp", "src/interfaces/accesser.cpp", "src/interfaces/characteristic_profile.cpp", + "src/interfaces/device_icon_info.cpp", + "src/interfaces/device_icon_info_filter_options.cpp", "src/interfaces/device_profile.cpp", + "src/interfaces/device_profile_filter_options.cpp", "src/interfaces/dp_inited_callback_proxy.cpp", "src/interfaces/dp_inited_callback_stub.cpp", "src/interfaces/dp_subscribe_info.cpp", "src/interfaces/dp_sync_options.cpp", "src/interfaces/i_profile_change_listener.cpp", + "src/interfaces/product_info.cpp", "src/interfaces/profile_change_listener_proxy.cpp", "src/interfaces/profile_change_listener_stub.cpp", "src/interfaces/service_profile.cpp", diff --git a/common/include/constants/distributed_device_profile_constants.h b/common/include/constants/distributed_device_profile_constants.h index 289ebc55a136304e61233391a7090a0a23106026..229c6b3000170b8e75affa3c264401ecc0372bc1 100644 --- a/common/include/constants/distributed_device_profile_constants.h +++ b/common/include/constants/distributed_device_profile_constants.h @@ -42,13 +42,59 @@ extern const std::string OS_SYS_CAPACITY; extern const std::string OS_API_LEVEL; extern const std::string OS_VERSION; extern const std::string OS_TYPE; +extern const std::string TYPE; extern const std::string OH_PROFILE_SUFFIX; +extern const std::string ID; +extern const std::string DEV_TYPE; +extern const std::string MANU; +extern const std::string SN; +extern const std::string PRODUCT_ID; +extern const std::string SUB_PRODUCT_ID; +extern const std::string HIV; +extern const std::string MAC; +extern const std::string BLE_MAC; +extern const std::string BR_MAC; +extern const std::string SLE_MAC; +extern const std::string FWV; +extern const std::string HWV; +extern const std::string SWV; +extern const std::string PROT_TYPE; +extern const std::string SETUP_TYPE; +extern const std::string WISE_USER_ID; +extern const std::string WISE_DEVICE_ID; +extern const std::string ROOM_NAME; +extern const std::string REGISTER_TIME; +extern const std::string MODIFY_TIME; +extern const std::string SHARE_TIME; +extern const std::string PRODUCTOR_INFO_VERSION; +extern const std::string INNER_MODEL; +extern const std::string DEVICE_PROFILE_TABLE; +extern const std::string DEVICE_ICON_INFO_TABLE; +extern const std::string PRODUCT_INFO_TABLE; +extern const std::string SYSTEM; /* ServiceProfile Attribute */ extern const std::string SERVICE_NAME; +extern const std::string SERVICE_PROFILE_SERVICE_ID; extern const std::string SERVICE_TYPE; +extern const std::string SERVICE_PROFILE_TABLE; +extern const std::string RDB_USER_ID; +extern const std::string SERVICE_PROFILE_DEVICE_PROFILE_ID; +extern const std::string SERVICE_PROFILE_SERVICE_TYPE; /* CharacteristicProfile Attribute */ +extern const std::string SERVICE_PROFILE_ID; +extern const std::string CHARACTERISTIC_PROFILE_TABLE; extern const std::string CHARACTERISTIC_KEY; extern const std::string CHARACTERISTIC_VALUE; +/* ProductInfo Attribute */ +extern const std::string PRODUCT_NAME; +extern const std::string PRODUCT_SHORT_NAME; +extern const std::string IMAGE_VERSION; +/* DeviceIconInfo Attribute */ +extern const std::string IMAGE_TYPE; +extern const std::string SPEC_NAME; +extern const std::string DEVICE_ICON; +extern const std::string DEVICE_ICON_VERSION; +extern const std::string DEVICE_ICON_URL; /* TrustDeviceProfile Attribute */ extern const std::string SUBSCRIBE_TRUST_DEVICE_PROFILE; extern const std::string DEVICE_ID_TYPE; @@ -135,17 +181,30 @@ constexpr int32_t MAX_INTERFACE_SIZE = 20; constexpr int32_t MAX_SUBSCRIBE_INFO_SIZE = 500; constexpr int32_t MAX_SYNC_RESULTS_SIZE = 50; constexpr int32_t MAX_STATIC_CAPABILITY_SIZE = 100; +constexpr int32_t MAX_ID_SIZE = 1000; +constexpr int32_t MAX_ICON_SIZE = 4*1024*1024; constexpr int32_t MIN_USER_ID = 0; constexpr int32_t MAX_USER_ID = 100000; constexpr uint32_t MAX_TRUSTED_DEVICE_SIZE = 1000; extern const std::string IS_MULTI_USER; extern const std::string SEPARATOR; +extern const std::string SLASHES; extern const std::string DEV_PREFIX; extern const std::string SVR_PREFIX; extern const std::string CHAR_PREFIX; extern const std::string USER_ID; extern const std::string TOKEN_ID; +extern const std::string DEVICE_PROFILE_ID; extern const std::string ALL_PROC; +extern const std::string TYPE_UNKNOWN; +extern const std::string TYPE_PHONE; +extern const std::string TYPE_PAD; +extern const std::string TYPE_TV; +extern const std::string TYPE_CAR; +extern const std::string TYPE_WATCH; +extern const std::string TYPE_PC; +extern const std::string TYPE_2IN1; +extern const std::string HIV_VERSION; constexpr int32_t NUM_1 = 1; constexpr int32_t NUM_2 = 2; constexpr int32_t NUM_3 = 3; @@ -153,6 +212,9 @@ constexpr int32_t NUM_4 = 4; constexpr int32_t NUM_5 = 5; constexpr int32_t NUM_6 = 6; constexpr int32_t DEFAULT_USER_ID = -1; +constexpr int32_t DEFAULT_ID = -1; +constexpr int32_t DEFAULT_SERVICE_PROFILE_ID = -1; +constexpr int32_t DEFAULT_DEVICE_PROFILE_ID = -1; constexpr uint32_t NUM_1U = 1; constexpr uint32_t NUM_8U = 8; constexpr uint16_t CUR_SWITCH_LEN = 3; @@ -171,6 +233,7 @@ extern const std::string USERID; extern const std::string BUNDLENAME; extern const std::string TOKENID; extern const std::string ACCOUNTID; +extern const std::string PRODUCTID; extern const std::string DEVICEID_EQUAL_CONDITION; extern const std::string ACCESSCONTROLID_EQUAL_CONDITION; extern const std::string ACCESSERID_EQUAL_CONDITION; @@ -179,6 +242,7 @@ constexpr int32_t ROWCNT_INIT = -1; constexpr int32_t RET_INIT = -1; constexpr int32_t ROWCOUNT_INIT = -1; constexpr int32_t CHANGEROWCNT_INIT = -1; +constexpr int32_t CHANGEROWCNT_INIT_ID = -1; constexpr int32_t COLUMNINDEX_INIT = -1; constexpr int32_t STATUS_INIT = 0; constexpr int32_t STATUS_ACTIVE = 1; @@ -191,6 +255,7 @@ constexpr int32_t DELETE_ACCESSEE_CONDITION = 1; constexpr int32_t DELETE_TRUST_CONDITION = 0; constexpr int32_t MAX_SAID = 16777215; constexpr int64_t ROWID_INIT = -1; +constexpr int64_t DEVICE_PROFILE_ID_INIT = -1; constexpr int64_t ACCESSERID_INIT = -1; constexpr int64_t ACCESSEEID_INIT = -1; constexpr int64_t ACCESSCONTROLID_INIT = -1; diff --git a/common/include/constants/distributed_device_profile_errors.h b/common/include/constants/distributed_device_profile_errors.h index 86fa4d0881e800b1fc7bd7cb98b1174a7576baf8..42e71a7259bd4b9e72496729d13de468ddf23ad9 100644 --- a/common/include/constants/distributed_device_profile_errors.h +++ b/common/include/constants/distributed_device_profile_errors.h @@ -54,6 +54,7 @@ constexpr int32_t DP_DEVICE_MANAGER_INIT_FAIL = 98566174; constexpr int32_t DP_TRUST_PROFILE_MANAGER_INIT_FAIL = 98566175; constexpr int32_t DP_DEVICE_PROFILE_MANAGER_INIT_FAIL = 98566176; constexpr int32_t DP_SUBSCRIBE_PROFILE_MANAGER_INIT_FAIL = 98566177; +constexpr int32_t DP_PROFILE_DATA_MANAGER_INIT_FAIL = 98566178; constexpr int32_t DP_CONTENT_SENSOR_MANAGER_INIT_FAIL = 98566179; constexpr int32_t DP_CACHE_UNINIT_FAIL = 98566180; constexpr int32_t DP_DEVICE_MANAGER_UNINIT_FAIL = 98566181; @@ -160,6 +161,34 @@ constexpr int32_t DP_GET_USER_ID_IS_NOT_TRUSTED = 98566280; constexpr int32_t DP_MULTI_USER_MANAGER_INIT_FAIL = 98566281; constexpr int32_t DP_MULTI_USER_MANAGER_UNINIT_FAIL = 98566282; constexpr int32_t DP_DM_ADAPTER_UNINIT_FAIL = 98566283; +// profile_data +constexpr int32_t DP_PUT_DEVICE_ICON_INFO_FAIL = 98566284; +constexpr int32_t DP_DEL_DEVICE_ICON_INFO_FAIL = 98566286; +constexpr int32_t DP_UPDATE_DEVICE_ICON_INFO_FAIL = 98566287; +constexpr int32_t DP_PUT_PRODUCT_INFO_FAIL = 98566288; +constexpr int32_t DP_DEL_PRODUCT_INFO_FAIL = 98566289; +constexpr int32_t DP_UPDATE_PRODUCT_INFO_FAIL = 98566290; +constexpr int32_t DP_RDB_PUT_SERVICE_PROFILE_FAIL = 98566291; +constexpr int32_t DP_RDB_DELETE_SERVICE_PROFILE_FAIL = 98566292; +constexpr int32_t DP_RDB_UPDATE_SERVICE_PROFILE_FAIL = 98566293; +constexpr int32_t DP_RDB_GET_SERVICE_PROFILE_FAIL = 98566294; +constexpr int32_t DP_RDB_SET_SERVICE_PROFILE_ID_FAIL = 98566295; +constexpr int32_t DP_DEVICE_PROFILE_NOT_FOUND = 98566296; +constexpr int32_t DP_SERVICE_PROFILE_NOT_FOUND = 98566297; +constexpr int32_t DP_DEVICE_PROFILE_DAO_INIT_FAIL = 98566298; +constexpr int32_t DP_SERVICE_PROFILE_DAO_INIT_FAIL = 98566299; +constexpr int32_t DP_CHAR_PROFILE_DAO_INIT_FAIL = 98566300; +constexpr int32_t DP_PRODUCT_INFO_DAO_INIT_FAIL = 98566301; +constexpr int32_t DP_DEVICE_ICON_INFO_DAO_INIT_FAIL = 98566302; +constexpr int32_t DP_DEVICE_PROFILE_DAO_UNINIT_FAIL = 98566303; +constexpr int32_t DP_SERVICE_PROFILE_DAO_UNINIT_FAIL = 98566304; +constexpr int32_t DP_CHAR_PROFILE_DAO_UNINIT_FAIL = 98566305; +constexpr int32_t DP_PRODUCT_INFO_DAO_UNINIT_FAIL = 98566306; +constexpr int32_t DP_DEVICE_ICON_INFO_DAO_UNINIT_FAIL = 98566307; +constexpr int32_t DP_CREATE_INDEX_FAIL = 98566308; +constexpr int32_t DP_SETTINGSDATA_MANAGER_INIT_FAIL = 98566309; +constexpr int32_t DP_SETTINGSDATA_MANAGER_UNINIT_FAIL = 98566310; +constexpr int32_t DP_PROFILE_DATA_MANAGER_UNINIT_FAIL = 98566311; } // namespace DistributedDeviceProfile } // namespace OHOS #endif // OHOS_DP_DISTRIBUTED_DEVICE_PROFILE_ERRORS_H diff --git a/common/include/interfaces/device_profile.h b/common/include/interfaces/device_profile.h index c0a2f207ce4542cc2f1ac5d35ae6f26057959f4e..bc67b567f22748a761c5b4ceca622f120efd644f 100644 --- a/common/include/interfaces/device_profile.h +++ b/common/include/interfaces/device_profile.h @@ -27,8 +27,6 @@ class DeviceProfile : public DpParcel { public: DeviceProfile() : deviceId_(""), - deviceTypeName_(""), - deviceTypeId_(0), deviceName_(""), manufactureName_(""), deviceModel_(""), @@ -38,16 +36,35 @@ public: osVersion_(""), osType_(0), isMultiUser_(false), - userId_(DEFAULT_USER_ID) + userId_(DEFAULT_USER_ID), + id_(0), + devType_(""), + manu_(""), + sn_(""), + productId_(""), + subProductId_(""), + hiv_(""), + mac_(""), + fwv_(""), + hwv_(""), + swv_(""), + protType_(0), + wiseUserId_(""), + wiseDeviceId_(""), + registerTime_(""), + modifyTime_(""), + shareTime_(""), + accountId_(""), + bleMac_(""), + brMac_(""), + sleMac_(""), + setupType_(0), + innerModel_("") {} ~DeviceProfile() = default; std::string GetDeviceId() const; void SetDeviceId(const std::string& deviceId); - std::string GetDeviceTypeName() const; - void SetDeviceTypeName(const std::string& deviceTypeName); - int32_t GetDeviceTypeId() const; - void SetDeviceTypeId(int32_t deviceTypeId); std::string GetDeviceName() const; void SetDeviceName(const std::string& deviceName); std::string GetManufactureName() const; @@ -68,16 +85,59 @@ public: void SetIsMultiUser(bool isMultiUser); int32_t GetUserId() const; void SetUserId(int32_t userId); + int32_t GetId() const; + void SetId(int32_t id); + std::string GetDevType() const; + void SetDevType(const std::string& devType); + std::string GetManu() const; + void SetManu(const std::string& manu); + std::string GetSn() const; + void SetSn(const std::string& sn); + std::string GetProductId() const; + void SetProductId(const std::string& productId); + std::string GetSubProductId() const; + void SetSubProductId(const std::string& subProductId); + std::string GetHiv() const; + void SetHiv(const std::string& hiv); + std::string GetMac() const; + void SetMac(const std::string& mac); + std::string GetFwv() const; + void SetFwv(const std::string& fwv); + std::string GetHwv() const; + void SetHwv(const std::string& hwv); + std::string GetSwv() const; + void SetSwv(const std::string& swv); + int32_t GetProtType() const; + void SetProtType(int32_t protType); + std::string GetWiseUserId() const; + void SetWiseUserId(const std::string& wiseUserId); + std::string GetWiseDeviceId() const; + void SetWiseDeviceId(const std::string& wiseDeviceId); + std::string GetRegisterTime() const; + void SetRegisterTime(const std::string& registerTime); + std::string GetModifyTime() const; + void SetModifyTime(std::string modifyTime); + std::string GetShareTime() const; + void SetShareTime(const std::string& shareTime); + std::string GetAccountId() const; + void SetAccountId(const std::string& accountId); + std::string GetInnerModel() const; + void SetInnerModel(const std::string& innerModel); bool Marshalling(MessageParcel& parcel) const override; bool UnMarshalling(MessageParcel& parcel) override; bool operator!=(const DeviceProfile& deviceProfile) const; std::string dump() const override; std::string AnnoymizeDump() const; - + const std::string GetBleMac() const; + void SetBleMac(const std::string& bleMac); + const std::string GetBrMac() const; + void SetBrMac(const std::string& brMac); + const std::string GetSleMac() const; + void SetSleMac(const std::string& sleMac); + int32_t GetSetupType() const; + void SetSetupType(int32_t setupType); private: std::string deviceId_; - std::string deviceTypeName_; - int32_t deviceTypeId_; std::string deviceName_; std::string manufactureName_; std::string deviceModel_; @@ -88,7 +148,30 @@ private: int32_t osType_; bool isMultiUser_; int32_t userId_; + int32_t id_; + std::string devType_; + std::string manu_; + std::string sn_; + std::string productId_; + std::string subProductId_; + std::string hiv_; + std::string mac_; + std::string fwv_; + std::string hwv_; + std::string swv_; + int32_t protType_; + std::string wiseUserId_; + std::string wiseDeviceId_; + std::string registerTime_; + std::string modifyTime_; + std::string shareTime_; + std::string accountId_; + std::string bleMac_; + std::string brMac_; + std::string sleMac_; + int32_t setupType_; + std::string innerModel_; }; } // namespace DistributedDeviceProfile } // namespace OHOS -#endif //OHOS_DP_DEVICE_PROFILE_H +#endif // OHOS_DP_DEVICE_PROFILE_H diff --git a/common/include/interfaces/distributed_device_profile_enums.h b/common/include/interfaces/distributed_device_profile_enums.h index 247efef223810db5d73459b0f0b798a9ce32adfb..95e2f2a56ceae82e4af520182d8112386114ccf5 100644 --- a/common/include/interfaces/distributed_device_profile_enums.h +++ b/common/include/interfaces/distributed_device_profile_enums.h @@ -61,7 +61,12 @@ enum class DPInterfaceCode : uint32_t { ON_TRUST_DEVICE_PROFILE_ACTIVE = 43, ON_TRUST_DEVICE_PROFILE_INACTIVE = 44, PUT_ALL_TRUSTED_DEVICES = 45, - MAX = 46 + PUT_DEVICE_PROFILE_BATCH = 46, + GET_DEVICE_PROFILES = 47, + GET_DEVICE_ICON_INFOS = 48, + PUT_DEVICE_ICON_INFO_BATCH = 49, + PUT_PRODUCT_INFO_BATCH = 50, + MAX = 51 }; enum class DeviceIdType : uint32_t { diff --git a/common/include/interfaces/i_distributed_device_profile.h b/common/include/interfaces/i_distributed_device_profile.h index c84bb3ef01cef692c19484d6f5fd8cae5429a016..9c0a4996952d87eeca600dd1209689e8faa7eb75 100644 --- a/common/include/interfaces/i_distributed_device_profile.h +++ b/common/include/interfaces/i_distributed_device_profile.h @@ -22,10 +22,14 @@ #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_profile.h" #include "trust_device_profile.h" #include "trusted_device_info.h" @@ -45,11 +49,14 @@ public: std::vector& accessControlProfiles) = 0; virtual int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) = 0; virtual int32_t DeleteAccessControlProfile(int32_t accessControlId) = 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 GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile) = 0; virtual int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, @@ -66,6 +73,10 @@ public: 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; }; } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/common/include/utils/content_sensor_manager_utils.h b/common/include/utils/content_sensor_manager_utils.h index 0e44572a1c0087504d773e54615ee7d2c85d642e..b7f5c7c325961add989232f69a755a7e06ffdd7d 100644 --- a/common/include/utils/content_sensor_manager_utils.h +++ b/common/include/utils/content_sensor_manager_utils.h @@ -34,6 +34,7 @@ public: std::string ObtainOsFullName(); std::string ObtainDisplayVersion(); std::string ObtainLocalUdid(); + std::string ObtainProductId(); void ObtainDeviceDataSyncMode(); bool IsDeviceE2ESync(); @@ -46,6 +47,7 @@ private: std::string osFullName_ = ""; std::string displayVersion_ = ""; std::string localUdid_ = ""; + std::string productId_ = ""; std::atomic isDeviceE2ESync_ {false}; std::mutex csMutex_; }; diff --git a/common/include/utils/ipc_utils.h b/common/include/utils/ipc_utils.h index 551cc35604dcec8cdad5151c345eea66f3590105..4168ecac9227a5ec38bfd161f507baf61246205b 100644 --- a/common/include/utils/ipc_utils.h +++ b/common/include/utils/ipc_utils.h @@ -27,11 +27,13 @@ #include "accessee.h" #include "accesser.h" #include "characteristic_profile.h" +#include "device_icon_info.h" #include "device_profile.h" #include "distributed_device_profile_constants.h" #include "distributed_device_profile_errors.h" #include "distributed_device_profile_log.h" #include "dp_subscribe_info.h" +#include "product_info.h" #include "service_profile.h" #include "trust_device_profile.h" #include "trusted_device_info.h" @@ -42,17 +44,29 @@ class IpcUtils { public: static bool Marshalling(MessageParcel& parcel, const std::vector& trustDeviceProfiles); static bool Marshalling(MessageParcel& parcel, const std::vector& aclProfiles); + static bool Marshalling(MessageParcel& parcel, const std::vector& deviceProfiles); static bool Marshalling(MessageParcel& parcel, const std::vector& serviceProfiles); static bool Marshalling(MessageParcel& parcel, const std::vector& charProfiles); + static bool Marshalling(MessageParcel& parcel, const std::vector& strings); + static bool Marshalling(MessageParcel& parcel, const std::vector& params); + static bool Marshalling(MessageParcel& parcel, const std::vector& params); static bool Marshalling(MessageParcel& parcel, const std::map& params); static bool Marshalling(MessageParcel& parcel, const std::map& listenerMap); static bool Marshalling(MessageParcel& parcel, const std::unordered_set& changeTypes); static bool Marshalling(MessageParcel& parcel, const std::vector& deviceInfos); + static bool Marshalling(MessageParcel& parcel, const std::vector& deviceIconInfos); + static bool Marshalling(MessageParcel& parcel, const std::vector& productInfos); + static bool UnMarshalling(MessageParcel& parcel, std::vector& productInfos); + static bool UnMarshalling(MessageParcel& parcel, std::vector& deviceIconInfos); static bool UnMarshalling(MessageParcel& parcel, std::vector& trustDeviceProfiles); static bool UnMarshalling(MessageParcel& parcel, std::vector& aclProfiles); + static bool UnMarshalling(MessageParcel& parcel, std::vector& deviceProfiles); static bool UnMarshalling(MessageParcel& parcel, std::vector& serviceProfiles); static bool UnMarshalling(MessageParcel& parcel, std::vector& charProfiles); + static bool UnMarshalling(MessageParcel& parcel, std::vector& strings); + static bool UnMarshalling(MessageParcel& parcel, std::vector& params); + static bool UnMarshalling(MessageParcel& parcel, std::vector& params); static bool UnMarshalling(MessageParcel& parcel, std::map& params); static bool UnMarshalling(MessageParcel& parcel, std::map& listenerMap); diff --git a/common/src/constants/distributed_device_profile_constants.cpp b/common/src/constants/distributed_device_profile_constants.cpp index 7414d4bb5643697cf5baeb5ef8b93998d8a038a1..1269c7c97bcac6b51dc2036ae01a86e420d0a7cf 100644 --- a/common/src/constants/distributed_device_profile_constants.cpp +++ b/common/src/constants/distributed_device_profile_constants.cpp @@ -24,21 +24,67 @@ namespace { const std::string DEVICE_ID = "deviceId"; const std::string DEVICE_TYPE_ID = "deviceTypeId"; const std::string DEVICE_TYPE_NAME = "deviceTypeName"; -const std::string DEVICE_NAME = "deviceIdName"; +const std::string DEVICE_NAME = "deviceName"; const std::string MANUFACTURE_NAME = "manufactureName"; -const std::string DEVICE_MODEL = "deviceModel"; +const std::string DEVICE_MODEL = "model"; const std::string STORAGE_CAPACITY = "storageCapacity"; const std::string OS_SYS_CAPACITY = "osSysCapacity"; const std::string OS_API_LEVEL = "osApiLevel"; const std::string OS_VERSION = "osVersion"; const std::string OS_TYPE = "osType"; +const std::string TYPE = "type"; const std::string OH_PROFILE_SUFFIX = "_OH"; +const std::string ID = "id"; +const std::string DEV_TYPE = "devType"; +const std::string MANU = "manu"; +const std::string SN = "sn"; +const std::string PRODUCT_ID = "productId"; +const std::string SUB_PRODUCT_ID = "subProductId"; +const std::string HIV = "hiv"; +const std::string MAC = "mac"; +const std::string BLE_MAC = "bleMac"; +const std::string BR_MAC = "brMac"; +const std::string SLE_MAC = "sleMac"; +const std::string FWV = "fwv"; +const std::string HWV = "hwv"; +const std::string SWV = "swv"; +const std::string PROT_TYPE = "protType"; +const std::string SETUP_TYPE = "setupType"; +const std::string WISE_USER_ID = "wiseUserId"; +const std::string WISE_DEVICE_ID = "wiseDeviceId"; +const std::string ROOM_NAME = "roomName"; +const std::string REGISTER_TIME = "registerTime"; +const std::string MODIFY_TIME = "modifyTime"; +const std::string SHARE_TIME = "shareTime"; +const std::string PRODUCTOR_INFO_VERSION = "productorInfoVersion"; +const std::string INNER_MODEL = "innerModel"; +const std::string DEVICE_PROFILE_TABLE = "device_profile"; +const std::string DEVICE_ICON_INFO_TABLE = "device_icon_info"; +const std::string PRODUCT_INFO_TABLE = "product_info"; +const std::string SYSTEM = "system"; /* ServiceProfile Attribute */ const std::string SERVICE_NAME = "serviceName"; +const std::string SERVICE_PROFILE_SERVICE_ID = "serviceId"; const std::string SERVICE_TYPE = "serviceType"; +const std::string SERVICE_PROFILE_TABLE = "service_profile"; +const std::string RDB_USER_ID = "userId"; +const std::string SERVICE_PROFILE_DEVICE_PROFILE_ID = "deviceProfileId"; +const std::string SERVICE_PROFILE_SERVICE_TYPE = "serviceType"; /* CharacteristicProfile Attribute */ +const std::string SERVICE_PROFILE_ID = "serviceProfileId"; +const std::string CHARACTERISTIC_PROFILE_TABLE = "characteristic_profile"; const std::string CHARACTERISTIC_KEY = "characteristicKey"; const std::string CHARACTERISTIC_VALUE = "characteristicValue"; +/* ProductInfo Attribute */ +const std::string PRODUCT_NAME = "productName"; +const std::string PRODUCT_SHORT_NAME = "productShortName"; +const std::string IMAGE_VERSION = "imageVersion"; +/* DeviceIconInfo Attribute */ +const std::string IMAGE_TYPE = "imageType"; +const std::string SPEC_NAME = "specName"; +const std::string DEVICE_ICON = "icon"; +const std::string DEVICE_ICON_VERSION = "version"; +const std::string DEVICE_ICON_URL = "url"; /* TrustDeviceProfile Attribute */ const std::string SUBSCRIBE_TRUST_DEVICE_PROFILE = "trust_device_profile"; const std::string DEVICE_ID_TYPE = "deviceIdType"; @@ -104,12 +150,23 @@ const std::string PUT_ALL_TRUSTED_DEVICES = "PutAllTrustedDevices"; /* Common constants */ const std::string IS_MULTI_USER = "is_multi_user"; const std::string SEPARATOR = "#"; +const std::string SLASHES = "/"; const std::string DEV_PREFIX = "dev"; const std::string SVR_PREFIX = "svr"; const std::string CHAR_PREFIX = "char"; const std::string USER_ID = "user_id"; +const std::string DEVICE_PROFILE_ID = "deviceProfile_id"; const std::string TOKEN_ID = "token_id"; const std::string ALL_PROC = "all"; +const std::string TYPE_UNKNOWN = "default"; +const std::string TYPE_PHONE = "phone"; +const std::string TYPE_PAD = "tablet"; +const std::string TYPE_TV = "tv"; +const std::string TYPE_CAR = "car"; +const std::string TYPE_WATCH = "wearable"; +const std::string TYPE_PC = "pc"; +const std::string TYPE_2IN1 = "2in1"; +const std::string HIV_VERSION = "1.0"; const std::string DP_PKG_NAME = "ohos.deviceprofile"; const std::string IS_NUMSTRING_RULES = "^[-+]?[0-9]+$"; /* rdb constants */ @@ -120,6 +177,7 @@ const std::string USERID = "userId"; const std::string BUNDLENAME = "bundleName"; const std::string TOKENID = "tokenId"; const std::string ACCOUNTID = "accountId"; +const std::string PRODUCTID = "productId"; const std::string DEVICEID_EQUAL_CONDITION = "deviceId = ?"; const std::string ACCESSCONTROLID_EQUAL_CONDITION = "accessControlId = ?"; const std::string ACCESSERID_EQUAL_CONDITION = "accesserId = ? "; diff --git a/common/src/interfaces/device_profile.cpp b/common/src/interfaces/device_profile.cpp index b51fd2b84dec6f7b3630846ef9d38fef75ecf525..19042c4930a993605505cacdb2e1f46363c1fd8c 100644 --- a/common/src/interfaces/device_profile.cpp +++ b/common/src/interfaces/device_profile.cpp @@ -34,26 +34,6 @@ void DeviceProfile::SetDeviceId(const std::string& deviceId) deviceId_ = deviceId; } -std::string DeviceProfile::GetDeviceTypeName() const -{ - return deviceTypeName_; -} - -void DeviceProfile::SetDeviceTypeName(const std::string &deviceTypeName) -{ - deviceTypeName_ = deviceTypeName; -} - -int32_t DeviceProfile::GetDeviceTypeId() const -{ - return deviceTypeId_; -} - -void DeviceProfile::SetDeviceTypeId(int32_t deviceTypeId) -{ - deviceTypeId_ = deviceTypeId; -} - std::string DeviceProfile::GetDeviceName() const { return deviceName_; @@ -79,7 +59,7 @@ std::string DeviceProfile::GetDeviceModel() const return deviceModel_; } -void DeviceProfile::SetDeviceModel(const std::string &deviceModel) +void DeviceProfile::SetDeviceModel(const std::string& deviceModel) { deviceModel_ = deviceModel; } @@ -154,11 +134,239 @@ void DeviceProfile::SetUserId(int32_t userId) userId_ = userId; } +int32_t DeviceProfile::GetId() const +{ + return id_; +} + +void DeviceProfile::SetId(int32_t id) +{ + id_ = id; +} + +std::string DeviceProfile::GetDevType() const +{ + return devType_; +} + +void DeviceProfile::SetDevType(const std::string& devType) +{ + devType_ = devType; +} + +std::string DeviceProfile::GetManu() const +{ + return manu_; +} + +void DeviceProfile::SetManu(const std::string& manu) +{ + manu_ = manu; +} + +std::string DeviceProfile::GetSn() const +{ + return sn_; +} + +void DeviceProfile::SetSn(const std::string& sn) +{ + sn_ = sn; +} + +std::string DeviceProfile::GetProductId() const +{ + return productId_; +} + +void DeviceProfile::SetProductId(const std::string& productId) +{ + productId_ = productId; +} + +std::string DeviceProfile::GetSubProductId() const +{ + return subProductId_; +} + +void DeviceProfile::SetSubProductId(const std::string& subProductId) +{ + subProductId_ = subProductId; +} + +std::string DeviceProfile::GetHiv() const +{ + return hiv_; +} + +void DeviceProfile::SetHiv(const std::string& hiv) +{ + hiv_ = hiv; +} + +std::string DeviceProfile::GetMac() const +{ + return mac_; +} + +void DeviceProfile::SetMac(const std::string& mac) +{ + mac_ = mac; +} + +std::string DeviceProfile::GetFwv() const +{ + return fwv_; +} + +void DeviceProfile::SetFwv(const std::string& fwv) +{ + fwv_ = fwv; +} + +std::string DeviceProfile::GetHwv() const +{ + return hwv_; +} + +void DeviceProfile::SetHwv(const std::string& hwv) +{ + hwv_ = hwv; +} + +std::string DeviceProfile::GetSwv() const +{ + return swv_; +} + +void DeviceProfile::SetSwv(const std::string& swv) +{ + swv_ = swv; +} + +int32_t DeviceProfile::GetProtType() const +{ + return protType_; +} + +void DeviceProfile::SetProtType(int32_t protType) +{ + protType_ = protType; +} + +std::string DeviceProfile::GetWiseUserId() const +{ + return wiseUserId_; +} + +void DeviceProfile::SetWiseUserId(const std::string& wiseUserId) +{ + wiseUserId_ = wiseUserId; +} + +std::string DeviceProfile::GetWiseDeviceId() const +{ + return wiseDeviceId_; +} + +void DeviceProfile::SetWiseDeviceId(const std::string& wiseDeviceId) +{ + wiseDeviceId_ = wiseDeviceId; +} + +std::string DeviceProfile::GetRegisterTime() const +{ + return registerTime_; +} + +void DeviceProfile::SetRegisterTime(const std::string& registerTime) +{ + registerTime_ = registerTime; +} + +std::string DeviceProfile::GetModifyTime() const +{ + return modifyTime_; +} + +void DeviceProfile::SetModifyTime(std::string modifyTime) +{ + modifyTime_ = modifyTime; +} + +std::string DeviceProfile::GetShareTime() const +{ + return shareTime_; +} + +void DeviceProfile::SetShareTime(const std::string& shareTime) +{ + shareTime_ = shareTime; +} + +std::string DeviceProfile::GetAccountId() const +{ + return accountId_; +} + +void DeviceProfile::SetAccountId(const std::string& accountId) +{ + accountId_ = accountId; +} + +const std::string DeviceProfile::GetBleMac() const +{ + return bleMac_; +} + +void DeviceProfile::SetBleMac(const std::string& bleMac) +{ + bleMac_ = bleMac; +} + +const std::string DeviceProfile::GetBrMac() const +{ + return brMac_; +} + +void DeviceProfile::SetBrMac(const std::string& brMac) +{ + brMac_ = brMac; +} + +const std::string DeviceProfile::GetSleMac() const +{ + return sleMac_; +} + +void DeviceProfile::SetSleMac(const std::string& sleMac) +{ + sleMac_ = sleMac; +} + +int32_t DeviceProfile::GetSetupType() const +{ + return setupType_; +} + +void DeviceProfile::SetSetupType(int32_t setupType) +{ + setupType_ = setupType; +} + +std::string DeviceProfile::GetInnerModel() const +{ + return innerModel_; +} + +void DeviceProfile::SetInnerModel(const std::string& innerModel) +{ + innerModel_ = innerModel; +} + bool DeviceProfile::Marshalling(MessageParcel& parcel) const { WRITE_HELPER_RET(parcel, String, deviceId_, false); - WRITE_HELPER_RET(parcel, String, deviceTypeName_, false); - WRITE_HELPER_RET(parcel, Int32, deviceTypeId_, false); WRITE_HELPER_RET(parcel, String, deviceName_, false); WRITE_HELPER_RET(parcel, String, manufactureName_, false); WRITE_HELPER_RET(parcel, String, deviceModel_, false); @@ -169,14 +377,34 @@ bool DeviceProfile::Marshalling(MessageParcel& parcel) const 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, 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, innerModel_, 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; } bool DeviceProfile::UnMarshalling(MessageParcel& parcel) { READ_HELPER_RET(parcel, String, deviceId_, false); - READ_HELPER_RET(parcel, String, deviceTypeName_, false); - READ_HELPER_RET(parcel, Int32, deviceTypeId_, false); READ_HELPER_RET(parcel, String, deviceName_, false); READ_HELPER_RET(parcel, String, manufactureName_, false); READ_HELPER_RET(parcel, String, deviceModel_, false); @@ -187,18 +415,50 @@ bool DeviceProfile::UnMarshalling(MessageParcel& parcel) 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, 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, innerModel_, 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; } bool DeviceProfile::operator!=(const DeviceProfile& deviceProfile) const { - bool isNotEqual = (deviceId_ != deviceProfile.GetDeviceId() || deviceTypeName_ != deviceProfile.GetDeviceTypeName() - || deviceTypeId_ != deviceProfile.GetDeviceTypeId() || deviceName_ != deviceProfile.GetDeviceName() || + bool isNotEqual = (deviceId_ != deviceProfile.GetDeviceId() || deviceName_ != deviceProfile.GetDeviceName() || manufactureName_ != deviceProfile.GetManufactureName() || deviceModel_ != deviceProfile.GetDeviceModel() || storageCapability_ != deviceProfile.GetStorageCapability() || osSysCap_ != deviceProfile.GetOsSysCap() || - osApiLevel_ != deviceProfile.GetOsApiLevel() || osVersion_ != deviceProfile.GetOsVersion() || osType_ != - deviceProfile.GetOsType() || isMultiUser_ != deviceProfile.IsMultiUser() || userId_ != - deviceProfile.GetUserId()); + osApiLevel_ != deviceProfile.GetOsApiLevel() || osVersion_ != deviceProfile.GetOsVersion() || + osType_ != deviceProfile.GetOsType() || isMultiUser_ != deviceProfile.IsMultiUser() || + userId_ != deviceProfile.GetUserId() || devType_ != deviceProfile.GetDevType() || + manu_ != deviceProfile.GetManu() || sn_ != deviceProfile.GetSn() || + productId_ != deviceProfile.GetProductId() || subProductId_ != deviceProfile.GetSubProductId() || + hiv_ != deviceProfile.GetHiv() || mac_ != deviceProfile.GetMac() || + fwv_ != deviceProfile.GetFwv() || hwv_ != deviceProfile.GetHwv() || + swv_ != deviceProfile.GetSwv() || protType_ != deviceProfile.GetProtType() || + wiseUserId_ != deviceProfile.GetWiseUserId() || wiseDeviceId_ != deviceProfile.GetWiseDeviceId() || + registerTime_ != deviceProfile.GetRegisterTime() || innerModel_ != deviceProfile.GetInnerModel() || + modifyTime_ != deviceProfile.GetModifyTime() || shareTime_ != deviceProfile.GetShareTime() || + accountId_ != deviceProfile.GetAccountId() || id_ != deviceProfile.GetId() || + bleMac_ != deviceProfile.bleMac_ || brMac_ != deviceProfile.brMac_ || sleMac_ != deviceProfile.sleMac_ || + setupType_ != deviceProfile.setupType_); if (isNotEqual) { return true; } else { @@ -214,8 +474,6 @@ std::string DeviceProfile::dump() const return EMPTY_STRING; } cJSON_AddStringToObject(json, DEVICE_ID.c_str(), ProfileUtils::GetAnonyString(deviceId_).c_str()); - cJSON_AddStringToObject(json, DEVICE_TYPE_NAME.c_str(), deviceTypeName_.c_str()); - cJSON_AddNumberToObject(json, DEVICE_TYPE_ID.c_str(), deviceTypeId_); cJSON_AddStringToObject(json, DEVICE_NAME.c_str(), deviceName_.c_str()); cJSON_AddStringToObject(json, MANUFACTURE_NAME.c_str(), manufactureName_.c_str()); cJSON_AddStringToObject(json, DEVICE_MODEL.c_str(), deviceModel_.c_str()); @@ -223,6 +481,7 @@ std::string DeviceProfile::dump() const cJSON_AddStringToObject(json, OS_SYS_CAPACITY.c_str(), osSysCap_.c_str()); cJSON_AddNumberToObject(json, OS_API_LEVEL.c_str(), osApiLevel_); cJSON_AddStringToObject(json, OS_VERSION.c_str(), osVersion_.c_str()); + cJSON_AddStringToObject(json, INNER_MODEL.c_str(), innerModel_.c_str()); cJSON_AddNumberToObject(json, OS_TYPE.c_str(), osType_); cJSON_AddBoolToObject(json, IS_MULTI_USER.c_str(), isMultiUser_); cJSON_AddNumberToObject(json, USER_ID.c_str(), userId_); @@ -246,8 +505,6 @@ std::string DeviceProfile::AnnoymizeDump() const return EMPTY_STRING; } cJSON_AddStringToObject(json, DEVICE_ID.c_str(), ProfileUtils::GetAnonyString(deviceId_).c_str()); - cJSON_AddStringToObject(json, DEVICE_TYPE_NAME.c_str(), deviceTypeName_.c_str()); - cJSON_AddNumberToObject(json, DEVICE_TYPE_ID.c_str(), deviceTypeId_); cJSON_AddStringToObject(json, DEVICE_NAME.c_str(), deviceName_.c_str()); cJSON_AddStringToObject(json, MANUFACTURE_NAME.c_str(), manufactureName_.c_str()); cJSON_AddStringToObject(json, DEVICE_MODEL.c_str(), deviceModel_.c_str()); diff --git a/common/src/utils/content_sensor_manager_utils.cpp b/common/src/utils/content_sensor_manager_utils.cpp index 3d7c418151f07f4301102cfa98ab3f7f5b060ea5..e2d650f4ab575f2fc157c3208ecab6cf0a73671c 100644 --- a/common/src/utils/content_sensor_manager_utils.cpp +++ b/common/src/utils/content_sensor_manager_utils.cpp @@ -164,6 +164,24 @@ std::string ContentSensorManagerUtils::ObtainLocalUdid() return localUdid_; } + +std::string ContentSensorManagerUtils::ObtainProductId() +{ + HILOGI("called!"); + std::lock_guard lock(csMutex_); + if (!productId_.empty()) { + return productId_; + } + const char* productIdTemp = GetProductSeries(); + if (productIdTemp == nullptr) { + HILOGE("get productId failed!"); + return ""; + } + productId_ = productIdTemp; + free((char*)productIdTemp); + return productId_; +} + void ContentSensorManagerUtils::ObtainDeviceDataSyncMode() { char isE2EDeviceParam[SYS_SETTINGS_DATA_SYNC_PARAM_LEN + 1] = {0}; diff --git a/common/src/utils/ipc_utils.cpp b/common/src/utils/ipc_utils.cpp index 882875d433f8f2d77085c395d81d68d072baa8d0..af7d5d8d88b0eb456e27084e8a4bca65e3e4fe2f 100644 --- a/common/src/utils/ipc_utils.cpp +++ b/common/src/utils/ipc_utils.cpp @@ -24,12 +24,12 @@ namespace { } bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& trustDeviceProfiles) { + uint32_t size = trustDeviceProfiles.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (trustDeviceProfiles.empty() || trustDeviceProfiles.size() > MAX_PROFILE_SIZE) { HILOGE("profile size is invalid!size : %{public}zu", trustDeviceProfiles.size()); return false; } - uint32_t size = trustDeviceProfiles.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (const auto& profile : trustDeviceProfiles) { if (!profile.Marshalling(parcel)) { HILOGE("profile Marshalling fail!"); @@ -41,12 +41,12 @@ bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& aclProfiles) { + uint32_t size = aclProfiles.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (aclProfiles.empty() || aclProfiles.size() > MAX_PROFILE_SIZE) { HILOGE("profile size is invalid!size : %{public}zu", aclProfiles.size()); return false; } - uint32_t size = aclProfiles.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (const auto& profile : aclProfiles) { if (!profile.Marshalling(parcel)) { HILOGE("profile Marshalling fail!"); @@ -56,14 +56,48 @@ bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& deviceProfiles) +{ + uint32_t size = deviceProfiles.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); + if (deviceProfiles.empty() || deviceProfiles.size() > MAX_PROFILE_SIZE) { + HILOGE("profile size is invalid!size : %{public}zu", deviceProfiles.size()); + return false; + } + for (const auto& profile : deviceProfiles) { + if (!profile.Marshalling(parcel)) { + HILOGE("profile Marshalling fail!"); + return false; + } + } + return true; +} + +bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& productInfos) +{ + uint32_t size = productInfos.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); + if (productInfos.empty() || productInfos.size() > MAX_PROFILE_SIZE) { + HILOGE("profile size is invalid!size : %{public}zu", productInfos.size()); + return false; + } + for (const auto& productInfo : productInfos) { + if (!productInfo.Marshalling(parcel)) { + HILOGE("productInfo Marshalling fail!"); + return false; + } + } + return true; +} + bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& serviceProfiles) { + uint32_t size = serviceProfiles.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (serviceProfiles.empty() || serviceProfiles.size() > MAX_PROFILE_SIZE) { HILOGE("profile size is invalid!size : %{public}zu", serviceProfiles.size()); return false; } - uint32_t size = serviceProfiles.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (const auto& profile : serviceProfiles) { if (!profile.Marshalling(parcel)) { HILOGE("profile Marshalling fail!"); @@ -75,26 +109,69 @@ bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& charProfiles) { + uint32_t size = charProfiles.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (charProfiles.empty() || charProfiles.size() > MAX_PROFILE_SIZE) { HILOGE("profile size is invalid!size : %{public}zu", charProfiles.size()); return false; } - uint32_t size = charProfiles.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (const auto& profile : charProfiles) { profile.Marshalling(parcel); } return true; } +bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& strings) +{ + size_t size = strings.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); + if (strings.empty() || strings.size() > MAX_ID_SIZE) { + HILOGE("string vector, strings size is invalid! size : %{public}zu", strings.size()); + return false; + } + for (const auto& item : strings) { + WRITE_HELPER_RET(parcel, String, item, false); + } + return true; +} + +bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& params) +{ + size_t size = params.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); + if (params.empty() || params.size() > MAX_ID_SIZE) { + HILOGE("int32_t vector, params size is invalid! size : %{public}zu", params.size()); + return false; + } + for (const auto& item : params) { + WRITE_HELPER_RET(parcel, Int32, item, false); + } + return true; +} + +bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& params) +{ + int32_t length = static_cast(params.size()); + WRITE_HELPER_RET(parcel, Int32, length, false); + if (params.empty() || params.size() > MAX_ICON_SIZE) { + HILOGE("uint8_t vector, params size is invalid! size : %{public}zu", params.size()); + return false; + } + if (length > 0) { + const unsigned char *buffer = reinterpret_cast(params.data()); + parcel.WriteRawData(buffer, length); + } + return true; +} + bool IpcUtils::Marshalling(MessageParcel& parcel, const std::map& params) { + uint32_t size = params.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (params.size() == 0 || params.size() > MAX_PARAM_SIZE) { HILOGE("Params size is invalid!size : %{public}zu", params.size()); return false; } - uint32_t size = params.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (const auto& item : params) { WRITE_HELPER_RET(parcel, String, item.first + SEPARATOR + item.second, false); } @@ -104,12 +181,12 @@ bool IpcUtils::Marshalling(MessageParcel& parcel, const std::map& listenerMap) { + uint32_t size = listenerMap.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (listenerMap.size() == 0 || listenerMap.size() > MAX_LISTENER_SIZE) { HILOGE("listenerMap size is invalid!size : %{public}zu", listenerMap.size()); return false; } - uint32_t size = listenerMap.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (const auto& item : listenerMap) { OHOS::DistributedDeviceProfile::SubscribeInfo subscribeInfo = item.second; if (!subscribeInfo.Marshalling(parcel)) { @@ -122,12 +199,12 @@ bool IpcUtils::Marshalling(MessageParcel& parcel, const std::map& changeTypes) { + uint32_t size = changeTypes.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (changeTypes.size() == 0 || changeTypes.size() > MAX_SUBSCRIBE_CHANGE_SIZE) { HILOGE("listenerMap size is invalid!size : %{public}zu", changeTypes.size()); return false; } - uint32_t size = changeTypes.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (ProfileChangeType item : changeTypes) { WRITE_HELPER_RET(parcel, Int32, static_cast(item), false); } @@ -136,18 +213,68 @@ bool IpcUtils::Marshalling(MessageParcel& parcel, const std::unordered_set& deviceInfos) { + uint32_t size = deviceInfos.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); if (deviceInfos.empty() || deviceInfos.size() > MAX_PROFILE_SIZE) { HILOGE("deviceInfos size is invalid!size : %{public}zu", deviceInfos.size()); return false; } - uint32_t size = deviceInfos.size(); - WRITE_HELPER_RET(parcel, Uint32, size, false); for (const auto& item : deviceInfos) { item.Marshalling(parcel); } return true; } +bool IpcUtils::Marshalling(MessageParcel& parcel, const std::vector& deviceIconInfos) +{ + uint32_t size = deviceIconInfos.size(); + WRITE_HELPER_RET(parcel, Uint32, size, false); + if (deviceIconInfos.empty() || deviceIconInfos.size() > MAX_PROFILE_SIZE) { + HILOGE("deviceInfos size is invalid!size : %{public}zu", deviceIconInfos.size()); + return false; + } + for (const auto& item : deviceIconInfos) { + item.Marshalling(parcel); + } + return true; +} + +bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& deviceIconInfos) +{ + uint32_t size = parcel.ReadUint32(); + if (size == 0 || size > MAX_PROFILE_SIZE) { + HILOGE("Profile size is invalid!size : %{public}u", size); + return false; + } + for (uint32_t i = 0; i < size; i++) { + DeviceIconInfo deviceIconInfo; + if (!deviceIconInfo.UnMarshalling(parcel)) { + HILOGE("Profile UnMarshalling fail!"); + return false; + } + deviceIconInfos.emplace_back(deviceIconInfo); + } + return true; +} + +bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& productInfos) +{ + uint32_t size = parcel.ReadUint32(); + if (size == 0 || size > MAX_PROFILE_SIZE) { + HILOGE("Profile size is invalid!size : %{public}u", size); + return false; + } + for (uint32_t i = 0; i < size; i++) { + ProductInfo productInfo; + if (!productInfo.UnMarshalling(parcel)) { + HILOGE("Profile UnMarshalling fail!"); + return false; + } + productInfos.emplace_back(productInfo); + } + return true; +} + bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& trustDeviceProfiles) { uint32_t size = parcel.ReadUint32(); @@ -184,6 +311,24 @@ bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& deviceProfiles) +{ + uint32_t size = parcel.ReadUint32(); + if (size == 0 || size > MAX_PROFILE_SIZE) { + HILOGE("Profile size is invalid!size : %{public}u", size); + return false; + } + for (uint32_t i = 0; i < size; i++) { + DeviceProfile deviceProfile; + if (!deviceProfile.UnMarshalling(parcel)) { + HILOGE("Profile UnMarshalling fail!"); + return false; + } + deviceProfiles.emplace_back(deviceProfile); + } + return true; +} + bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& serviceProfiles) { uint32_t size = parcel.ReadUint32(); @@ -220,6 +365,53 @@ bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& strings) +{ + 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); + strings.emplace_back(item); + } + return true; +} + +bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& params) +{ + size_t size = parcel.ReadUint32(); + if (size == 0 || size > MAX_ID_SIZE) { + HILOGE("int32_t vector, params size is invalid! size : %{public}zu", size); + return false; + } + for (uint32_t i = 0; i < size; i++) { + int32_t item = 0; + READ_HELPER_RET(parcel, Int32, item, false); + params.emplace_back(item); + } + return true; +} + +bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::vector& params) +{ + 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; + } + const unsigned char *buffer = nullptr; + if ((buffer = reinterpret_cast(parcel.ReadRawData((size_t)length))) == nullptr) { + HILOGE("read raw data failed, length = %{public}d", length); + return false; + } + std::vector icon(buffer, buffer + length); + params = icon; + return true; +} + bool IpcUtils::UnMarshalling(MessageParcel& parcel, std::map& params) { uint32_t size = parcel.ReadUint32(); diff --git a/common/src/utils/profile_utils.cpp b/common/src/utils/profile_utils.cpp index e03ebc48f6cccec2221ce724086f6a4f0bafc109..24bef78c5e968498be44327640f2f4daaa8a3d94 100644 --- a/common/src/utils/profile_utils.cpp +++ b/common/src/utils/profile_utils.cpp @@ -1066,5 +1066,6 @@ int32_t ProfileUtils::ConvertToAccessControlProfile( accessControlProfile.SetBindLevel(bindLevel); return DP_SUCCESS; } + } // namespace DistributedDeviceProfile } // namespace OHOS diff --git a/deviceprofile.gni b/deviceprofile.gni index 607ad0ac7b7f975d518b9c6f22e9650435b71152..72a1357dde60599e7d1284d58811075ff18ab830 100644 --- a/deviceprofile.gni +++ b/deviceprofile.gni @@ -10,8 +10,15 @@ # 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. -device_info_manager_switch_static_disable = true -old_device_profile_path = "//foundation/deviceprofile/device_info_manager/old" +declare_args() { + device_info_manager_switch_static_disable = true + if (defined(global_parts_info) && + defined(global_parts_info.account_os_account)) { + dp_os_account_part_exists = true + } else { + dp_os_account_part_exists = false + } +}old_device_profile_path = "//foundation/deviceprofile/device_info_manager/old" old_device_profile_service = "//foundation/deviceprofile/device_info_manager/old/services" old_device_profile_innerkits = diff --git a/etc/init/deviceprofile.cfg b/etc/init/deviceprofile.cfg index 16c085c67459101df89540fa3804e7f518b56720..5287466605cd28c35006a1f6da47cffa05afb193 100644 --- a/etc/init/deviceprofile.cfg +++ b/etc/init/deviceprofile.cfg @@ -4,7 +4,9 @@ "cmds" : [ "mkdir /data/service/el1/public/database 0711 ddms ddms", "mkdir /data/service/el1/public/database/distributed_device_profile_service 02770 dms ddms", - "mkdir /data/service/el1/public/database/ddps_adapter 02770 dms ddms" + "mkdir /data/service/el1/public/database/ddps_adapter 02770 dms ddms", + "mkdir /data/service/el2/public/database 0711 ddms ddms", + "mkdir /data/service/el2/public/database/distributed_device_profile_service 02770 dms ddms" ] } ], @@ -18,6 +20,7 @@ "ohos.permission.DISTRIBUTED_DATASYNC", "ohos.permission.ACCESS_SERVICE_DM", "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "ohos.permission.MANAGE_SECURE_SETTINGS", "ohos.permission.MONITOR_DEVICE_NETWORK_STATE" ], "permission_acls" : ["ohos.permission.MONITOR_DEVICE_NETWORK_STATE"], diff --git a/interfaces/innerkits/core/include/distributed_device_profile_client.h b/interfaces/innerkits/core/include/distributed_device_profile_client.h index f5cf94616b086936d5f69319b38a0f0a986f5808..11394d0dacbbcd6b2012027f75d03d15ce1d72c2 100644 --- a/interfaces/innerkits/core/include/distributed_device_profile_client.h +++ b/interfaces/innerkits/core/include/distributed_device_profile_client.h @@ -52,11 +52,13 @@ public: std::vector& accessControlProfiles); int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles); int32_t DeleteAccessControlProfile(int32_t accessControlId); + 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(DeviceProfileFilterOptions& options, 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, @@ -65,6 +67,10 @@ public: bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID); int32_t DeleteCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, const std::string& characteristicKey, bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID); + 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 SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo); int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo); int32_t SyncDeviceProfile(const DpSyncOptions& syncOptions, sptr syncCb); diff --git a/interfaces/innerkits/core/include/distributed_device_profile_proxy.h b/interfaces/innerkits/core/include/distributed_device_profile_proxy.h index fa5df3a7f4f383f3d83ae04f0c19161271ad70ec..c270f289dcd229dae6ffb1b91532a7b9b9037c0d 100644 --- a/interfaces/innerkits/core/include/distributed_device_profile_proxy.h +++ b/interfaces/innerkits/core/include/distributed_device_profile_proxy.h @@ -47,11 +47,14 @@ public: std::vector& accessControlProfiles) override; int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) override; int32_t DeleteAccessControlProfile(int32_t accessControlId) 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 GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile) override; int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, @@ -67,6 +70,10 @@ public: 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; private: static inline BrokerDelegator delegator_; diff --git a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp index f6ed851c1f17c5f419330c5bbde99fd0b676f2e6..5301eeb7bda62bbee948e393c49334dc0f80b9c5 100644 --- a/interfaces/innerkits/core/src/distributed_device_profile_client.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_client.cpp @@ -204,6 +204,16 @@ int32_t DistributedDeviceProfileClient::DeleteAccessControlProfile(int32_t acces return dpService->DeleteAccessControlProfile(accessControlId); } +int32_t DistributedDeviceProfileClient::PutDeviceProfileBatch(std::vector& deviceProfiles) +{ + auto dpService = GetDeviceProfileService(); + if (dpService == nullptr) { + HILOGE("Get dp service failed"); + return DP_GET_SERVICE_FAILED; + } + return dpService->PutDeviceProfileBatch(deviceProfiles); +} + int32_t DistributedDeviceProfileClient::PutServiceProfile(const ServiceProfile& serviceProfile) { auto dpService = GetDeviceProfileService(); @@ -263,6 +273,17 @@ int32_t DistributedDeviceProfileClient::GetDeviceProfile(const std::string& devi return dpService->GetDeviceProfile(deviceId, deviceProfile); } +int32_t DistributedDeviceProfileClient::GetDeviceProfiles(DeviceProfileFilterOptions& options, + std::vector& deviceProfiles) +{ + auto dpService = GetDeviceProfileService(); + if (dpService == nullptr) { + HILOGE("Get dp service failed"); + return DP_GET_SERVICE_FAILED; + } + return dpService->GetDeviceProfiles(options, deviceProfiles); +} + int32_t DistributedDeviceProfileClient::GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile) { @@ -274,6 +295,38 @@ int32_t DistributedDeviceProfileClient::GetServiceProfile(const std::string& dev return dpService->GetServiceProfile(deviceId, serviceName, serviceProfile); } + +int32_t DistributedDeviceProfileClient::PutProductInfoBatch(const std::vector& productInfos) +{ + auto dpService = GetDeviceProfileService(); + if (dpService == nullptr) { + HILOGE("Get dp service failed"); + return DP_GET_SERVICE_FAILED; + } + return dpService->PutProductInfoBatch(productInfos); +} + +int32_t DistributedDeviceProfileClient::PutDeviceIconInfoBatch(const std::vector& deviceIconInfos) +{ + auto dpService = GetDeviceProfileService(); + if (dpService == nullptr) { + HILOGE("Get dp service failed"); + return DP_GET_SERVICE_FAILED; + } + return dpService->PutDeviceIconInfoBatch(deviceIconInfos); +} + +int32_t DistributedDeviceProfileClient::GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, + std::vector& deviceIconInfos) +{ + auto dpService = GetDeviceProfileService(); + if (dpService == nullptr) { + HILOGE("Get dp service failed"); + return DP_GET_SERVICE_FAILED; + } + return dpService->GetDeviceIconInfos(filterOptions, deviceIconInfos); +} + int32_t DistributedDeviceProfileClient::GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, const std::string& characteristicId, CharacteristicProfile& characteristicProfile) { diff --git a/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp b/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp index e2cadf66250fc285eb97b801abd885ad64d2f3d6..a4efab2f36dc1885b5a097dfd4c15f67b50578ed 100644 --- a/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp +++ b/interfaces/innerkits/core/src/distributed_device_profile_proxy.cpp @@ -52,6 +52,56 @@ int32_t DistributedDeviceProfileProxy::UpdateAccessControlProfile(const AccessCo 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) { @@ -132,6 +182,21 @@ int32_t DistributedDeviceProfileProxy::DeleteAccessControlProfile(int32_t access 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; @@ -211,6 +276,26 @@ int32_t DistributedDeviceProfileProxy::GetDeviceProfile(const std::string& devic 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::GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile) { diff --git a/old/services/core/include/contentsensor/content_sensor_manager.h b/old/services/core/include/contentsensor/content_sensor_manager.h index a07007c724db41c33efc5361271eabe6eff0ea23..8dc8c45426819dda22becd792ac7e2034cc24cc0 100644 --- a/old/services/core/include/contentsensor/content_sensor_manager.h +++ b/old/services/core/include/contentsensor/content_sensor_manager.h @@ -36,4 +36,4 @@ private: }; } // namespace DeviceProfile } // namespace OHOS -#endif // OHOS_DEVICE_PROFILE_CONTENT_SENSOR_MANAGER_H \ No newline at end of file +#endif // OHOS_DEVICE_PROFILE_CONTENT_SENSOR_MANAGER_H diff --git a/old/services/core/include/distributed_device_profile_stub.h b/old/services/core/include/distributed_device_profile_stub.h index 24bb73848cdf6fb9574526e23ba4414896b89390..a90645d923e197e7f6a21b41558e95c64b071c10 100644 --- a/old/services/core/include/distributed_device_profile_stub.h +++ b/old/services/core/include/distributed_device_profile_stub.h @@ -46,11 +46,13 @@ public: int32_t GetAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); int32_t GetAllAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); int32_t DeleteAccessControlProfileInner(MessageParcel& data, MessageParcel& reply); + int32_t PutDeviceProfileBatchInner(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 GetDeviceProfileNewInner(MessageParcel& data, MessageParcel& reply); + int32_t GetDeviceProfilesInner(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); @@ -62,6 +64,9 @@ public: int32_t SubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply); int32_t UnSubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply); int32_t PutAllTrustedDevicesInner(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); virtual void DelayUnloadTask() { return; @@ -77,6 +82,9 @@ private: void InitAclAndSubscribe(); 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 NotifyOldEventInner(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option); diff --git a/old/services/core/src/distributed_device_profile_stub.cpp b/old/services/core/src/distributed_device_profile_stub.cpp index 29091128edb1dbe2bd02101c84e62c9c397a3ec6..3ebc74c68189ae44896207e893f006de99f3ca44 100644 --- a/old/services/core/src/distributed_device_profile_stub.cpp +++ b/old/services/core/src/distributed_device_profile_stub.cpp @@ -118,6 +118,11 @@ void DistributedDeviceProfileStub::InitAclAndSubscribe() aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED)); aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE_INITED)); aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::PUT_ALL_TRUSTED_DEVICES)); + aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::PUT_DEVICE_PROFILE_BATCH)); + aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::GET_DEVICE_PROFILES)); + aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::GET_DEVICE_ICON_INFOS)); + aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::PUT_DEVICE_ICON_INFO_BATCH)); + aclAndSubscribeFuncs_.emplace_back(static_cast(DPInterfaceCode::PUT_PRODUCT_INFO_BATCH)); } int32_t DistributedDeviceProfileStub::NotifyAclEventInner(uint32_t code, MessageParcel& data, @@ -158,6 +163,25 @@ int32_t DistributedDeviceProfileStub::NotifyAclEventInner(uint32_t code, Message return UnSubscribeDeviceProfileInitedInner(data, reply); case static_cast(DPInterfaceCode::PUT_ALL_TRUSTED_DEVICES): return PutAllTrustedDevicesInner(data, reply); + default: + return NotifyProfileDataEventInner(code, data, reply, option); + } +} + +int32_t DistributedDeviceProfileStub::NotifyProfileDataEventInner(uint32_t code, MessageParcel& data, + MessageParcel& reply, MessageOption& option) +{ + switch (code) { + 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); default: HILOGW("unknown request code, please check, code = %{public}u", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -399,6 +423,57 @@ int32_t DistributedDeviceProfileStub::GetTrustDeviceProfileInner(MessageParcel& return DP_SUCCESS; } +int32_t DistributedDeviceProfileStub::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 = DistributedDeviceProfileServiceNew::GetInstance().PutProductInfoBatch(productInfos); + if (!reply.WriteInt32(ret)) { + HILOGE("Write reply failed"); + return ERR_FLATTEN_OBJECT; + } + return DP_SUCCESS; +} + +int32_t DistributedDeviceProfileStub::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 = DistributedDeviceProfileServiceNew::GetInstance().PutDeviceIconInfoBatch(deviceIconInfos); + if (!reply.WriteInt32(ret)) { + HILOGE("Write reply failed"); + return ERR_FLATTEN_OBJECT; + } + return DP_SUCCESS; +} + +int32_t DistributedDeviceProfileStub::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 = DistributedDeviceProfileServiceNew::GetInstance().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 DistributedDeviceProfileStub::GetAllTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply) { HILOGI("called"); @@ -466,6 +541,21 @@ int32_t DistributedDeviceProfileStub::DeleteAccessControlProfileInner(MessagePar return DP_SUCCESS; } +int32_t DistributedDeviceProfileStub::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 = DistributedDeviceProfileServiceNew::GetInstance().PutDeviceProfileBatch(deviceProfiles); + if (!reply.WriteInt32(ret)) { + HILOGE("Write reply failed"); + return ERR_FLATTEN_OBJECT; + } + return DP_SUCCESS; +} + int32_t DistributedDeviceProfileStub::PutServiceProfileInner(MessageParcel& data, MessageParcel& reply) { HILOGI("called"); @@ -550,6 +640,26 @@ int32_t DistributedDeviceProfileStub::GetDeviceProfileNewInner(MessageParcel& da return DP_SUCCESS; } +int32_t DistributedDeviceProfileStub::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 = DistributedDeviceProfileServiceNew::GetInstance().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 DistributedDeviceProfileStub::GetServiceProfileInner(MessageParcel& data, MessageParcel& reply) { std::string deviceId; diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index 96690c81840f2c467db8d8a4986243b77b8eccf3..3a171e413764c27591d7c2362cb6c6bce5c25389 100644 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -22,6 +22,7 @@ config("device_info_manager_config") { "include", "include/contentsensormanager", "include/common", + "include/data_share", "include/deviceprofilemanager", "include/deviceprofilemanager/listener", "include/dfx", @@ -31,6 +32,7 @@ config("device_info_manager_config") { "include/persistenceadapter", "include/persistenceadapter/kvadapter", "include/persistenceadapter/rdbadapter", + "include/profiledatamanager", "include/publishcommonevent", "include/subscribeprofilemanager", "include/staticcapabilitycollector", @@ -58,6 +60,9 @@ ohos_shared_library("distributed_device_profile_svr") { "-D_FORTIFY_SOURCE=2", "-O2", ] + if (dp_os_account_part_exists) { + cflags += [ "-DDP_OS_ACCOUNT_PART_EXISTS" ] + } cflags_cc = cflags @@ -70,6 +75,7 @@ ohos_shared_library("distributed_device_profile_svr") { install_enable = true sources = [ + "src/common/dp_services_constants.cpp", "src/contentsensormanager/collaboration_info_collector.cpp", "src/contentsensormanager/collector.cpp", "src/contentsensormanager/content_sensor_manager.cpp", @@ -78,6 +84,7 @@ ohos_shared_library("distributed_device_profile_svr") { "src/contentsensormanager/switch_status_collector.cpp", "src/contentsensormanager/syscap_info_collector.cpp", "src/contentsensormanager/system_info_collector.cpp", + "src/datashare/settings_data_manager.cpp", "src/deviceprofilemanager/device_profile_manager.cpp", "src/deviceprofilemanager/listener/kv_data_change_listener.cpp", "src/deviceprofilemanager/listener/kv_store_death_recipient.cpp", @@ -93,7 +100,12 @@ ohos_shared_library("distributed_device_profile_svr") { "src/permissionmanager/permission_manager.cpp", "src/persistenceadapter/kvadapter/kv_adapter.cpp", "src/persistenceadapter/kvadapter/switch_adapter.cpp", + "src/persistenceadapter/rdbadapter/profile_data_rdb_adapter.cpp", "src/persistenceadapter/rdbadapter/rdb_adapter.cpp", + "src/profiledatamanager/device_icon_info_dao.cpp", + "src/profiledatamanager/device_profile_dao.cpp", + "src/profiledatamanager/product_info_dao.cpp", + "src/profiledatamanager/profile_data_manager.cpp", "src/publishcommonevent/dp_account_common_event.cpp", "src/staticcapabilitycollector/static_capability_collector.cpp", "src/staticcapabilityloader/static_capability_loader.cpp", @@ -118,6 +130,7 @@ ohos_shared_library("distributed_device_profile_svr") { "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", "config_policy:configpolicy_util", + "data_share:datashare_consumer", "device_auth:deviceauth_sdk", "device_manager:devicemanagersdk", "dmsfwk:common_sdk", diff --git a/services/core/include/contentsensormanager/content_sensor_manager.h b/services/core/include/contentsensormanager/content_sensor_manager.h index ed9ad5ab1517c2e9af2714e98f360019c5094551..e1c79b2c99b92689b15c8b524912c0e32205f277 100644 --- a/services/core/include/contentsensormanager/content_sensor_manager.h +++ b/services/core/include/contentsensormanager/content_sensor_manager.h @@ -17,6 +17,8 @@ #define OHOS_DP_CONTENT_SENSOR_MANAGER_H #include + +#include "device_profile.h" #include "single_instance.h" namespace OHOS { @@ -30,6 +32,7 @@ public: private: int32_t Collect(); + int32_t CollectInfoToProfileData(DeviceProfile& collectProfile); }; } // namespace DeviceProfile } // namespace OHOS diff --git a/services/core/include/contentsensormanager/system_info_collector.h b/services/core/include/contentsensormanager/system_info_collector.h index b230a68bdaa17aab8820d8f89c3f9d2983e77248..feb2e124a8906f634fb1c9311a9f85aea0242e44 100644 --- a/services/core/include/contentsensormanager/system_info_collector.h +++ b/services/core/include/contentsensormanager/system_info_collector.h @@ -17,6 +17,7 @@ #define OHOS_DP_PROFILE_SYSTEM_INFO_COLLECTOR_H #include +#include #include "collector.h" #include "device_profile.h" @@ -28,9 +29,27 @@ public: bool ConvertToProfile(DeviceProfile& profile) override; private: + const std::map deviceTypeMap = { + {TYPE_UNKNOWN, "00A"}, + {TYPE_PHONE, "00E"}, + {TYPE_PAD, "011"}, + {TYPE_TV, "09C"}, + {TYPE_CAR, "083"}, + {TYPE_WATCH, "06D"}, + {TYPE_PC, "00C"}, + {TYPE_2IN1, "A2F"} + }; int32_t GetOsType(); + int32_t GetProtType(); std::string GetOsVersion(); + std::string GetDeviceName(); + std::string GetProductId(); + std::string GetSn(); + std::string GetDeviceModel(); + std::string GetDevType(); + std::string GetDeviceManufacturer(); + std::string GetDeviceTypeId(); }; } // namespace DeviceProfile } // namespace OHOS -#endif // OHOS_DP_PROFILE_SYSTEM_INFO_COLLECTOR_H \ No newline at end of file +#endif // OHOS_DP_PROFILE_SYSTEM_INFO_COLLECTOR_H diff --git a/services/core/include/distributed_device_profile_service_new.h b/services/core/include/distributed_device_profile_service_new.h index 45a86995163c82c2d88a594a57f7f1e08dcca937..7028257e07c307795a7d43e0351237865669748c 100644 --- a/services/core/include/distributed_device_profile_service_new.h +++ b/services/core/include/distributed_device_profile_service_new.h @@ -20,11 +20,15 @@ #include #include #include +#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 "dp_account_common_event.h" #include "i_dp_inited_callback.h" #include "event_handler.h" #include "event_runner.h" +#include "product_info.h" #include "single_instance.h" #include "system_ability.h" #include "system_ability_definition.h" @@ -50,11 +54,13 @@ public: std::vector& accessControlProfiles) override; int32_t GetAllAccessControlProfile(std::vector& accessControlProfiles) override; int32_t DeleteAccessControlProfile(int32_t accessControlId) 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 GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile) override; int32_t GetCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, @@ -63,6 +69,10 @@ public: int32_t userId = DEFAULT_USER_ID) override; int32_t DeleteCharacteristicProfile(const std::string& deviceId, const std::string& serviceName, const std::string& characteristicKey, bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID) 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 SubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; int32_t UnSubscribeDeviceProfile(const SubscribeInfo& subscribeInfo) override; int32_t SyncDeviceProfile(const DistributedDeviceProfile::DpSyncOptions& syncOptions, @@ -93,6 +103,7 @@ private: int32_t NotifyDeviceProfileInited(); void GetDynamicProfilesFromTempCache(std::map& entries); void ClearProfileCache(); + int32_t UnInitNext(); private: std::mutex accountCommonEventManagerMtx_; diff --git a/services/core/include/multiusermanager/multi_user_manager.h b/services/core/include/multiusermanager/multi_user_manager.h index 0605aabb4873c54114252202ac70ee18e0b110f1..092b1b89ed9a755e9fccce1eedf6f8d934176a66 100644 --- a/services/core/include/multiusermanager/multi_user_manager.h +++ b/services/core/include/multiusermanager/multi_user_manager.h @@ -31,14 +31,12 @@ class MultiUserManager { DECLARE_SINGLE_INSTANCE(MultiUserManager); public: int32_t Init(); - int32_t UnInit(); - int32_t GetCurrentForegroundUserID(); - void SetCurrentForegroundUserID(int32_t userId); - int32_t GetForegroundUserIDFromOs(int32_t& foregroundId); + std::string GetOhosAccountId(); + std::string GetOhosAccountIdByUserId(int32_t userId); private: int32_t foregroundUserId_ = DEFAULT_USER_ID; diff --git a/services/core/include/utils/profile_cache.h b/services/core/include/utils/profile_cache.h index 527400c12c536488168ec5001ae1b328df958da3..5ca3dbe27b7ee330f562011d6049715e397953e2 100644 --- a/services/core/include/utils/profile_cache.h +++ b/services/core/include/utils/profile_cache.h @@ -89,6 +89,7 @@ public: std::string GetLocalUdid(); std::string GetLocalNetworkId(); std::string GetLocalUuid(); + std::string GetLocalAccountId(); int32_t AddAllTrustedDevices(const std::vector& deviceInfos); bool FilterAndGroupOnlineDevices(const std::vector& deviceList, std::vector& ohBasedDevices, std::vector& notOHBasedDevices); diff --git a/services/core/src/contentsensormanager/content_sensor_manager.cpp b/services/core/src/contentsensormanager/content_sensor_manager.cpp index ee7323204aa55e79c57842ab5465f5a48d3ef0f9..e1ad24c42b985d6feadd8584aa707a9dceb34b17 100644 --- a/services/core/src/contentsensormanager/content_sensor_manager.cpp +++ b/services/core/src/contentsensormanager/content_sensor_manager.cpp @@ -22,12 +22,15 @@ #include "collaboration_info_collector.h" #include "collector.h" #include "content_sensor_manager_utils.h" -#include "device_profile.h" +#include "device_profile_filter_options.h" #include "device_profile_manager.h" #include "distributed_device_profile_errors.h" #include "distributed_device_profile_log.h" #include "dms_info_collector.h" +#include "multi_user_manager.h" #include "pasteboard_info_collector.h" +#include "profile_data_manager.h" +#include "profile_cache.h" #include "switch_status_collector.h" #include "syscap_info_collector.h" #include "system_info_collector.h" @@ -54,7 +57,7 @@ int32_t ContentSensorManager::UnInit() int32_t ContentSensorManager::Collect() { - auto csTask = []() { + auto csTask = [this]() { HILOGI("ContentSensorManager Collect"); std::list> taskList; taskList.push_back(std::make_shared()); @@ -73,6 +76,8 @@ int32_t ContentSensorManager::Collect() } deviceProfile.SetDeviceId(ContentSensorManagerUtils::GetInstance().ObtainLocalUdid()); DeviceProfileManager::GetInstance().PutDeviceProfile(deviceProfile); + deviceProfile.SetUserId(MultiUserManager::GetInstance().GetCurrentForegroundUserID()); + CollectInfoToProfileData(deviceProfile); if (!svrProfileList.empty()) { DeviceProfileManager::GetInstance().PutServiceProfileBatch(svrProfileList); } else { @@ -92,5 +97,35 @@ int32_t ContentSensorManager::Collect() csTaskThread.join(); return DP_SUCCESS; } + +int32_t ContentSensorManager::CollectInfoToProfileData(DeviceProfile& collectProfile) +{ + DeviceProfileFilterOptions devFilterOptions; + devFilterOptions.AddDeviceIds(ProfileCache::GetInstance().GetLocalUdid()); + devFilterOptions.SetAccountId(ProfileCache::GetInstance().GetLocalAccountId()); + devFilterOptions.SetUserId(MultiUserManager::GetInstance().GetCurrentForegroundUserID()); + std::vector oldDeviceProfiles; + int32_t ret = DeviceProfileDao::GetInstance().GetDeviceProfiles(devFilterOptions, oldDeviceProfiles); + if ((ret != DP_SUCCESS) && (ret != DP_NOT_FIND_DATA)) { + HILOGE("GetDeviceProfiles failed,ret=%{public}d", ret); + return ret; + } + if (!oldDeviceProfiles.empty()) { + DeviceProfile oldDeviceProfile = oldDeviceProfiles[0]; + collectProfile.SetWiseDeviceId(oldDeviceProfile.GetWiseDeviceId()); + collectProfile.SetWiseUserId(oldDeviceProfile.GetWiseUserId()); + collectProfile.SetSetupType(oldDeviceProfile.GetSetupType()); + collectProfile.SetRegisterTime(oldDeviceProfile.GetRegisterTime()); + collectProfile.SetModifyTime(oldDeviceProfile.GetModifyTime()); + collectProfile.SetShareTime(oldDeviceProfile.GetShareTime()); + collectProfile.SetInnerModel(oldDeviceProfile.GetInnerModel()); + } + ret = ProfileDataManager::GetInstance().PutDeviceProfile(collectProfile); + if (ret != DP_SUCCESS) { + HILOGE("PutDeviceProfile failed,ret=%{public}d", ret); + return ret; + } + return DP_SUCCESS; +} } // namespace DeviceProfile } // namespace OHOS diff --git a/services/core/src/contentsensormanager/system_info_collector.cpp b/services/core/src/contentsensormanager/system_info_collector.cpp index fa47c929400821010793c47f94bfb10d4010af40..b516cc1ecfcd3a592c32433e2364b0800256bd8d 100644 --- a/services/core/src/contentsensormanager/system_info_collector.cpp +++ b/services/core/src/contentsensormanager/system_info_collector.cpp @@ -17,12 +17,15 @@ #include "parameter.h" #include "securec.h" +#include "string_ex.h" #include "content_sensor_manager_utils.h" #include "device_profile.h" #include "distributed_device_profile_constants.h" #include "distributed_device_profile_log.h" +#include "multi_user_manager.h" #include "profile_utils.h" +#include "settings_data_manager.h" namespace OHOS { namespace DistributedDeviceProfile { @@ -44,6 +47,14 @@ bool SystemInfoCollector::ConvertToProfile(DeviceProfile& profile) { profile.SetOsType(GetOsType()); profile.SetOsVersion(GetOsVersion()); + profile.SetDeviceName(GetDeviceName()); + profile.SetProductId(GetProductId()); + profile.SetSn(GetSn()); + profile.SetDeviceModel(GetDeviceModel()); + profile.SetDevType(GetDeviceTypeId()); + profile.SetManu(GetDeviceManufacturer()); + profile.SetHiv(HIV_VERSION); + profile.SetProtType(GetProtType()); return true; } @@ -77,5 +88,57 @@ std::string SystemInfoCollector::GetOsVersion() { return DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainDisplayVersion(); } + +std::string SystemInfoCollector::GetDeviceName() +{ + std::string deviceName = ""; + SettingsDataManager::GetInstance().GetUserDefinedDeviceName( + MultiUserManager::GetInstance().GetCurrentForegroundUserID(), deviceName); + if (deviceName.empty()) { + SettingsDataManager::GetInstance().GetDeviceName(deviceName); + } + return deviceName; +} + +std::string SystemInfoCollector::GetProductId() +{ + return DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainProductId(); +} + +std::string SystemInfoCollector::GetSn() +{ + return DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainSerial(); +} + +std::string SystemInfoCollector::GetDeviceModel() +{ + return DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainProductModel(); +} + +std::string SystemInfoCollector::GetDevType() +{ + return DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainDeviceType(); +} + +std::string SystemInfoCollector::GetDeviceManufacturer() +{ + return DistributedDeviceProfile::ContentSensorManagerUtils::GetInstance().ObtainManufacture(); +} + +int32_t SystemInfoCollector::GetProtType() +{ + return 0; +} + +std::string SystemInfoCollector::GetDeviceTypeId() +{ + std::string deviceType = GetDevType(); + auto it = deviceTypeMap.find(deviceType); + if (it != deviceTypeMap.end()) { + return it->second; + } + HILOGE("deviceType not find on deviceTypeMap,deviceType=%{public}s", deviceType.c_str()); + return ""; +} } // namespace DeviceProfile -} // namespace OHOS \ No newline at end of file +} // 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 01e8a39502bbf63a95f10f1039e9f6c76ace1c4c..040dbe60e2607adeaad83fac2e4aca013c05eb9c 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -36,6 +36,7 @@ #include "multi_user_manager.h" #include "permission_manager.h" #include "profile_cache.h" +#include "profile_data_manager.h" #include "static_profile_manager.h" #include "static_capability_collector.h" #include "subscribe_profile_manager.h" @@ -78,6 +79,10 @@ int32_t DistributedDeviceProfileServiceNew::Init() HILOGE("TrustProfileManager init failed"); return DP_TRUST_PROFILE_MANAGER_INIT_FAIL; } + if (ProfileDataManager::GetInstance().Init() != DP_SUCCESS) { + HILOGE("ProfileDataManager init failed"); + return DP_PROFILE_DATA_MANAGER_INIT_FAIL; + } if (SubscribeProfileManager::GetInstance().Init() != DP_SUCCESS) { HILOGE("SubscribeProfileManager init failed"); return DP_SUBSCRIBE_PROFILE_MANAGER_INIT_FAIL; @@ -113,14 +118,14 @@ int32_t DistributedDeviceProfileServiceNew::PostInit() HILOGE("StaticCapabilityCollector init failed"); return DP_CONTENT_SENSOR_MANAGER_INIT_FAIL; } - if (ContentSensorManager::GetInstance().Init() != DP_SUCCESS) { - HILOGE("ContentSensorManager init failed"); - return DP_CONTENT_SENSOR_MANAGER_INIT_FAIL; - } if (MultiUserManager::GetInstance().Init() != DP_SUCCESS) { HILOGE("MultiUserManager init failed"); return DP_MULTI_USER_MANAGER_INIT_FAIL; } + if (ContentSensorManager::GetInstance().Init() != DP_SUCCESS) { + HILOGE("ContentSensorManager init failed"); + return DP_CONTENT_SENSOR_MANAGER_INIT_FAIL; + } SaveSwitchProfilesFromTempCache(); SaveDynamicProfilesFromTempCache(); isInited_ = true; @@ -141,6 +146,10 @@ int32_t DistributedDeviceProfileServiceNew::UnInit() HILOGE("TrustProfileManager UnInit failed"); return DP_TRUST_PROFILE_MANAGER_UNINIT_FAIL; } + if (ProfileDataManager::GetInstance().UnInit() != DP_SUCCESS) { + HILOGE("ProfileDataManager UnInit failed"); + return DP_PROFILE_DATA_MANAGER_UNINIT_FAIL; + } if (SwitchProfileManager::GetInstance().UnInit() != DP_SUCCESS) { HILOGE("SwitchProfileManager UnInit failed"); return DP_DEVICE_PROFILE_MANAGER_UNINIT_FAIL; @@ -153,6 +162,17 @@ int32_t DistributedDeviceProfileServiceNew::UnInit() HILOGE("StaticProfileManager UnInit failed"); return DP_CONTENT_SENSOR_MANAGER_UNINIT_FAIL; } + int32_t ret = UnInitNext(); + if (ret != DP_SUCCESS) { + return ret; + } + DestroyUnloadHandler(); + ClearProfileCache(); + return DP_SUCCESS; +} + +int32_t DistributedDeviceProfileServiceNew::UnInitNext() +{ if (ProfileCache::GetInstance().UnInit() != DP_SUCCESS) { HILOGE("ProfileCache UnInit failed"); return DP_CACHE_INIT_FAIL; @@ -181,8 +201,6 @@ int32_t DistributedDeviceProfileServiceNew::UnInit() HILOGE("EventHandlerFactory UnInit failed"); return DP_CACHE_UNINIT_FAIL; } - DestroyUnloadHandler(); - ClearProfileCache(); return DP_SUCCESS; } @@ -235,6 +253,40 @@ int32_t DistributedDeviceProfileServiceNew::UpdateAccessControlProfile(const Acc return ret; } +int32_t DistributedDeviceProfileServiceNew::PutProductInfoBatch(const std::vector& productInfos) +{ + if (!PermissionManager::GetInstance().CheckCallerPermission()) { + HILOGE("the caller is permission denied!"); + return DP_PERMISSION_DENIED; + } + HILOGD("CheckCallerPermission success interface PutProductInfoBatch"); + int32_t ret = ProfileDataManager::GetInstance().PutProductInfoBatch(productInfos); + return ret; +} + +int32_t DistributedDeviceProfileServiceNew::PutDeviceIconInfoBatch(const std::vector& deviceIconInfos) +{ + if (!PermissionManager::GetInstance().CheckCallerPermission()) { + HILOGE("the caller is permission denied!"); + return DP_PERMISSION_DENIED; + } + HILOGD("CheckCallerPermission success interface PutDeviceIconInfoBatch"); + int32_t ret = ProfileDataManager::GetInstance().PutDeviceIconInfoBatch(deviceIconInfos); + return ret; +} + +int32_t DistributedDeviceProfileServiceNew::GetDeviceIconInfos(const DeviceIconInfoFilterOptions& filterOptions, + std::vector& deviceIconInfos) +{ + if (!PermissionManager::GetInstance().CheckCallerPermission()) { + HILOGE("the caller is permission denied!"); + return DP_PERMISSION_DENIED; + } + HILOGD("CheckCallerPermission success interface GetDeviceIconInfos"); + int32_t ret = ProfileDataManager::GetInstance().GetDeviceIconInfos(filterOptions, deviceIconInfos); + return ret; +} + int32_t DistributedDeviceProfileServiceNew::GetTrustDeviceProfile(const std::string& deviceId, TrustDeviceProfile& trustDeviceProfile) { @@ -294,6 +346,17 @@ int32_t DistributedDeviceProfileServiceNew::DeleteAccessControlProfile(int32_t a return ret; } +int32_t DistributedDeviceProfileServiceNew::PutDeviceProfileBatch(std::vector& deviceProfiles) +{ + if (!PermissionManager::GetInstance().CheckCallerPermission()) { + HILOGE("the caller is permission denied!"); + return DP_PERMISSION_DENIED; + } + HILOGD("CheckCallerPermission success interface PutDeviceProfileBatch"); + int32_t ret = ProfileDataManager::GetInstance().PutDeviceProfileBatch(deviceProfiles); + return ret; +} + int32_t DistributedDeviceProfileServiceNew::PutServiceProfile(const ServiceProfile& serviceProfile) { if (!PermissionManager::GetInstance().CheckCallerPermission()) { @@ -406,6 +469,18 @@ int32_t DistributedDeviceProfileServiceNew::GetDeviceProfile(const std::string& return ret; } +int32_t DistributedDeviceProfileServiceNew::GetDeviceProfiles(DeviceProfileFilterOptions& options, + std::vector& deviceProfiles) +{ + if (!PermissionManager::GetInstance().CheckCallerPermission()) { + HILOGE("this caller is permission denied!"); + return DP_PERMISSION_DENIED; + } + HILOGD("CheckCallerPermission success interface GetDeviceProfiles"); + int32_t ret = ProfileDataManager::GetInstance().GetDeviceProfiles(options, deviceProfiles); + return ret; +} + int32_t DistributedDeviceProfileServiceNew::GetServiceProfile(const std::string& deviceId, const std::string& serviceName, ServiceProfile& serviceProfile) { diff --git a/services/core/src/multiusermanager/multi_user_manager.cpp b/services/core/src/multiusermanager/multi_user_manager.cpp index 7bfdb8e8448a385bdb36bb523e50ccc5e673eaa9..89d4822320493282c2b983ef5844e7f14eb282b6 100644 --- a/services/core/src/multiusermanager/multi_user_manager.cpp +++ b/services/core/src/multiusermanager/multi_user_manager.cpp @@ -62,6 +62,9 @@ void MultiUserManager::SetCurrentForegroundUserID(int32_t userId) int32_t MultiUserManager::GetCurrentForegroundUserID() { std::lock_guard lock(foregroundUserIdLock_); + if (foregroundUserId_ == DEFAULT_USER_ID) { + GetForegroundUserIDFromOs(foregroundUserId_); + } return foregroundUserId_; } @@ -77,5 +80,41 @@ int32_t MultiUserManager::GetForegroundUserIDFromOs(int32_t& foregroundId) return DP_SUCCESS; } +std::string MultiUserManager::GetOhosAccountId() +{ +#if (defined(__LITEOS_M__) || defined(LITE_DEVICE)) + return ""; +#elif DP_OS_ACCOUNT_PART_EXISTS + AccountSA::OhosAccountInfo accountInfo; + ErrCode ret = OHOS::AccountSA::OhosAccountKits::GetInstance().GetOhosAccountInfo(accountInfo); + if (ret != 0 || accountInfo.uid_ == "") { + HILOGE("GetOhosAccountId error ret: %{public}d", ret); + return ""; + } + return accountInfo.uid_; +#else + return ""; +#endif +} + +std::string MultiUserManager::GetOhosAccountIdByUserId(int32_t userId) +{ +#if (defined(__LITEOS_M__) || defined(LITE_DEVICE)) + (void)userId; + return ""; +#elif DP_OS_ACCOUNT_PART_EXISTS + AccountSA::OhosAccountInfo accountInfo; + ErrCode ret = OHOS::AccountSA::OhosAccountKits::GetInstance().GetOsAccountDistributedInfo(userId, accountInfo); + if (ret != 0 || accountInfo.uid_ == "") { + HILOGE("error ret: %{public}d", ret); + return ""; + } + return accountInfo.uid_; +#else + (void)userId; + return ""; +#endif +} + } // namespace DistributedHardware } // namespace OHOS diff --git a/services/core/src/utils/profile_cache.cpp b/services/core/src/utils/profile_cache.cpp index 2135d387f618b3a16500c9e62f8080f8573ce90c..4bb1ddcdc759625cf738ace55dfaeb7e1707fb3e 100644 --- a/services/core/src/utils/profile_cache.cpp +++ b/services/core/src/utils/profile_cache.cpp @@ -25,6 +25,7 @@ #include "distributed_device_profile_errors.h" #include "device_profile_manager.h" #include "dm_adapter.h" +#include "multi_user_manager.h" #include "profile_utils.h" #include "static_profile_manager.h" #include "switch_profile_manager.h" @@ -805,6 +806,12 @@ std::string ProfileCache::GetLocalUuid() return localUuid; } +std::string ProfileCache::GetLocalAccountId() +{ + return MultiUserManager::GetInstance().GetOhosAccountIdByUserId( + MultiUserManager::GetInstance().GetCurrentForegroundUserID()); +} + int32_t ProfileCache::AddAllTrustedDevices(const std::vector& deviceInfos) { HILOGI("deviceInfos.size: %{public}zu!", deviceInfos.size()); diff --git a/services/core/test/unittest/device_profile_manager_test.cpp b/services/core/test/unittest/device_profile_manager_test.cpp index 29c3185c78adeb8cfc0a9feededbd145c5a4a099..4de5faa606182cf2f720f546a10c9c8ac8a5f0dc 100644 --- a/services/core/test/unittest/device_profile_manager_test.cpp +++ b/services/core/test/unittest/device_profile_manager_test.cpp @@ -162,8 +162,6 @@ HWTEST_F(DeviceProfileManagerTest, PutDeviceProfile001, TestSize.Level1) DeviceProfile deviceProfile; ContentSensorManagerUtils::GetInstance().localUdid_ = "anything"; deviceProfile.SetDeviceId("anything"); - deviceProfile.SetDeviceTypeName("anything"); - deviceProfile.SetDeviceTypeId(0); deviceProfile.SetDeviceName("anything"); deviceProfile.SetManufactureName("anything"); deviceProfile.SetDeviceModel("anything"); @@ -187,8 +185,6 @@ HWTEST_F(DeviceProfileManagerTest, PutDeviceProfile002, TestSize.Level1) { DeviceProfile deviceProfile; deviceProfile.SetDeviceId(""); - deviceProfile.SetDeviceTypeName("anything"); - deviceProfile.SetDeviceTypeId(0); deviceProfile.SetDeviceName("anything"); deviceProfile.SetManufactureName("anything"); deviceProfile.SetDeviceModel("anything"); @@ -213,8 +209,6 @@ HWTEST_F(DeviceProfileManagerTest, PutDeviceProfile003, TestSize.Level1) DeviceProfile deviceProfile1; ContentSensorManagerUtils::GetInstance().localUdid_ = "anything1"; deviceProfile1.SetDeviceId("anything1"); - deviceProfile1.SetDeviceTypeName("anything"); - deviceProfile1.SetDeviceTypeId(0); deviceProfile1.SetDeviceName("anything"); deviceProfile1.SetManufactureName("anything"); deviceProfile1.SetDeviceModel("anything"); @@ -226,8 +220,6 @@ HWTEST_F(DeviceProfileManagerTest, PutDeviceProfile003, TestSize.Level1) DeviceProfile deviceProfile2; deviceProfile2.SetDeviceId("anything1"); - deviceProfile2.SetDeviceTypeName("anything"); - deviceProfile2.SetDeviceTypeId(0); deviceProfile2.SetDeviceName("anything"); deviceProfile2.SetManufactureName("anything"); deviceProfile2.SetDeviceModel("anything"); @@ -252,8 +244,6 @@ HWTEST_F(DeviceProfileManagerTest, PutDeviceProfile004, TestSize.Level1) { DeviceProfile deviceProfile10; deviceProfile10.SetDeviceId("anything10"); - deviceProfile10.SetDeviceTypeName("anything"); - deviceProfile10.SetDeviceTypeId(0); deviceProfile10.SetDeviceName("anything"); deviceProfile10.SetManufactureName("anything"); deviceProfile10.SetDeviceModel("anything"); @@ -279,8 +269,6 @@ HWTEST_F(DeviceProfileManagerTest, PutDeviceProfile005, TestSize.Level1) DeviceProfile deviceProfile11; ContentSensorManagerUtils::GetInstance().localUdid_ = "anything11"; deviceProfile11.SetDeviceId("anything11"); - deviceProfile11.SetDeviceTypeName("anything"); - deviceProfile11.SetDeviceTypeId(0); deviceProfile11.SetDeviceName("anything"); deviceProfile11.SetManufactureName("anything"); deviceProfile11.SetDeviceModel("anything"); @@ -309,8 +297,6 @@ HWTEST_F(DeviceProfileManagerTest, PutDeviceProfile006, TestSize.Level1) DeviceProfile deviceProfile; ContentSensorManagerUtils::GetInstance().localUdid_ = "anything111"; deviceProfile.SetDeviceId("anything111"); - deviceProfile.SetDeviceTypeName("anything"); - deviceProfile.SetDeviceTypeId(0); deviceProfile.SetDeviceName("anything"); deviceProfile.SetManufactureName("anything"); deviceProfile.SetDeviceModel("anything"); @@ -715,8 +701,6 @@ HWTEST_F(DeviceProfileManagerTest, GetDeviceProfile001, TestSize.Level1) ContentSensorManagerUtils::GetInstance().localUdid_ = "deviceId"; string deviceId = ContentSensorManagerUtils::GetInstance().ObtainLocalUdid(); deviceProfile2.SetDeviceId(deviceId); - deviceProfile2.SetDeviceTypeName("anything"); - deviceProfile2.SetDeviceTypeId(0); deviceProfile2.SetDeviceName("anything"); deviceProfile2.SetManufactureName("anything"); deviceProfile2.SetDeviceModel("anything"); @@ -733,8 +717,6 @@ HWTEST_F(DeviceProfileManagerTest, GetDeviceProfile001, TestSize.Level1) EXPECT_EQ(ret, DP_SUCCESS); outDeviceProfile.SetDeviceId(deviceId); string outDeviceId = outDeviceProfile.GetDeviceId(); - outDeviceProfile.GetDeviceTypeName(); - outDeviceProfile.GetDeviceTypeId(); outDeviceProfile.GetDeviceName(); outDeviceProfile.GetManufactureName(); outDeviceProfile.GetDeviceModel(); @@ -1373,8 +1355,6 @@ HWTEST_F(DeviceProfileManagerTest, DeviceProfileMarshalling001, TestSize.Level1) OHOS::MessageParcel data; DeviceProfile deviceProfile; deviceProfile.SetDeviceId("anything"); - deviceProfile.SetDeviceTypeName("anything"); - deviceProfile.SetDeviceTypeId(0); deviceProfile.SetDeviceName("anything"); deviceProfile.SetManufactureName("anything"); deviceProfile.SetDeviceModel("anything"); @@ -1401,8 +1381,6 @@ HWTEST_F(DeviceProfileManagerTest, DeviceProfileOperator001, TestSize.Level1) { DeviceProfile deviceProfile1; deviceProfile1.SetDeviceId("anything1"); - deviceProfile1.SetDeviceTypeName("anything1"); - deviceProfile1.SetDeviceTypeId(0); deviceProfile1.SetDeviceName("anything1"); deviceProfile1.SetManufactureName("anything1"); deviceProfile1.SetDeviceModel("anything1"); @@ -1414,8 +1392,6 @@ HWTEST_F(DeviceProfileManagerTest, DeviceProfileOperator001, TestSize.Level1) DeviceProfile deviceProfile2; deviceProfile2.SetDeviceId("anything2"); - deviceProfile2.SetDeviceTypeName("anything2"); - deviceProfile2.SetDeviceTypeId(0); deviceProfile2.SetDeviceName("anything2"); deviceProfile2.SetManufactureName("anything2"); deviceProfile2.SetDeviceModel("anything2"); @@ -1439,8 +1415,6 @@ HWTEST_F(DeviceProfileManagerTest, DeviceProfileDump001, TestSize.Level1) { DeviceProfile deviceProfile; deviceProfile.SetDeviceId("anything"); - deviceProfile.SetDeviceTypeName("anything"); - deviceProfile.SetDeviceTypeId(0); deviceProfile.SetDeviceName("anything"); deviceProfile.SetManufactureName("anything"); deviceProfile.SetDeviceModel("anything"); @@ -1500,8 +1474,6 @@ HWTEST_F(DeviceProfileManagerTest, GetInKvDB001, TestSize.Level1) string deviceId = ContentSensorManagerUtils::GetInstance().ObtainLocalUdid(); DeviceProfile deviceProfile2; deviceProfile2.SetDeviceId(deviceId); - deviceProfile2.SetDeviceTypeName("GetInKvDB001_DeviceTypeName"); - deviceProfile2.SetDeviceTypeId(0); deviceProfile2.SetDeviceName("GetInKvDB001_DeviceName"); deviceProfile2.SetManufactureName("GetInKvDB001_ManufactureName"); deviceProfile2.SetDeviceModel("GetInKvDB001_DeviceModel"); @@ -1579,8 +1551,6 @@ HWTEST_F(DeviceProfileManagerTest, GetInKvDB002, TestSize.Level1) string deviceId = ContentSensorManagerUtils::GetInstance().ObtainLocalUdid(); DeviceProfile deviceProfile2; deviceProfile2.SetDeviceId(deviceId); - deviceProfile2.SetDeviceTypeName("GetInKvDB001_DeviceTypeName2"); - deviceProfile2.SetDeviceTypeId(0); deviceProfile2.SetDeviceName("GetInKvDB001_DeviceName2"); deviceProfile2.SetManufactureName("GetInKvDB001_ManufactureName2"); deviceProfile2.SetDeviceModel("GetInKvDB001_DeviceModel2"); 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 55c33d4fd33c7b3a8e738927b6a771e7b9092888..b70e955d38edbd3ea19d128b52e31dedc572f1f3 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 @@ -272,8 +272,6 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceProfile001, TestSize.Lev DeviceProfile deviceProfile1; deviceProfile1.SetDeviceId("anything"); - deviceProfile1.SetDeviceTypeName("anything"); - deviceProfile1.SetDeviceTypeId(0); deviceProfile1.SetDeviceName("anything"); deviceProfile1.SetManufactureName("anything"); deviceProfile1.SetDeviceModel("anything"); @@ -284,8 +282,6 @@ HWTEST_F(DistributedDeviceProfileClientKvTest, GetDeviceProfile001, TestSize.Lev deviceProfile1.SetOsType(1); deviceProfile1.GetDeviceId(); - deviceProfile1.GetDeviceTypeName(); - deviceProfile1.GetDeviceTypeId(); deviceProfile1.GetDeviceName(); deviceProfile1.GetManufactureName(); deviceProfile1.GetDeviceModel(); 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 index ce764ef61c4a597bd25f9ad7d0219dee83818250..2d39ce9441bd313e6df14fb87c3527f5c868f727 100644 --- a/services/core/test/unittest/distributed_device_profile_stub_new_test.cpp +++ b/services/core/test/unittest/distributed_device_profile_stub_new_test.cpp @@ -63,6 +63,13 @@ class MockDistributedDeviceProfileStubNew : public DistributedDeviceProfileStubN 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; void DelayUnloadTask() override; bool IsInited() override; }; @@ -248,6 +255,40 @@ 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; +} + /** * @tc.name: IsInterfaceTokenValid001 * @tc.desc: IsInterfaceTokenValid diff --git a/services/core/test/unittest/profile_cache_test.cpp b/services/core/test/unittest/profile_cache_test.cpp index a01acbdfb0f2874b42e3646cd8f0564389bbeb54..9cb605a3d4975b36ac4f3f597cf6f518e9ac389e 100644 --- a/services/core/test/unittest/profile_cache_test.cpp +++ b/services/core/test/unittest/profile_cache_test.cpp @@ -310,8 +310,6 @@ HWTEST_F(ProfileCacheTest, IsDeviceProfileExist_001, TestSize.Level2) DeviceProfile deviceProfile1; deviceProfile1.SetDeviceId("anything1"); - deviceProfile1.SetDeviceTypeName("anything"); - deviceProfile1.SetDeviceTypeId(0); deviceProfile1.SetDeviceName("anything"); deviceProfile1.SetManufactureName("anything"); deviceProfile1.SetDeviceModel("anything"); diff --git a/services/core/test/unittest/profile_control_utils_test.cpp b/services/core/test/unittest/profile_control_utils_test.cpp index 0ed7a522e11ee24143986cd43756bbb5c41bc1d8..25b32e3c3abc11fef15b94aa63b1374c83d70c0f 100644 --- a/services/core/test/unittest/profile_control_utils_test.cpp +++ b/services/core/test/unittest/profile_control_utils_test.cpp @@ -137,8 +137,6 @@ HWTEST_F(ProfileControlUtilsTest, PutDeviceProfile004, TestSize.Level1) DeviceProfile deviceProfile1; ContentSensorManagerUtils::GetInstance().localUdid_ = "anything1"; deviceProfile1.SetDeviceId("anything1"); - deviceProfile1.SetDeviceTypeName("anything"); - deviceProfile1.SetDeviceTypeId(0); deviceProfile1.SetDeviceName("anything"); deviceProfile1.SetManufactureName("anything"); deviceProfile1.SetDeviceModel("anything"); @@ -1338,4 +1336,4 @@ HWTEST_F(ProfileControlUtilsTest, GetSwitchCharacteristicProfile007, TestSize.Le ProfileCache::GetInstance().onlineDevMap_.erase(deviceId); } } // namespace DistributedDeviceProfile -} // namespace OHOS \ No newline at end of file +} // namespace OHOS