• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <sstream>
17 #include "rotateoffscreen_param_parse.h"
18 
19 namespace OHOS::Rosen {
ParseFeatureParam(FeatureParamMapType & featureMap,xmlNode & node)20 int32_t RotateOffScreenParamParse::ParseFeatureParam(FeatureParamMapType &featureMap, xmlNode &node)
21 {
22     xmlNode *currNode = &node;
23     if (currNode->xmlChildrenNode == nullptr) {
24         RS_LOGE("RotateOffScreenParamParse stop parsing, no children nodes");
25         return PARSE_GET_CHILD_FAIL;
26     }
27 
28     currNode = currNode->xmlChildrenNode;
29     for (; currNode; currNode = currNode->next) {
30         if (currNode->type != XML_ELEMENT_NODE) {
31             continue;
32         }
33 
34         if (ParseRotateOffScreenInternal(*currNode) != PARSE_EXEC_SUCCESS) {
35             RS_LOGE("RotateOffScreenParamParse stop parsing, parse internal fail");
36             return PARSE_INTERNAL_FAIL;
37         }
38     }
39     return PARSE_EXEC_SUCCESS;
40 }
41 
ParseRotateOffScreenInternal(xmlNode & node)42 int32_t RotateOffScreenParamParse::ParseRotateOffScreenInternal(xmlNode &node)
43 {
44     // Start Parse Feature Params
45     int xmlParamType = GetXmlNodeAsInt(node);
46     auto name = ExtractPropertyValue("name", node);
47     auto val = ExtractPropertyValue("value", node);
48     if (xmlParamType == PARSE_XML_FEATURE_SWITCH) {
49         bool isEnabled = ParseFeatureSwitch(val);
50         if (name == "RotateOffScreenDisplayNodeEnabled") {
51             RotateOffScreenParam::SetRotateOffScreenDisplayNodeEnable(isEnabled);
52             RS_LOGI("RotateOffScreenParamParse parse RotateOffScreenDisplayNodeEnable %{public}d", isEnabled);
53         } else if (name == "RotateOffScreenSurfaceNodeEnabled") {
54             RotateOffScreenParam::SetRotateOffScreenSurfaceNodeEnable(isEnabled);
55             RS_LOGI("RotateOffScreenParamParse parse RotateOffScreenSurfaceNodeEnable %{public}d", isEnabled);
56         } else if (name == "RotateOffScreenDowngradeEnabled") {
57             RotateOffScreenParam::SetRotateOffScreenDowngradeEnable(isEnabled);
58             RS_LOGI("RotateOffScreenParamParse parse RotateOffScreenDowngradeEnabled %{public}d", isEnabled);
59         }
60     }
61     return PARSE_EXEC_SUCCESS;
62 }
63 } // namespace OHOS::Rosen