1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "prevalidate_param_parse.h"
17
18 namespace OHOS::Rosen {
19
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)20 int32_t PrevalidateParamParse::ParseFeatureParam(FeatureParamMapType &featureMap, xmlNode &node)
21 {
22 RS_LOGI("PrevalidateParamParse start");
23 xmlNode *currNode = &node;
24 if (currNode->xmlChildrenNode == nullptr) {
25 RS_LOGE("PrevalidateParamParse stop parsing, no children nodes");
26 return PARSE_GET_CHILD_FAIL;
27 }
28
29 currNode = currNode->xmlChildrenNode;
30 for (; currNode; currNode = currNode->next) {
31 if (currNode->type != XML_ELEMENT_NODE) {
32 continue;
33 }
34
35 if (ParsePrevalidateInternal(*currNode) != PARSE_EXEC_SUCCESS) {
36 RS_LOGE("PrevalidateParamParse stop parsing, parse internal fail");
37 return PARSE_INTERNAL_FAIL;
38 }
39 }
40
41 return PARSE_EXEC_SUCCESS;
42 }
43
ParsePrevalidateInternal(xmlNode & node)44 int32_t PrevalidateParamParse::ParsePrevalidateInternal(xmlNode &node)
45 {
46 // Start Parse Feature Params
47 int xmlParamType = GetXmlNodeAsInt(node);
48 auto name = ExtractPropertyValue("name", node);
49 if (xmlParamType == PARSE_XML_FEATURE_SWITCH && name == "PrevalidateEnabled") {
50 auto val = ExtractPropertyValue("value", node);
51 bool isEnabled = ParseFeatureSwitch(val);
52 PrevalidateParam::SetPrevalidateEnable(isEnabled);
53 RS_LOGI("PrevalidateEnabled parse PrevalidateEnabled %{public}d", PrevalidateParam::IsPrevalidateEnable());
54 }
55
56 return PARSE_EXEC_SUCCESS;
57 }
58 } // namespace OHOS::Rosen
59