mirror of
https://gitee.com/openharmony/deviceprofile_device_info_manager
synced 2024-11-26 17:21:03 +00:00
commit
cd33df2dbb
@ -54,6 +54,12 @@ public:
|
||||
static bool IsSvrProfileValid(const ServiceProfile& svrProfile);
|
||||
// This mothed can be invoked only when put or delete profile.
|
||||
static bool IsCharProfileValid(const CharacteristicProfile& charProfile);
|
||||
// This mothed can be invoked only when get profile.
|
||||
static bool IsDeviceProfileValid(const DeviceProfile& devProfile);
|
||||
// This mothed can be invoked only when get profile.
|
||||
static bool IsServiceProfileValid(const ServiceProfile& svrProfile);
|
||||
// This mothed can be invoked only when get profile.
|
||||
static bool IsCharacteristicProfileValid(const CharacteristicProfile& charProfile);
|
||||
static std::string GenerateDeviceProfileKey(const std::string& deviceId);
|
||||
static std::string GenerateServiceProfileKey(const std::string& deviceId, const std::string& serviceName);
|
||||
static std::string GenerateCharProfileKey(const std::string& deviceId, const std::string& serviceName,
|
||||
|
@ -363,6 +363,30 @@ bool ProfileUtils::IsCharProfileValid(const CharacteristicProfile& charProfile)
|
||||
IsKeyValid(charProfile.GetServiceName()) && IsKeyValid(charProfile.GetCharacteristicKey());
|
||||
}
|
||||
|
||||
bool ProfileUtils::IsDeviceProfileValid(const DeviceProfile& devProfile)
|
||||
{
|
||||
if (devProfile.GetOsVersion().empty() || devProfile.GetOsType() == MIN_OS_TYPE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProfileUtils::IsServiceProfileValid(const ServiceProfile& svrProfile)
|
||||
{
|
||||
if (svrProfile.GetServiceName().empty() || svrProfile.GetServiceType().empty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProfileUtils::IsCharacteristicProfileValid(const CharacteristicProfile& charProfile)
|
||||
{
|
||||
if (charProfile.GetCharacteristicKey().empty() || charProfile.GetCharacteristicValue().empty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ProfileUtils::GenerateDeviceProfileKey(const std::string& deviceId)
|
||||
{
|
||||
return DEV_PREFIX + SEPARATOR + deviceId;
|
||||
@ -704,6 +728,7 @@ bool ProfileUtils::IsPropertyValid(const std::map<std::string, std::string>& pro
|
||||
(static_cast<int32_t>(propertyMap.at(property).length())) < maxValue) {
|
||||
return true;
|
||||
}
|
||||
HILOGE("property is valid, property : %{public}s", property.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -711,7 +736,7 @@ bool ProfileUtils::IsPropertyValid(const std::map<std::string, std::string>& pro
|
||||
int32_t minValue, int32_t maxValue)
|
||||
{
|
||||
if (property.empty() || propertyMap.find(property) == propertyMap.end()) {
|
||||
HILOGE("property is valid");
|
||||
HILOGE("property is valid, property : %{public}s", property.c_str());
|
||||
return false;
|
||||
}
|
||||
std::string propertyValue = propertyMap.at(property);
|
||||
|
@ -244,6 +244,10 @@ int32_t ProfileControlUtils::GetDeviceProfile(std::shared_ptr<IKVAdapter> kvStor
|
||||
return DP_GET_KV_DB_FAIL;
|
||||
}
|
||||
ProfileUtils::EntriesToDeviceProfile(values, deviceProfile);
|
||||
if (!ProfileUtils::IsDeviceProfileValid(deviceProfile)) {
|
||||
HILOGE("deviceProfile is invalid!");
|
||||
return DP_GET_KV_DB_FAIL;
|
||||
}
|
||||
HILOGD("GetDeviceProfile in db : %{public}s!", deviceProfile.AnnoymizeDump().c_str());
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
@ -273,6 +277,10 @@ int32_t ProfileControlUtils::GetServiceProfile(std::shared_ptr<IKVAdapter> kvSto
|
||||
return DP_GET_KV_DB_FAIL;
|
||||
}
|
||||
ProfileUtils::EntriesToServiceProfile(values, serviceProfile);
|
||||
if (!ProfileUtils::IsServiceProfileValid(serviceProfile)) {
|
||||
HILOGE("serviceProfile is invalid!");
|
||||
return DP_GET_KV_DB_FAIL;
|
||||
}
|
||||
HILOGD("GetServiceProfile in db : %{public}s!", serviceProfile.dump().c_str());
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
@ -312,6 +320,10 @@ int32_t ProfileControlUtils::GetCharacteristicProfile(std::shared_ptr<IKVAdapter
|
||||
}
|
||||
}
|
||||
ProfileUtils::EntriesToCharProfile(values, charProfile);
|
||||
if (!ProfileUtils::IsCharacteristicProfileValid(charProfile)) {
|
||||
HILOGE("charProfile is invalid!");
|
||||
return DP_GET_KV_DB_FAIL;
|
||||
}
|
||||
HILOGD("GetCharacteristicProfile in db : %{public}s!", charProfile.dump().c_str());
|
||||
return DP_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user