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(featureMap, *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(FeatureParamMapType & featureMap,xmlNode & node)42 int32_t RotateOffScreenParamParse::ParseRotateOffScreenInternal(FeatureParamMapType &featureMap, xmlNode &node)
43 {
44 xmlNode *currNode = &node;
45
46 auto iter = featureMap.find(FEATURE_CONFIGS[RotateOffScreen]);
47 if (iter == featureMap.end()) {
48 RS_LOGE("RotateOffScreenParamParse stop parsing, no initializing param map");
49 return PARSE_INTERNAL_FAIL;
50 }
51 rotateOffScreenParam_ = std::static_pointer_cast<RotateOffScreenParam>(iter->second);
52
53 // Start Parse Feature Params
54 int xmlParamType = GetXmlNodeAsInt(*currNode);
55 auto name = ExtractPropertyValue("name", *currNode);
56 auto val = ExtractPropertyValue("value", *currNode);
57 if (xmlParamType == PARSE_XML_FEATURE_SWITCH) {
58 bool isEnabled = ParseFeatureSwitch(val);
59 if (name == "RotateOffScreenDisplayNodeEnabled") {
60 rotateOffScreenParam_->SetRotateOffScreenDisplayNodeEnable(isEnabled);
61 RS_LOGI("RotateOffScreenParamParse parse RotateOffScreenDisplayNodeEnable %{public}d", isEnabled);
62 }
63 }
64 return PARSE_EXEC_SUCCESS;
65 }
66 } // namespace OHOS::Rosen