mirror of
https://gitee.com/openharmony/distributedhardware_distributed_hardware_fwk
synced 2024-11-23 15:50:09 +00:00
fix:add sensitive value
Signed-off-by: chen0088 <chenmenghuan6@huawei.com>
This commit is contained in:
parent
d8a85db435
commit
f750035f69
@ -47,6 +47,7 @@ namespace DistributedHardware {
|
|||||||
const std::string DEV_TYPE = "dev_type";
|
const std::string DEV_TYPE = "dev_type";
|
||||||
const std::string DH_TYPE = "dh_type";
|
const std::string DH_TYPE = "dh_type";
|
||||||
const std::string DH_ATTRS = "dh_attrs";
|
const std::string DH_ATTRS = "dh_attrs";
|
||||||
|
const std::string DH_SUBTYPE = "dh_subtype";
|
||||||
const std::string DH_LOG_TITLE_TAG = "DHFWK";
|
const std::string DH_LOG_TITLE_TAG = "DHFWK";
|
||||||
const std::string DH_VER = "dh_ver";
|
const std::string DH_VER = "dh_ver";
|
||||||
const std::string COMP_VER = "comp_ver";
|
const std::string COMP_VER = "comp_ver";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -39,6 +39,7 @@ struct EnableParam {
|
|||||||
std::string sourceAttrs;
|
std::string sourceAttrs;
|
||||||
std::string sinkVersion;
|
std::string sinkVersion;
|
||||||
std::string sinkAttrs;
|
std::string sinkAttrs;
|
||||||
|
std::string subtype;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IDistributedHardwareSource {
|
class IDistributedHardwareSource {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -27,6 +27,7 @@ const std::string COMPONENT_LOADER_GET_HARDWARE_HANDLER = "GetHardwareHandler";
|
|||||||
struct DHItem {
|
struct DHItem {
|
||||||
std::string dhId;
|
std::string dhId;
|
||||||
std::string attrs;
|
std::string attrs;
|
||||||
|
std::string subtype;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PluginListener {
|
class PluginListener {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -30,6 +30,11 @@
|
|||||||
|
|
||||||
namespace OHOS {
|
namespace OHOS {
|
||||||
namespace DistributedHardware {
|
namespace DistributedHardware {
|
||||||
|
struct ResourceDesc {
|
||||||
|
std::string subtype;
|
||||||
|
bool sensitiveValue;
|
||||||
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct CompHandler {
|
struct CompHandler {
|
||||||
DHType type;
|
DHType type;
|
||||||
@ -38,6 +43,7 @@ struct CompHandler {
|
|||||||
void *sinkHandler;
|
void *sinkHandler;
|
||||||
int32_t sinkSaId;
|
int32_t sinkSaId;
|
||||||
void *hardwareHandler;
|
void *hardwareHandler;
|
||||||
|
std::vector<ResourceDesc> resourceDesc;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,6 +58,7 @@ struct CompConfig {
|
|||||||
std::string compSinkLoc;
|
std::string compSinkLoc;
|
||||||
std::string compSinkVersion;
|
std::string compSinkVersion;
|
||||||
int32_t compSinkSaId;
|
int32_t compSinkSaId;
|
||||||
|
std::vector<ResourceDesc> compResourceDesc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ComponentLoader {
|
class ComponentLoader {
|
||||||
@ -74,6 +81,7 @@ public:
|
|||||||
int32_t GetLocalDHVersion(DHVersion &dhVersion);
|
int32_t GetLocalDHVersion(DHVersion &dhVersion);
|
||||||
int32_t GetSourceSaId(const DHType dhType);
|
int32_t GetSourceSaId(const DHType dhType);
|
||||||
DHType GetDHTypeBySrcSaId(const int32_t saId);
|
DHType GetDHTypeBySrcSaId(const int32_t saId);
|
||||||
|
std::vector<ResourceDesc> GetCompResourceDesc(const DHType dhType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void *GetHandler(const std::string &soName);
|
void *GetHandler(const std::string &soName);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -34,12 +34,14 @@ public:
|
|||||||
deviceName_(""),
|
deviceName_(""),
|
||||||
deviceType_(0),
|
deviceType_(0),
|
||||||
dhType_(DHType::UNKNOWN),
|
dhType_(DHType::UNKNOWN),
|
||||||
dhAttrs_("")
|
dhAttrs_(""),
|
||||||
|
dhSubtype_("")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CapabilityInfo(std::string dhId, std::string devId, std::string devName, uint16_t devType, DHType dhType,
|
CapabilityInfo(std::string dhId, std::string devId, std::string devName, uint16_t devType, DHType dhType,
|
||||||
std::string dhAttrs)
|
std::string dhAttrs, std::string dhSubtype)
|
||||||
: dhId_(dhId), deviceId_(devId), deviceName_(devName), deviceType_(devType), dhType_(dhType), dhAttrs_(dhAttrs)
|
: dhId_(dhId), deviceId_(devId), deviceName_(devName), deviceType_(devType), dhType_(dhType), dhAttrs_(dhAttrs),
|
||||||
|
dhSubtype_(dhSubtype)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~CapabilityInfo() {}
|
virtual ~CapabilityInfo() {}
|
||||||
@ -68,6 +70,10 @@ public:
|
|||||||
|
|
||||||
void SetDHAttrs(const std::string &dhAttrs);
|
void SetDHAttrs(const std::string &dhAttrs);
|
||||||
|
|
||||||
|
std::string GetDHSubtype() const;
|
||||||
|
|
||||||
|
void SetDHSubtype(const std::string &dhSubtype);
|
||||||
|
|
||||||
virtual std::string GetKey() const;
|
virtual std::string GetKey() const;
|
||||||
virtual std::string GetAnonymousKey() const;
|
virtual std::string GetAnonymousKey() const;
|
||||||
virtual int32_t FromJsonString(const std::string &jsonStr);
|
virtual int32_t FromJsonString(const std::string &jsonStr);
|
||||||
@ -81,6 +87,7 @@ private:
|
|||||||
uint16_t deviceType_;
|
uint16_t deviceType_;
|
||||||
DHType dhType_;
|
DHType dhType_;
|
||||||
std::string dhAttrs_;
|
std::string dhAttrs_;
|
||||||
|
std::string dhSubtype_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ToJson(nlohmann::json &jsonObject, const CapabilityInfo &capability);
|
void ToJson(nlohmann::json &jsonObject, const CapabilityInfo &capability);
|
||||||
|
@ -56,6 +56,9 @@ const std::string COMP_SOURCE_SA_ID = "comp_source_sa_id";
|
|||||||
const std::string COMP_SINK_LOC = "comp_sink_loc";
|
const std::string COMP_SINK_LOC = "comp_sink_loc";
|
||||||
const std::string COMP_SINK_VERSION = "comp_sink_version";
|
const std::string COMP_SINK_VERSION = "comp_sink_version";
|
||||||
const std::string COMP_SINK_SA_ID = "comp_sink_sa_id";
|
const std::string COMP_SINK_SA_ID = "comp_sink_sa_id";
|
||||||
|
const std::string COMP_RESOURCE_DESC = "comp_resource_desc";
|
||||||
|
const std::string COMP_SUBTYPE = "subtype";
|
||||||
|
const std::string COMP_SENSITIVE = "sensitive";
|
||||||
|
|
||||||
const std::string COMPONENTSLOAD_DISTRIBUTED_COMPONENTS = "distributed_components";
|
const std::string COMPONENTSLOAD_DISTRIBUTED_COMPONENTS = "distributed_components";
|
||||||
|
|
||||||
@ -170,6 +173,21 @@ int32_t ParseSink(const nlohmann::json &json, CompConfig &cfg)
|
|||||||
return DH_FWK_SUCCESS;
|
return DH_FWK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ParseResourceDesc(const nlohmann::json &json, CompConfig &cfg)
|
||||||
|
{
|
||||||
|
if (!IsArray(json, COMP_RESOURCE_DESC)) {
|
||||||
|
DHLOGE("COMP_RESOURCE_DESC is invalid");
|
||||||
|
return ERR_DH_FWK_JSON_PARSE_FAILED;
|
||||||
|
}
|
||||||
|
for (const auto &obj : json.at(COMP_RESOURCE_DESC)) {
|
||||||
|
ResourceDesc desc;
|
||||||
|
desc.subtype = obj[COMP_SUBTYPE];
|
||||||
|
desc.sensitiveValue = obj[COMP_SENSITIVE];
|
||||||
|
cfg.compResourceDesc.push_back(desc);
|
||||||
|
}
|
||||||
|
return DH_FWK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
void from_json(const nlohmann::json &json, CompConfig &cfg)
|
void from_json(const nlohmann::json &json, CompConfig &cfg)
|
||||||
{
|
{
|
||||||
if (ParseComponent(json, cfg) != DH_FWK_SUCCESS) {
|
if (ParseComponent(json, cfg) != DH_FWK_SUCCESS) {
|
||||||
@ -184,6 +202,10 @@ void from_json(const nlohmann::json &json, CompConfig &cfg)
|
|||||||
DHLOGE("ParseSink is failed");
|
DHLOGE("ParseSink is failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (ParseResourceDesc(json, cfg) != DH_FWK_SUCCESS) {
|
||||||
|
DHLOGE("ParseResourceDesc is failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CompVersion ComponentLoader::GetCompVersionFromComConfig(const CompConfig& cCfg)
|
CompVersion ComponentLoader::GetCompVersionFromComConfig(const CompConfig& cCfg)
|
||||||
@ -278,6 +300,7 @@ void ComponentLoader::GetAllHandler(std::map<DHType, CompConfig> &dhtypeMap)
|
|||||||
comHandler.sourceSaId = itor->second.compSourceSaId;
|
comHandler.sourceSaId = itor->second.compSourceSaId;
|
||||||
comHandler.sinkHandler = GetHandler(itor->second.compSinkLoc);
|
comHandler.sinkHandler = GetHandler(itor->second.compSinkLoc);
|
||||||
comHandler.sinkSaId = itor->second.compSinkSaId;
|
comHandler.sinkSaId = itor->second.compSinkSaId;
|
||||||
|
comHandler.resourceDesc = itor->second.compResourceDesc;
|
||||||
compHandlerMap_[itor->second.type] = comHandler;
|
compHandlerMap_[itor->second.type] = comHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,5 +527,13 @@ DHType ComponentLoader::GetDHTypeBySrcSaId(const int32_t saId)
|
|||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<ResourceDesc> ComponentLoader::GetCompResourceDesc(const DHType dhType)
|
||||||
|
{
|
||||||
|
if (!IsDHTypeExist(dhType)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return compHandlerMap_[dhType].resourceDesc;
|
||||||
|
}
|
||||||
} // namespace DistributedHardware
|
} // namespace DistributedHardware
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -464,10 +464,11 @@ int32_t ComponentManager::GetEnableParam(const std::string &networkId, const std
|
|||||||
return ERR_DH_FWK_COMPONENT_GET_SINK_VERSION_FAILED;
|
return ERR_DH_FWK_COMPONENT_GET_SINK_VERSION_FAILED;
|
||||||
}
|
}
|
||||||
param.sinkVersion = sinkVersion;
|
param.sinkVersion = sinkVersion;
|
||||||
|
param.subtype = capability->GetDHSubtype();
|
||||||
DHLOGI("success. dhType = %#X, sink uuid =%s, sink dhId = %s, sinVersion = %s, source uuid =%s, source dhId = %s, "
|
DHLOGI("success. dhType = %#X, sink uuid =%s, sink dhId = %s, sinVersion = %s, source uuid =%s, source dhId = %s, "
|
||||||
"sourceVersion = %s", dhType, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(),
|
"sourceVersion = %s, subtype = %s", dhType, GetAnonyString(uuid).c_str(), GetAnonyString(dhId).c_str(),
|
||||||
param.sinkVersion.c_str(), GetAnonyString(sourceDeviceInfo.uuid).c_str(),
|
param.sinkVersion.c_str(), GetAnonyString(sourceDeviceInfo.uuid).c_str(),
|
||||||
GetAnonyString(sourceDHId).c_str(), param.sourceVersion.c_str());
|
GetAnonyString(sourceDHId).c_str(), param.sourceVersion.c_str(), param.subtype.c_str());
|
||||||
|
|
||||||
return DH_FWK_SUCCESS;
|
return DH_FWK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
@ -112,8 +112,8 @@ void LocalHardwareManager::AddLocalCapabilityInfo(const std::vector<DHItem> &dhI
|
|||||||
std::string devName = DHContext::GetInstance().GetDeviceInfo().deviceName;
|
std::string devName = DHContext::GetInstance().GetDeviceInfo().deviceName;
|
||||||
uint16_t devType = DHContext::GetInstance().GetDeviceInfo().deviceType;
|
uint16_t devType = DHContext::GetInstance().GetDeviceInfo().deviceType;
|
||||||
for (auto dhItem : dhItems) {
|
for (auto dhItem : dhItems) {
|
||||||
std::shared_ptr<CapabilityInfo> dhCapabilityInfo =
|
std::shared_ptr<CapabilityInfo> dhCapabilityInfo = std::make_shared<CapabilityInfo>(
|
||||||
std::make_shared<CapabilityInfo>(dhItem.dhId, deviceId, devName, devType, dhType, dhItem.attrs);
|
dhItem.dhId, deviceId, devName, devType, dhType, dhItem.attrs, dhItem.subtype);
|
||||||
capabilityInfos.push_back(dhCapabilityInfo);
|
capabilityInfos.push_back(dhCapabilityInfo);
|
||||||
}
|
}
|
||||||
CapabilityInfoManager::GetInstance()->AddCapability(capabilityInfos);
|
CapabilityInfoManager::GetInstance()->AddCapability(capabilityInfos);
|
||||||
|
@ -40,7 +40,7 @@ void PluginListenerImpl::PluginHardware(const std::string &dhId, const std::stri
|
|||||||
std::string devName = DHContext::GetInstance().GetDeviceInfo().deviceName;
|
std::string devName = DHContext::GetInstance().GetDeviceInfo().deviceName;
|
||||||
uint16_t devType = DHContext::GetInstance().GetDeviceInfo().deviceType;
|
uint16_t devType = DHContext::GetInstance().GetDeviceInfo().deviceType;
|
||||||
std::shared_ptr<CapabilityInfo> dhCapabilityInfo =
|
std::shared_ptr<CapabilityInfo> dhCapabilityInfo =
|
||||||
std::make_shared<CapabilityInfo>(dhId, deviceId, devName, devType, dhType_, attrs);
|
std::make_shared<CapabilityInfo>(dhId, deviceId, devName, devType, dhType_, attrs, "");
|
||||||
capabilityInfos.push_back(dhCapabilityInfo);
|
capabilityInfos.push_back(dhCapabilityInfo);
|
||||||
|
|
||||||
CapabilityInfoManager::GetInstance()->AddCapability(capabilityInfos);
|
CapabilityInfoManager::GetInstance()->AddCapability(capabilityInfos);
|
||||||
|
@ -90,6 +90,16 @@ void CapabilityInfo::SetDHAttrs(const std::string &dhAttrs)
|
|||||||
this->dhAttrs_ = dhAttrs;
|
this->dhAttrs_ = dhAttrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CapabilityInfo::GetDHSubtype() const
|
||||||
|
{
|
||||||
|
return dhSubtype_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CapabilityInfo::SetDHSubtype(const std::string &dhSubtype)
|
||||||
|
{
|
||||||
|
this->dhSubtype_ = dhSubtype;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CapabilityInfo::GetKey() const
|
std::string CapabilityInfo::GetKey() const
|
||||||
{
|
{
|
||||||
std::string kvStoreKey;
|
std::string kvStoreKey;
|
||||||
@ -153,6 +163,10 @@ bool CapabilityInfo::Compare(const CapabilityInfo& capInfo)
|
|||||||
DHLOGE("dhAttrs is not equal");
|
DHLOGE("dhAttrs is not equal");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (strcmp(this->dhSubtype_.c_str(), capInfo.dhSubtype_.c_str()) != 0) {
|
||||||
|
DHLOGE("dhSubtype is not equal");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +178,7 @@ void ToJson(nlohmann::json &jsonObject, const CapabilityInfo &capability)
|
|||||||
jsonObject[DEV_TYPE] = capability.GetDeviceType();
|
jsonObject[DEV_TYPE] = capability.GetDeviceType();
|
||||||
jsonObject[DH_TYPE] = capability.GetDHType();
|
jsonObject[DH_TYPE] = capability.GetDHType();
|
||||||
jsonObject[DH_ATTRS] = capability.GetDHAttrs();
|
jsonObject[DH_ATTRS] = capability.GetDHAttrs();
|
||||||
|
jsonObject[DH_SUBTYPE] = capability.GetDHSubtype();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FromJson(const nlohmann::json &jsonObject, CapabilityInfo &capability)
|
void FromJson(const nlohmann::json &jsonObject, CapabilityInfo &capability)
|
||||||
@ -198,6 +213,11 @@ void FromJson(const nlohmann::json &jsonObject, CapabilityInfo &capability)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
capability.SetDHAttrs(jsonObject.at(DH_ATTRS).get<std::string>());
|
capability.SetDHAttrs(jsonObject.at(DH_ATTRS).get<std::string>());
|
||||||
|
if (!IsString(jsonObject, DH_SUBTYPE)) {
|
||||||
|
DHLOGE("DH_SUBTYPE is invalid!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
capability.SetDHSubtype(jsonObject.at(DH_SUBTYPE).get<std::string>());
|
||||||
}
|
}
|
||||||
} // namespace DistributedHardware
|
} // namespace DistributedHardware
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -48,9 +48,10 @@ void ResourceManagerFuzzTest(const uint8_t* data, size_t size)
|
|||||||
uint16_t devType = *(reinterpret_cast<const uint16_t*>(data));
|
uint16_t devType = *(reinterpret_cast<const uint16_t*>(data));
|
||||||
DHType dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE];
|
DHType dhType = dhTypeFuzz[data[0] % DH_TYPE_SIZE];
|
||||||
std::string dhAttrs(reinterpret_cast<const char*>(data), size);
|
std::string dhAttrs(reinterpret_cast<const char*>(data), size);
|
||||||
|
std::string dhSubtype(reinterpret_cast<const char*>(data), size);
|
||||||
|
|
||||||
std::shared_ptr<CapabilityInfo> capInfo =
|
std::shared_ptr<CapabilityInfo> capInfo =
|
||||||
std::make_shared<CapabilityInfo>(dhId, devId, devName, devType, dhType, dhAttrs);
|
std::make_shared<CapabilityInfo>(dhId, devId, devName, devType, dhType, dhAttrs, dhSubtype);
|
||||||
std::vector<std::shared_ptr<CapabilityInfo>> resInfos;
|
std::vector<std::shared_ptr<CapabilityInfo>> resInfos;
|
||||||
resInfos.emplace_back(capInfo);
|
resInfos.emplace_back(capInfo);
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ const std::string UUID_TEST = "bb536a637105409e904d4da78290ab1";
|
|||||||
const std::string DH_ATTR_1 = "attr1";
|
const std::string DH_ATTR_1 = "attr1";
|
||||||
const std::string DEVICE_NAME = "Dev1";
|
const std::string DEVICE_NAME = "Dev1";
|
||||||
const std::string DH_ID_1 = "Camera_1";
|
const std::string DH_ID_1 = "Camera_1";
|
||||||
|
const std::string DH_SUBTYPE_TEST = "camera";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentManagerTest::SetUpTestCase(void)
|
void ComponentManagerTest::SetUpTestCase(void)
|
||||||
@ -476,8 +477,8 @@ HWTEST_F(ComponentManagerTest, get_enableparam_test_001, TestSize.Level0)
|
|||||||
DHContext::GetInstance().AddOnlineDevice(info->networkId, devInfo.uuid);
|
DHContext::GetInstance().AddOnlineDevice(info->networkId, devInfo.uuid);
|
||||||
|
|
||||||
const std::shared_ptr<CapabilityInfo> CAP_INFO_1 =
|
const std::shared_ptr<CapabilityInfo> CAP_INFO_1 =
|
||||||
std::make_shared<CapabilityInfo>(DH_ID_1, devInfo.deviceId, DEVICE_NAME,
|
std::make_shared<CapabilityInfo>(DH_ID_1, devInfo.deviceId, DEVICE_NAME,
|
||||||
TEST_DEV_TYPE_PAD, DHType::CAMERA, DH_ATTR_1);
|
TEST_DEV_TYPE_PAD, DHType::CAMERA, DH_ATTR_1, DH_SUBTYPE_TEST);
|
||||||
|
|
||||||
CapabilityInfoManager::GetInstance()->Init();
|
CapabilityInfoManager::GetInstance()->Init();
|
||||||
std::vector<std::shared_ptr<CapabilityInfo>> resInfos { CAP_INFO_1 };
|
std::vector<std::shared_ptr<CapabilityInfo>> resInfos { CAP_INFO_1 };
|
||||||
|
@ -52,29 +52,44 @@ const string TEST_DH_ID_3 = "Display_03";
|
|||||||
const string TEST_DH_ID_4 = "Input_04";
|
const string TEST_DH_ID_4 = "Input_04";
|
||||||
const string TEST_DH_ATTR_0 = "db_test_attr0";
|
const string TEST_DH_ATTR_0 = "db_test_attr0";
|
||||||
const string TEST_DH_ATTR_1 = "db_test_attr1";
|
const string TEST_DH_ATTR_1 = "db_test_attr1";
|
||||||
|
const string TEST_DH_SUBTYPE_0 = "camera";
|
||||||
|
const string TEST_DH_SUBTYPE_1 = "mic";
|
||||||
|
const string TEST_DH_SUBTYPE_2 = "gps";
|
||||||
|
const string TEST_DH_SUBTYPE_3 = "screen";
|
||||||
|
const string TEST_DH_SUBTYPE_4 = "input";
|
||||||
constexpr uint16_t TEST_DEV_TYPE = 0x11;
|
constexpr uint16_t TEST_DEV_TYPE = 0x11;
|
||||||
|
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_0 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_0 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_0, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::CAMERA, TEST_DH_ATTR_0);
|
make_shared<CapabilityInfo>(TEST_DH_ID_0, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::CAMERA, TEST_DH_ATTR_0,
|
||||||
|
TEST_DH_SUBTYPE_0);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_1 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_1 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_1, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::AUDIO, TEST_DH_ATTR_0);
|
make_shared<CapabilityInfo>(TEST_DH_ID_1, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::AUDIO, TEST_DH_ATTR_0,
|
||||||
|
TEST_DH_SUBTYPE_1);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_2 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_2 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_2, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::GPS, TEST_DH_ATTR_0);
|
make_shared<CapabilityInfo>(TEST_DH_ID_2, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::GPS, TEST_DH_ATTR_0,
|
||||||
|
TEST_DH_SUBTYPE_2);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_3 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_3 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_3, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::HFP, TEST_DH_ATTR_0);
|
make_shared<CapabilityInfo>(TEST_DH_ID_3, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::HFP, TEST_DH_ATTR_0,
|
||||||
|
TEST_DH_SUBTYPE_3);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_4 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_4 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_4, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::INPUT, TEST_DH_ATTR_0);
|
make_shared<CapabilityInfo>(TEST_DH_ID_4, TEST_DEV_ID_0, DEV_NAME, TEST_DEV_TYPE, DHType::INPUT, TEST_DH_ATTR_0,
|
||||||
|
TEST_DH_SUBTYPE_4);
|
||||||
|
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_5 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_5 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_0, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::CAMERA, TEST_DH_ATTR_1);
|
make_shared<CapabilityInfo>(TEST_DH_ID_0, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::CAMERA, TEST_DH_ATTR_1,
|
||||||
|
TEST_DH_SUBTYPE_0);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_6 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_6 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_1, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::AUDIO, TEST_DH_ATTR_1);
|
make_shared<CapabilityInfo>(TEST_DH_ID_1, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::AUDIO, TEST_DH_ATTR_1,
|
||||||
|
TEST_DH_SUBTYPE_1);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_7 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_7 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_2, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::GPS, TEST_DH_ATTR_1);
|
make_shared<CapabilityInfo>(TEST_DH_ID_2, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::GPS, TEST_DH_ATTR_1,
|
||||||
|
TEST_DH_SUBTYPE_2);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_8 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_8 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_3, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::HFP, TEST_DH_ATTR_1);
|
make_shared<CapabilityInfo>(TEST_DH_ID_3, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::HFP, TEST_DH_ATTR_1,
|
||||||
|
TEST_DH_SUBTYPE_3);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_9 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_9 =
|
||||||
make_shared<CapabilityInfo>(TEST_DH_ID_4, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::INPUT, TEST_DH_ATTR_1);
|
make_shared<CapabilityInfo>(TEST_DH_ID_4, TEST_DEV_ID_1, DEV_NAME, TEST_DEV_TYPE, DHType::INPUT, TEST_DH_ATTR_1,
|
||||||
|
TEST_DH_SUBTYPE_4);
|
||||||
|
|
||||||
std::shared_ptr<DBAdapter> g_dbAdapterPtr;
|
std::shared_ptr<DBAdapter> g_dbAdapterPtr;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,11 @@ const string DH_ID_3 = "Display_0";
|
|||||||
const string DH_ID_4 = "Input_0";
|
const string DH_ID_4 = "Input_0";
|
||||||
const string DH_ATTR_0 = "attr0";
|
const string DH_ATTR_0 = "attr0";
|
||||||
const string DH_ATTR_1 = "attr1";
|
const string DH_ATTR_1 = "attr1";
|
||||||
|
const string DH_SUBTYPE_0 = "camera";
|
||||||
|
const string DH_SUBTYPE_1 = "mic";
|
||||||
|
const string DH_SUBTYPE_2 = "gps";
|
||||||
|
const string DH_SUBTYPE_3 = "screen";
|
||||||
|
const string DH_SUBTYPE_4 = "input";
|
||||||
constexpr uint16_t TEST_DEV_TYPE_PAD = 0x11;
|
constexpr uint16_t TEST_DEV_TYPE_PAD = 0x11;
|
||||||
constexpr uint32_t TEST_DH_TYPE_CAMERA = 0x01;
|
constexpr uint32_t TEST_DH_TYPE_CAMERA = 0x01;
|
||||||
constexpr uint32_t TEST_DH_TYPE_MIC = 0x02;
|
constexpr uint32_t TEST_DH_TYPE_MIC = 0x02;
|
||||||
@ -63,26 +68,36 @@ constexpr uint32_t TEST_SIZE_10 = 10;
|
|||||||
const std::string EMPTY_PREFIX = "";
|
const std::string EMPTY_PREFIX = "";
|
||||||
|
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_0 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_0 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_0, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::CAMERA, DH_ATTR_0);
|
make_shared<CapabilityInfo>(DH_ID_0, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::CAMERA, DH_ATTR_0,
|
||||||
|
DH_SUBTYPE_0);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_1 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_1 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_1, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::AUDIO, DH_ATTR_0);
|
make_shared<CapabilityInfo>(DH_ID_1, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::AUDIO, DH_ATTR_0,
|
||||||
|
DH_SUBTYPE_1);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_2 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_2 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_2, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::GPS, DH_ATTR_0);
|
make_shared<CapabilityInfo>(DH_ID_2, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::GPS, DH_ATTR_0,
|
||||||
|
DH_SUBTYPE_2);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_3 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_3 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_3, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::SCREEN, DH_ATTR_0);
|
make_shared<CapabilityInfo>(DH_ID_3, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::SCREEN, DH_ATTR_0,
|
||||||
|
DH_SUBTYPE_3);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_4 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_4 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_4, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::INPUT, DH_ATTR_0);
|
make_shared<CapabilityInfo>(DH_ID_4, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::INPUT, DH_ATTR_0,
|
||||||
|
DH_SUBTYPE_4);
|
||||||
|
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_5 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_5 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_0, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::CAMERA, DH_ATTR_1);
|
make_shared<CapabilityInfo>(DH_ID_0, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::CAMERA, DH_ATTR_1,
|
||||||
|
DH_SUBTYPE_0);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_6 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_6 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_1, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::AUDIO, DH_ATTR_1);
|
make_shared<CapabilityInfo>(DH_ID_1, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::AUDIO, DH_ATTR_1,
|
||||||
|
DH_SUBTYPE_1);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_7 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_7 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_2, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::GPS, DH_ATTR_1);
|
make_shared<CapabilityInfo>(DH_ID_2, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::GPS, DH_ATTR_1,
|
||||||
|
DH_SUBTYPE_2);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_8 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_8 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_3, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::SCREEN, DH_ATTR_1);
|
make_shared<CapabilityInfo>(DH_ID_3, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::SCREEN, DH_ATTR_1,
|
||||||
|
DH_SUBTYPE_3);
|
||||||
const shared_ptr<CapabilityInfo> CAP_INFO_9 =
|
const shared_ptr<CapabilityInfo> CAP_INFO_9 =
|
||||||
make_shared<CapabilityInfo>(DH_ID_4, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::INPUT, DH_ATTR_1);
|
make_shared<CapabilityInfo>(DH_ID_4, DEV_ID_1, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::INPUT, DH_ATTR_1,
|
||||||
|
DH_SUBTYPE_4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManagerTest::SetUpTestCase(void)
|
void ResourceManagerTest::SetUpTestCase(void)
|
||||||
@ -464,7 +479,8 @@ HWTEST_F(ResourceManagerTest, resource_manager_test_019, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, resource_manager_test_020, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, resource_manager_test_020, TestSize.Level0)
|
||||||
{
|
{
|
||||||
CapabilityInfo capaInfo(DH_ID_0, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::CAMERA, DH_ATTR_0);
|
CapabilityInfo capaInfo(DH_ID_0, DEV_ID_0, TEST_DEV_NAME, TEST_DEV_TYPE_PAD, DHType::CAMERA,
|
||||||
|
DH_ATTR_0, DH_SUBTYPE_0);
|
||||||
bool ret = CAP_INFO_1->Compare(capaInfo);
|
bool ret = CAP_INFO_1->Compare(capaInfo);
|
||||||
EXPECT_EQ(false, ret);
|
EXPECT_EQ(false, ret);
|
||||||
}
|
}
|
||||||
@ -581,7 +597,7 @@ HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_001, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_002, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_002, TestSize.Level0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "");
|
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "", "");
|
||||||
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DH_ID;
|
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DH_ID;
|
||||||
std::string value;
|
std::string value;
|
||||||
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
||||||
@ -596,7 +612,7 @@ HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_002, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_003, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_003, TestSize.Level0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "");
|
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "", "");
|
||||||
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DEVICE_ID;
|
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DEVICE_ID;
|
||||||
std::string value;
|
std::string value;
|
||||||
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
||||||
@ -611,7 +627,7 @@ HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_003, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_004, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_004, TestSize.Level0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "");
|
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "", "");
|
||||||
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DEVICE_NAME;
|
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DEVICE_NAME;
|
||||||
std::string value;
|
std::string value;
|
||||||
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
||||||
@ -626,7 +642,7 @@ HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_004, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_005, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_005, TestSize.Level0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "");
|
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "", "");
|
||||||
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DEVICE_TYPE;
|
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DEVICE_TYPE;
|
||||||
uint16_t devType = 123;
|
uint16_t devType = 123;
|
||||||
std::string value = std::to_string(devType);
|
std::string value = std::to_string(devType);
|
||||||
@ -642,7 +658,7 @@ HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_005, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_006, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_006, TestSize.Level0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "");
|
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "", "");
|
||||||
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DH_TYPE;
|
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DH_TYPE;
|
||||||
DHType dhType = DHType::AUDIO;
|
DHType dhType = DHType::AUDIO;
|
||||||
std::string value = std::to_string(static_cast<uint32_t>(dhType));
|
std::string value = std::to_string(static_cast<uint32_t>(dhType));
|
||||||
@ -658,7 +674,7 @@ HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_006, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_007, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_007, TestSize.Level0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "");
|
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "", "");
|
||||||
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DH_ATTRS;
|
CapabilityInfoFilter filter = CapabilityInfoFilter::FILTER_DH_ATTRS;
|
||||||
std::string value;
|
std::string value;
|
||||||
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
bool ret = CapabilityInfoManager::GetInstance()->IsCapabilityMatchFilter(cap, filter, value);
|
||||||
@ -673,7 +689,7 @@ HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_007, TestSize.Level0)
|
|||||||
*/
|
*/
|
||||||
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_008, TestSize.Level0)
|
HWTEST_F(ResourceManagerTest, IsCapabilityMatchFilter_008, TestSize.Level0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "");
|
std::shared_ptr<CapabilityInfo> cap = std::make_shared<CapabilityInfo>("", "", "", 0, DHType::UNKNOWN, "", "");
|
||||||
uint32_t invalid = 6;
|
uint32_t invalid = 6;
|
||||||
CapabilityInfoFilter filter = static_cast<CapabilityInfoFilter>(invalid);
|
CapabilityInfoFilter filter = static_cast<CapabilityInfoFilter>(invalid);
|
||||||
std::string value;
|
std::string value;
|
||||||
@ -814,7 +830,8 @@ HWTEST_F(ResourceManagerTest, DumpCapabilityInfos_001, TestSize.Level0)
|
|||||||
uint16_t devType = 0;
|
uint16_t devType = 0;
|
||||||
DHType dhType = DHType::GPS;
|
DHType dhType = DHType::GPS;
|
||||||
std::string dhAttrs;
|
std::string dhAttrs;
|
||||||
CapabilityInfo info(dhId, devId, devName, devType, dhType, dhAttrs);
|
std::string dhSubtype;
|
||||||
|
CapabilityInfo info(dhId, devId, devName, devType, dhType, dhAttrs, dhSubtype);
|
||||||
capInfos.push_back(info);
|
capInfos.push_back(info);
|
||||||
CapabilityInfoManager::GetInstance()->DumpCapabilityInfos(capInfos);
|
CapabilityInfoManager::GetInstance()->DumpCapabilityInfos(capInfos);
|
||||||
EXPECT_EQ(nullptr, CapabilityInfoManager::GetInstance()->dbAdapterPtr_);
|
EXPECT_EQ(nullptr, CapabilityInfoManager::GetInstance()->dbAdapterPtr_);
|
||||||
@ -834,7 +851,8 @@ HWTEST_F(ResourceManagerTest, FromJson_001, TestSize.Level0)
|
|||||||
uint16_t devType = 0;
|
uint16_t devType = 0;
|
||||||
DHType dhType = DHType::GPS;
|
DHType dhType = DHType::GPS;
|
||||||
std::string dhAttrs;
|
std::string dhAttrs;
|
||||||
CapabilityInfo info(dhId, devId, devName, devType, dhType, dhAttrs);
|
std::string dhSubtype;
|
||||||
|
CapabilityInfo info(dhId, devId, devName, devType, dhType, dhAttrs, dhSubtype);
|
||||||
nlohmann::json jsonObject;
|
nlohmann::json jsonObject;
|
||||||
const std::string DH_ID = "dh_id";
|
const std::string DH_ID = "dh_id";
|
||||||
const std::string DEV_ID = "dev_id";
|
const std::string DEV_ID = "dev_id";
|
||||||
@ -842,12 +860,14 @@ HWTEST_F(ResourceManagerTest, FromJson_001, TestSize.Level0)
|
|||||||
const std::string DEV_TYPE = "dev_type";
|
const std::string DEV_TYPE = "dev_type";
|
||||||
const std::string DH_TYPE = "dh_type";
|
const std::string DH_TYPE = "dh_type";
|
||||||
const std::string DH_ATTRS = "dh_attrs";
|
const std::string DH_ATTRS = "dh_attrs";
|
||||||
|
const std::string DH_SUBTYPE = "dh_subtype";
|
||||||
jsonObject[DH_ID] = "dh_id";
|
jsonObject[DH_ID] = "dh_id";
|
||||||
jsonObject[DEV_ID] = "dev_id";
|
jsonObject[DEV_ID] = "dev_id";
|
||||||
jsonObject[DEV_NAME] = "dev_name";
|
jsonObject[DEV_NAME] = "dev_name";
|
||||||
jsonObject[DEV_TYPE] = "dev_type";
|
jsonObject[DEV_TYPE] = "dev_type";
|
||||||
jsonObject[DH_TYPE] = "dh_type";
|
jsonObject[DH_TYPE] = "dh_type";
|
||||||
jsonObject[DH_ATTRS] = "dh_attrs";
|
jsonObject[DH_ATTRS] = "dh_attrs";
|
||||||
|
jsonObject[DH_SUBTYPE] = "dh_subtype";
|
||||||
CapabilityInfo capability;
|
CapabilityInfo capability;
|
||||||
std::string jsonStr = jsonObject.dump();
|
std::string jsonStr = jsonObject.dump();
|
||||||
EXPECT_EQ(DH_FWK_SUCCESS, info.FromJsonString(jsonStr));
|
EXPECT_EQ(DH_FWK_SUCCESS, info.FromJsonString(jsonStr));
|
||||||
|
@ -54,6 +54,8 @@ bool IsUInt32(const nlohmann::json& jsonObj, const std::string& key);
|
|||||||
bool IsBool(const nlohmann::json& jsonObj, const std::string& key);
|
bool IsBool(const nlohmann::json& jsonObj, const std::string& key);
|
||||||
|
|
||||||
bool IsString(const nlohmann::json& jsonObj, const std::string& key);
|
bool IsString(const nlohmann::json& jsonObj, const std::string& key);
|
||||||
|
|
||||||
|
bool IsArray(const nlohmann::json& jsonObj, const std::string& key);
|
||||||
} // namespace DistributedHardware
|
} // namespace DistributedHardware
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
#endif
|
#endif
|
||||||
|
@ -164,5 +164,12 @@ bool IsString(const nlohmann::json& jsonObj, const std::string& key)
|
|||||||
jsonObj[key].size() <= MAX_MESSAGE_LEN;
|
jsonObj[key].size() <= MAX_MESSAGE_LEN;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsArray(const nlohmann::json& jsonObj, const std::string& key)
|
||||||
|
{
|
||||||
|
bool res = jsonObj.contains(key) && jsonObj[key].is_array() && jsonObj[key].size() > 0 &&
|
||||||
|
jsonObj[key].size() <= MAX_COMP_SIZE;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
} // namespace DistributedHardware
|
} // namespace DistributedHardware
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
Loading…
Reference in New Issue
Block a user