Fix logical errors in drag allow

Signed-off-by: dongzhanwu <dongzhanwu1@huawei.com>
This commit is contained in:
dongzhanwu 2023-11-16 21:18:37 +08:00
parent 527f9cfb84
commit e07bed31f4
2 changed files with 7 additions and 2 deletions

View File

@ -75,7 +75,7 @@ constexpr int32_t RADIUS_OUT { 42 };
constexpr int32_t ALPHA_IN { 51 };
constexpr int32_t ALPHA_OUT { 0 };
const std::string UD_KEY { "Unified data key" };
const std::string EXTRA_INFO { "{ \"drag_allow_distributed\", false }" };
const std::string EXTRA_INFO { "{ \"drag_allow_distributed\" : false }" };
const std::string SYSTEM_CORE { "system_core" };
const std::string SYSTEM_BASIC { "system_basic" };
int32_t g_deviceMouseId { -1 };

View File

@ -92,6 +92,7 @@ constexpr int32_t GLOBAL_WINDOW_ID { -1 };
constexpr int32_t MOUSE_DRAG_CURSOR_CIRCLE_STYLE { 41 };
constexpr int32_t CURSOR_CIRCLE_MIDDLE { 2 };
constexpr int32_t ALPHA_SHIFT { 24 };
constexpr size_t EXTRA_INFO_MAX_SIZE { 100 };
const Rosen::RSAnimationTimingCurve SHARP_CURVE = Rosen::RSAnimationTimingCurve::CreateCubicCurve(0.33, 0, 0.67, 1);
const std::string DEVICE_TYPE_DEFAULT { "default" };
const std::string DEVICE_TYPE_PHONE { "phone" };
@ -1171,6 +1172,10 @@ bool DragDrawing::GetAllowDragState()
FI_HILOGE("The extraInfo is empty");
return true;
}
if (g_drawingInfo.extraInfo.size() > EXTRA_INFO_MAX_SIZE) {
FI_HILOGE("The extraInfo is greater than the length limit");
return true;
}
JsonDataParser extraInfoParser;
extraInfoParser.json = cJSON_Parse(g_drawingInfo.extraInfo.c_str());
if (!cJSON_IsObject(extraInfoParser.json)) {
@ -1183,7 +1188,7 @@ bool DragDrawing::GetAllowDragState()
return true;
}
cJSON *json = cJSON_GetObjectItem(extraInfoParser.json, "drag_allow_distributed");
if (json != nullptr || !cJSON_IsBool(json)) {
if (json == nullptr || !cJSON_IsBool(json)) {
FI_HILOGE("Can't parse \'drag_allow_distributed\' in extraInfo");
return true;
}